// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) James South. // Licensed under the Apache License, Version 2.0. // // // Encapsulates the properties required to add a layer of text to an image. // // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Imaging { #region Using using System; using System.Drawing; #endregion /// /// Encapsulates the properties required to add a layer of text to an image. /// public class TextLayer { #region Fields /// /// The color to render the text. /// private Color textColor = Color.Black; /// /// The opacity at which to render the text. /// private int opacity = 100; /// /// The font style to render the text. /// private FontStyle fontStyle = FontStyle.Regular; /// /// The font size to render the text. /// private int fontSize = 48; /// /// The position to start creating the text from. /// private Point position = Point.Empty; #endregion #region Properties /// /// Gets or sets Text. /// public string Text { get; set; } /// /// Gets or sets the Color to render the font. /// /// Defaults to black. /// /// public Color TextColor { get { return this.textColor; } set { this.textColor = value; } } /// /// Gets or sets the name of the font. /// public string Font { get; set; } /// /// Gets or sets the size of the font in pixels. /// /// Defaults to 48 pixels. /// /// public int FontSize { get { return this.fontSize; } set { this.fontSize = value; } } /// /// Gets or sets the FontStyle of the text layer. /// /// Defaults to regular. /// /// public FontStyle Style { get { return this.fontStyle; } set { this.fontStyle = value; } } /// /// Gets or sets the Opacity of the text layer. /// public int Opacity { get { int alpha = (int)Math.Ceiling((this.opacity / 100d) * 255); return alpha < 255 ? alpha : 255; } set { this.opacity = value; } } /// /// Gets or sets the Position of the text layer. /// public Point Position { get { return this.position; } set { this.position = value; } } /// /// Gets or sets a value indicating whether a DropShadow should be drawn. /// public bool DropShadow { get; set; } #endregion } }