c#画笔Pen绘制曲线

来源:互联网 发布:经济学的大数据 编辑:程序博客网 时间:2024/04/29 15:55
 
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Drawing.Drawing2D;
  9. namespace WindowsApplication2
  10. {
  11.     public partial class Form11 : Form
  12.     {
  13.         public Form11()
  14.         {
  15.             InitializeComponent();
  16.         }
  17.         private void button1_Click(object sender, EventArgs e)
  18.         {
  19.            
  20.             LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle, Color.Empty, Color.Empty, 100);
  21.             ColorBlend blend = new ColorBlend();
  22.             blend.Colors = new Color[] { Color.Red, Color.Green, Color.Blue };
  23.             blend.Positions = new float[] { 0, .5f, 1 };
  24.             brush.InterpolationColors = blend;
  25.             Pen pen5 = new Pen(brush);
  26.             Graphics g5 = this.CreateGraphics();
  27.             Point[] p = new Point[] { new Point(0, 0), new Point(100, 100), new Point(50, 100), new Point(200, 100) };
  28.             g5.DrawCurve(pen5,p);
  29.         }
  30.     }
  31. }
原创粉丝点击