Gradient Color
Demonstrates drawing text with a gradient fill.
Сode Snippet
using (var bitmap = new Bitmap(600, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
var gradientBrush = new LinearGradientBrush()
{
BackgroundColor = RgbColor.Green,
StartPoint = new System.Drawing.PointF(0, 0),
EndPoint = new System.Drawing.PointF(600, 400),
ColorStops = new ColorStop[]
{
new ColorStop() { Color = RgbColor.Aqua, Position = 0.0f },
new ColorStop() { Color = RgbColor.Black, Position = 0.66f },
new ColorStop() { Color = RgbColor.Violet, Position = 1 },
},
};
var dummyText = "GRADIENT";
var text = new PlainText(dummyText, graphics.CreateFont("Verdana", 110f))
{
Position = new System.Drawing.PointF(10f, 230f),
Brush = gradientBrush,
};
graphics.DrawText(text);
bitmap.Save("GradientColor.png");
}
Output
GradientColor.png
For AI-assisted development: Download Graphics Mill Code Samples XML Catalog