SharpMap.Rendering.Thematics.ColorBlend.ToBrush C# (CSharp) Method

ToBrush() public method

Converts the color blend to a gradient brush
public ToBrush ( Rectangle rectangle, float angle ) : LinearGradientBrush
rectangle Rectangle
angle float
return System.Drawing.Drawing2D.LinearGradientBrush
        public System.Drawing.Drawing2D.LinearGradientBrush ToBrush(Rectangle rectangle, float angle)
        {
            LinearGradientBrush br = new LinearGradientBrush(rectangle, Color.Black, Color.Black, angle, true);
            System.Drawing.Drawing2D.ColorBlend cb = new System.Drawing.Drawing2D.ColorBlend();
            cb.Colors = _Colors;
            cb.Positions = _Positions;
            br.InterpolationColors = cb;
            return br;
        }

Usage Example

Beispiel #1
0
 public void ToBrushTest()
 {
     ColorBlend colorBlend = new ColorBlend(new Color[] {Color.Blue, Color.GreenYellow, Color.Red}, new float[] {0f, 500f, 1000f} );
     Assert.IsNotNull(colorBlend);
     System.Drawing.Drawing2D.LinearGradientBrush lgb = colorBlend.ToBrush(new Rectangle(0, 0, 100, 100), 0.5f);
     Assert.IsNotNull(lgb);
     Assert.AreEqual(1.0f, lgb.InterpolationColors.Positions[2]);
 }