public partial class Form_Hhrong : Form ......{ public Form_Hhrong() ......{ InitializeComponent(); this.timer1.Enabled = true; } Graphics gline; Graphics gbizer; int i = 0; byte r = 70;/**//**//**////定义三原色的值 byte g = 60;/**//**//**////通过后面方法中对三个值的改写 byte b = 30;/**//**//**////实现颜色的渐变
///画直线条: public void showline() ......{ gline = this.CreateGraphics();/**//**//**////this指代的是当前窗体 Color cl = Color.FromArgb(r,g,b);/**//**//**////颜色的混合色值 Pen pn = new Pen(cl); gline.DrawLine(pn,0,i,this.Width ,i);/**//**//**////在行方向上确定一条直线 ///一名实现从上到下的变动 ///以及颜色的渐变: } /**//**//**//// <summary> /// 画贝塞尔曲线: /// </summary> int x ; int y;/**//**//**////定义点的变动幅度: public void showbizer() ......{ gbizer = this.CreateGraphics(); Color clr = Color.FromArgb(r, g, b); Pen pn = new Pen(clr); Point[] pp =......{ new Point(5+x,6+y),new Point (20+x,30+y), new Point (42+x,58+y),new Point (79+x,59+y) }; gbizer.DrawBezier(pn, pp[0],pp[1],pp[2],pp[3]); } private void timer1_Tick(object sender, EventArgs e) ......{ showline(); i++; /**//**//**////让线条向下移动一个点; r += 20; g += 10; b += 25; showbizer(); x += 1; y += 1; } }
|