Silverlight 引路蜂二维图形库示例:颜色渐变

jerry Silverligth 2015年11月26日 收藏

颜色渐变(Gradient)定义了颜色从一种颜色到另一种颜色的平滑过渡,引路蜂二维图形库支持线性和圆形渐变。

  1. private void Gradients()
  2. {
  3.  /* The linear gradient color */
  4.  LinearGradientBrush brush1;
  5.  /* The radial gradient color */
  6.  RadialGradientBrush brush2;
  7.  
  8.  int[] fractions = new[] { 13, 242 };
  9.  Color[] colors = new[] { new Color(0xffff6600, false), new Color(0xffffff66, false) };
  10.  brush1 = new LinearGradientBrush(50, 50, 150, 125, fractions, colors, Brush.NoCycle);
  11.  
  12.  fractions = new int[] { 13, 128, 255 };
  13.  colors = new[]{new Color(0xffff6600,false),new Color(0xffffff66,false),
  14.     new Color(0xffff6600,false)};
  15.  brush2 = new RadialGradientBrush(90, 100, 50, fractions, colors);
  16.  
  17.  //Clear the canvas with white color.
  18.  graphics2D.Clear(Color.White);
  19.  graphics2D.FillRectangle(brush1, new Rectangle(10, 75, 120, 80));
  20.  
  21.  Pen pen = new Pen(brush2, 8);
  22.  graphics2D.DrawOval(pen, 20, 60, 100, 50);
  23. }