C#图像设计practice

来源:互联网 发布:洛阳广电网络客服电话 编辑:程序博客网 时间:2024/05/16 17:02

在点P11010)和P210050)之间画一条红色的线段

private void button1_Click(object sender, EventArgs e)        {            Graphics g = this.CreateGraphics();            Pen p1 = new Pen(Color.Red, 2);            g.DrawLine(p1, 10, 10, 100, 50);        }

使用BackwardDiagonalVertical,Cross等图案填充饼图。

使用画刷来填充:

private void button1_Click(object sender, EventArgs e)        {            HatchBrush h1 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Gold),                       h2 = new HatchBrush(HatchStyle.Cross, Color.Yellow),                       h3 = new HatchBrush(HatchStyle.Vertical, Color.Snow);            Graphics g = this.CreateGraphics();            g.Clear(this.BackColor);            g.FillPie(h1, 10, 10, 200, 200, 0, 60);            g.FillPie(h2, 210, 210, 200, 200, 0, 120);            g.FillPie(h3, 410, 410, 200, 200, 0, 180);        }


PictureBox1内部画一个绿色的椭圆边框。

private void button1_Click(object sender, EventArgs e)        {            Graphics g = pictureBox1.CreateGraphics();            Pen p = new Pen(Color.Green, 1);            g.DrawEllipse(p, 10, 10, 200, 100);        }
用黄色填充一个绿色椭圆。


private void button1_Click(object sender, EventArgs e)        {            Graphics g = this.CreateGraphics();            g.Clear(this.BackColor);            Brush b = new SolidBrush(Color.Yellow);            Pen p = new Pen(Color.Green, 2);            g.DrawEllipse(p, 10, 20, 100, 200);            g.FillEllipse(b, 10, 20, 100, 200);        }


蝴蝶曲线:
极坐标表达式:
在VS中写出来:
private void button1_Click(object sender, EventArgs e)        {            Graphics g = this.CreateGraphics();            float a = this.Width / 2, b = this.Height / 2;            g.TranslateTransform(a,b);            Pen p = new Pen(Color.Green , 4);            float x1, y1, x2, y2, t, t1,e1;            for (t = 0; t < 50 * 3.1415926; t += 0.0001f)            {                t1 = t + 3.1415926f / 2;                e1 = Convert.ToSingle(Math.Pow(2.718281f, Math.Cos(t1)) - 2 * Math.Cos(4 * t1) + Math.Pow(Math.Sin(t1 / 12), 5));                x1 = Convert.ToSingle(e1 * Math.Cos(t) * 30);                y1 = Convert.ToSingle(e1 * Math.Sin(t) * 30);                x2 = Convert.ToSingle(e1 * Math.Cos(t + 0.0001f) * 30);                y2 = Convert.ToSingle(e1 * Math.Sin(t + 0.0001f) * 30);                g.DrawLine(p, x1, y1, x2, y2);            }        }



0 0
原创粉丝点击