Draw.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WindowsFormsApp1
  11. {
  12. /// <summary>
  13. /// Создаём графическое изображение
  14. /// </summary>
  15. public partial class Draw : Form
  16. {
  17. /// <summary>
  18. /// Создаём цвета похожими на образец
  19. /// </summary>
  20. SolidBrush lightGreen = new SolidBrush(Color.FromArgb(144, 198, 56));
  21. SolidBrush darkRed = new SolidBrush(Color.FromArgb(184, 31, 31));
  22. SolidBrush darkGreen = new SolidBrush(Color.FromArgb(0, 100, 0));
  23. /// <summary>
  24. /// Создаём экземпляр класса Graphics
  25. /// </summary>
  26. Graphics g;
  27. public Draw()
  28. {
  29. InitializeComponent();
  30. }
  31. /// <summary>
  32. /// Создаём рисунок по варианту
  33. /// </summary>
  34. private void Draw_Paint(object sender, PaintEventArgs e)
  35. {
  36. g = CreateGraphics();
  37. // Первый многоугольник (свет треуг)
  38. Point p1 = new Point(50, 50);
  39. Point p2 = new Point(250, 250);
  40. Point p3 = new Point(50, 250);
  41. PointF[] firstPolygon = new PointF[] { p1, p2, p3};
  42. g.FillPolygon(lightGreen, firstPolygon);
  43. // Второй многоугольник (темный треуг)
  44. Point Pi1 = new Point(150,150);
  45. Point Pi2 = new Point(250,50);
  46. Point Pi3 = new Point(250,250);
  47. PointF[] Polygon = new PointF[] { Pi1, Pi2, Pi3 };
  48. g.FillPolygon(darkGreen, Polygon);
  49. // Третий многоугольник (квадрат)
  50. Point po1 = new Point(195, 105);
  51. Point po2 = new Point(150, 60);
  52. Point po3 = new Point(105, 105);
  53. Point po4 = new Point(150, 150);
  54. PointF[] Polygons = new PointF[] { po1, po2, po3, po4 };
  55. g.FillPolygon(darkRed, Polygons);
  56. }
  57. }
  58. }