using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp13
public partial class Form1 : Form
private void Form1_Load(object sender, EventArgs e)
Bitmap bmp = new Bitmap(400, 300);
Graphics g = Graphics.FromImage(bmp);
Pen p = new Pen(Color.Red, 3);
g.DrawRectangle(p, 10, 10, 20, 20);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawEllipse(Pens.Blue, 40, 10, 20, 20);
g.FillRectangle(Brushes.Brown, 70, 10, 20, 20);
Brush b = new LinearGradientBrush(new Point(40, 40), new Point(90, 90), Color.Red, Color.Blue);
g.FillRectangle(b, 40, 40, 50, 50);
int x = 70, y = 10, width = 20, height = 20;
g.ScaleTransform(0.5f, 0.5f);
g.FillRectangle(Brushes.Tomato, x, y, width, height);
g.FillRectangle(Brushes.Tomato, x, y, width, height);
g.TranslateTransform(x + width / 2, y + height / 2);
g.ScaleTransform(0.5f, 0.5f);
g.FillRectangle(Brushes.Tomato, -width / 2, -height / 2, width, height);
g.DrawLine(Pens.Black, new Point(30, 30), new Point(100, 100));
var path = new GraphicsPath();
path.AddLines(new Point[]
g.DrawPath(Pens.Green, path);
g.FillPath(Brushes.Green, path);