C#图像设计practice

网友投稿 641 2022-10-04 11:30:35

C#图像设计practice

在点P1(10,10)和P2(100,50)之间画一条红色的线段

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); }

使用BackwardDiagonal、Vertical,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); } }

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringBoot集成Jasypt敏感信息加密的操作方法
下一篇:小程序之间怎么跳转?小程序之间跳转方法(小程序跳转的几种方式)
相关文章