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;
using System.Drawing.Drawing2D;
namespace gdi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle rect = this.ClientRectangle;
LinearGradientBrush lbrush = new LinearGradientBrush(rect, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal);
g.FillRectangle(lbrush, rect);
Pen pn = new Pen(Color.Blue);
rect = new Rectangle(50, 50, 200, 100);
g.DrawArc(pn, rect, 12, 84);
Pen pn2 = new Pen(Color.BlueViolet);
Point pt1 = new Point(30, 30);
Point pt2 = new Point(110, 100);
g.DrawLine(pn2, pt1, pt2);
g.DrawString("welcome to the graphics world", this.Font, new SolidBrush(Color.Azure), 10, 10);
Pen pn3 = new Pen(Color.Aqua, 5);
rect=new Rectangle(ClientRectangle.Right-60,ClientRectangle.Bottom-60,50,50);
g.DrawEllipse(pn3,rect);
GraphicsPath path = new GraphicsPath(new Point[]
{
new Point(40,140),new Point(275,200),new Point(105,225),new Point(190,ClientRectangle.Bottom),
new Point(50,ClientRectangle.Bottom),new Point(20,180),
},
new byte[]
{
(byte)PathPointType.Start,
(byte)PathPointType.Bezier,
(byte)PathPointType.Bezier,
(byte)PathPointType.Bezier,
(byte)PathPointType.Line,
(byte)PathPointType.Line,
});
PathGradientBrush pgb = new PathGradientBrush(path);
pgb.SurroundColors = new Color[] { Color.Green, Color.Yellow, Color.Red, Color.Blue, Color.Orange, Color.White, };
g.FillPath(pgb, path);
}
}
}
No comments:
Post a Comment