Text Effects
View as MarkdownDemonstrates how to use shadow and glow effects for drawing text.
Code Snippet
using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var gr = bitmap.GetGraphics())
{
// Draw text with shadow effect
var textWithShadow = new PlainText("Text with shadow.", gr.CreateFont("Arial", 50))
{
Position = new System.Drawing.PointF(50, 50),
Brush = new SolidBrush(RgbColor.Red),
};
textWithShadow.Effect = new Shadow()
{
Color = RgbColor.Black,
OffsetX = 3,
OffsetY = 3,
Opacity = 0.5f,
Size = 2.0f,
};
gr.DrawText(textWithShadow);
// Draw text with glow effect
var textWithGlow = new PlainText("Text with glow.", gr.CreateFont("Arial", 50))
{
Position = new System.Drawing.PointF(50, 250),
Brush = new SolidBrush(RgbColor.Black),
};
textWithGlow.Effect = new Glow()
{
Color = RgbColor.Red,
Opacity = 0.75f,
Size = 2.0f,
};
gr.DrawText(textWithGlow);
bitmap.Save("TextEffects.png");
}
Output
TextEffects.png
Used APIs
- Aurigma.GraphicsMill.Bitmap.GetGraphics
- Aurigma.GraphicsMill.Drawing.Effects.Glow
- Aurigma.GraphicsMill.Drawing.Effects.Glow.Color
- Aurigma.GraphicsMill.Drawing.Effects.Glow.Opacity
- Aurigma.GraphicsMill.Drawing.Effects.Glow.Size
- Aurigma.GraphicsMill.Drawing.Effects.Shadow
- Aurigma.GraphicsMill.Drawing.Effects.Shadow.Color
- Aurigma.GraphicsMill.Drawing.Effects.Shadow.OffsetX
- Aurigma.GraphicsMill.Drawing.Effects.Shadow.OffsetY
- Aurigma.GraphicsMill.Drawing.Effects.Shadow.Opacity
- Aurigma.GraphicsMill.Drawing.Effects.Shadow.Size
- Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)
- Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)
- Aurigma.GraphicsMill.Drawing.PlainText
- Aurigma.GraphicsMill.Drawing.PlainText.Position
- Aurigma.GraphicsMill.Drawing.SolidBrush
- Aurigma.GraphicsMill.Drawing.Text.Brush
- Aurigma.GraphicsMill.Drawing.Text.Effect