//optien quel couleur est associer a un nombre public static sTileTriangleColor GetTriangleColor(int TheNumber) { sTileTriangleColor rep = new sTileTriangleColor(Color.Black, Color.White); switch (TheNumber) { case 0: rep.BackColor = Color.FromArgb(32, 32, 32); rep.ForeColor = Color.FromArgb(254, 254, 254); break; case 1: rep.BackColor = module.MultiplyLightLevel(Color.Chocolate, 1.1f); rep.ForeColor = Color.Black; break; case 2: rep.BackColor = module.MultiplyLightLevel(Color.Red, 0.9f); rep.ForeColor = Color.FromArgb(254, 254, 254); break; case 3: rep.BackColor = Color.Orange; rep.ForeColor = Color.Black; break; case 4: rep.BackColor = Color.Yellow; rep.ForeColor = Color.Black; break; case 5: rep.BackColor = Color.LimeGreen; rep.ForeColor = Color.Black; break; case 6: rep.BackColor = module.MultiplyLightLevel(Color.SteelBlue, 0.75f); rep.ForeColor = Color.FromArgb(254, 254, 254); break; case 7: rep.BackColor = Color.Purple; rep.ForeColor = Color.FromArgb(254, 254, 254); break; case 8: rep.BackColor = Color.Gray; rep.ForeColor = Color.Black; break; case 9: rep.BackColor = Color.Gainsboro; rep.ForeColor = Color.Black; break; default: rep.BackColor = Color.DarkBlue; rep.ForeColor = Color.White; break; } return(rep); }
//optien un seul triangle d'une tile en fonction du nombre et la position du triangle public static Bitmap GetBitmapForTriangle(oTile.TileDiv TheDiv, int TheNumber) { int twidth = oTile.TileWidth; int twidth2 = twidth / 2; Bitmap img = new Bitmap(twidth, twidth); img.MakeTransparent(); Graphics g = Graphics.FromImage(img); //fait quelque truc que tout le monde aura ou pourait avoir besoin string Text = TheNumber.ToString(); Font TextFont = new Font("consolas", 15); Size TextSize = module.GetTextSize(Text, TextFont); sTileTriangleColor AllColor = oTile.GetTriangleColor(TheNumber); Brush BackBrush = new SolidBrush(AllColor.BackColor); Brush ForeBrush = new SolidBrush(AllColor.ForeColor); //les coordonner des coin et du centre Point cUL = new Point(0, 0); Point cUR = new Point(twidth, 0); Point cDL = new Point(0, twidth); Point cDR = new Point(twidth, twidth); Point cCenter = new Point(twidth2, twidth2); if (TheDiv == TileDiv.up) { Point[] t = new Point[] { cUL, cUR, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point(twidth2 - (TextSize.Width / 2), (twidth2 / 2) - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } if (TheDiv == TileDiv.down) { Point[] t = new Point[] { cDL, cDR, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point(twidth2 - (TextSize.Width / 2), (twidth2 * 3 / 2) - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } if (TheDiv == TileDiv.right) { Point[] t = new Point[] { cUR, cDR, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point((twidth2 * 3 / 2) - (TextSize.Width / 2), twidth2 - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } if (TheDiv == TileDiv.left) { Point[] t = new Point[] { cUL, cDL, cCenter }; g.FillPolygon(BackBrush, t); Point TextPos = new Point((twidth2 / 2) - (TextSize.Width / 2), twidth2 - (TextSize.Height / 2)); g.DrawString(Text, TextFont, ForeBrush, (float)(TextPos.X), (float)(TextPos.Y)); } g.Dispose(); return(img); }