123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp1
- {
- /// <summary>
- /// Создаём графическое изображение
- /// </summary>
- public partial class Draw : Form
- {
- /// <summary>
- /// Создаём цвета похожими на образец
- /// </summary>
- SolidBrush lightGreen = new SolidBrush(Color.FromArgb(144, 198, 56));
- SolidBrush darkRed = new SolidBrush(Color.FromArgb(184, 31, 31));
- SolidBrush darkGreen = new SolidBrush(Color.FromArgb(0, 100, 0));
- /// <summary>
- /// Создаём экземпляр класса Graphics
- /// </summary>
- Graphics g;
- public Draw()
- {
- InitializeComponent();
- }
- /// <summary>
- /// Создаём рисунок по варианту
- /// </summary>
- private void Draw_Paint(object sender, PaintEventArgs e)
- {
- g = CreateGraphics();
- // Первый многоугольник (свет треуг)
- Point p1 = new Point(50, 50);
- Point p2 = new Point(250, 250);
- Point p3 = new Point(50, 250);
- PointF[] firstPolygon = new PointF[] { p1, p2, p3};
- g.FillPolygon(lightGreen, firstPolygon);
- // Второй многоугольник (темный треуг)
- Point Pi1 = new Point(150,150);
- Point Pi2 = new Point(250,50);
- Point Pi3 = new Point(250,250);
- PointF[] Polygon = new PointF[] { Pi1, Pi2, Pi3 };
- g.FillPolygon(darkGreen, Polygon);
- // Третий многоугольник (квадрат)
- Point po1 = new Point(195, 105);
- Point po2 = new Point(150, 60);
- Point po3 = new Point(105, 105);
- Point po4 = new Point(150, 150);
- PointF[] Polygons = new PointF[] { po1, po2, po3, po4 };
- g.FillPolygon(darkRed, Polygons);
- }
- }
- }
|