GemBox.Presentation
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    Color Struct

    Namespace:
    GemBox.Presentation
    Assembly:
    GemBox.Presentation.dll

    Represents a color.

    • C#
    • VB.NET
    public struct Color : IEquatable<Color>
    Public Structure Color
        Implements IEquatable(Of Color)
    Implements
    System.IEquatable<Color>

    Properties

    A

    Gets the color opacity (0 = fully transparent, 255 = fully opaque).

    • C#
    • VB.NET
    public readonly byte A { get; }
    Public ReadOnly Property A As Byte
    Property Value
    System.Byte

    The color opacity.

    Argb

    Gets the Opacity, Red, Green and Blue components in a single System.Int32 value.

    • C#
    • VB.NET
    public readonly int Argb { get; }
    Public ReadOnly Property Argb As Integer
    Property Value
    System.Int32

    The Opacity, Red, Green and Blue components in a single System.Int32 value.

    B

    Gets the Blue component (from 0 to 255).

    • C#
    • VB.NET
    public readonly byte B { get; }
    Public ReadOnly Property B As Byte
    Property Value
    System.Byte

    The Blue component.

    G

    Gets the Green component (from 0 to 255).

    • C#
    • VB.NET
    public readonly byte G { get; }
    Public ReadOnly Property G As Byte
    Property Value
    System.Byte

    The Green component.

    Name

    Gets the color name.

    • C#
    • VB.NET
    public readonly ColorName Name { get; }
    Public ReadOnly Property Name As ColorName
    Property Value
    ColorName

    The color name.

    R

    Gets the Red component (from 0 to 255).

    • C#
    • VB.NET
    public readonly byte R { get; }
    Public ReadOnly Property R As Byte
    Property Value
    System.Byte

    The Red component.

    Methods

    Equals(Color)

    Determines whether the other Color is equal to this Color instance.

    • C#
    • VB.NET
    public bool Equals(Color other)
    Public Function Equals(other As Color) As Boolean
    Parameters
    other
    Color

    The other color to compare with this color instance.

    Returns
    System.Boolean

    true if the other Color is equal to this Color instance; otherwise, false.

    Equals(Object)

    Determines whether the specified System.Object is equal to this Color instance.

    • C#
    • VB.NET
    public override bool Equals(object obj)
    Public Overrides Function Equals(obj As Object) As Boolean
    Parameters
    obj
    System.Object

    The System.Object to compare with this color instance.

    Returns
    System.Boolean

    true if the specified System.Object is a Color and is equal to this Color instance; otherwise, false.

    Overrides
    System.ValueType.Equals(System.Object)

    FromHexString(String)

    Initializes a new instance of the Color struct.

    • C#
    • VB.NET
    public static Color FromHexString(string hex)
    Public Shared Function FromHexString(hex As String) As Color
    Parameters
    hex
    System.String

    The string that represents the color in the format #AARRGGBB or #RRGGBB where AA is the byte that represents the alpha component. RR is the byte that represents the red component, GG is the byte that represents the green component and BB is the byte that represents the blue component.

    Returns
    Color

    FromHsl(Int32, Int32, Int32)

    Creates a new color instance from the specified Hue, Saturation and Lightness components.

    • C#
    • VB.NET
    public static Color FromHsl(int h, int s, int l)
    Public Shared Function FromHsl(h As Integer, s As Integer, l As Integer) As Color
    Parameters
    h
    System.Int32

    The Hue component (from 0 to 255).

    s
    System.Int32

    The Saturation component (from 0 to 255).

    l
    System.Int32

    The Lightness component (from 0 to 255).

    Returns
    Color

    A new color instance from the specified Hue, Saturation and Lightness components.

    FromHsl(Int32, Int32, Int32, Double)

    Creates a new color instance from the specified Hue, Saturation and Lightness components and transparency.

    • C#
    • VB.NET
    public static Color FromHsl(int h, int s, int l, double transparency)
    Public Shared Function FromHsl(h As Integer, s As Integer, l As Integer, transparency As Double) As Color
    Parameters
    h
    System.Int32

    The Hue component (from 0 to 255).

    s
    System.Int32

    The Saturation component (from 0 to 255).

    l
    System.Int32

    The Lightness component (from 0 to 255).

    transparency
    System.Double

    The transparency (0 = fully opaque, 1 = fully transparent).

    Returns
    Color

    A new color instance from the specified Hue, Saturation and Lightness components and transparency.

    FromName(ColorName)

    Creates a new color instance from the specified color name.

    • C#
    • VB.NET
    public static Color FromName(ColorName name)
    Public Shared Function FromName(name As ColorName) As Color
    Parameters
    name
    ColorName

    The color name.

    Returns
    Color

    A color instance with the specified name.

    FromName(ColorName, Double)

    Creates a new color instance from the specified color name and luminance.

    • C#
    • VB.NET
    public static Color FromName(ColorName name, double luminance)
    Public Shared Function FromName(name As ColorName, luminance As Double) As Color
    Parameters
    name
    ColorName

    The color name.

    luminance
    System.Double

    The luminance (-1 = darkest, 0 = none, 1 = lightest).

    Returns
    Color

    A color instance with the specified name and luminance.

    FromName(ColorName, Double, Double)

    Creates a new color instance from the specified color name, luminance and transparency.

    • C#
    • VB.NET
    public static Color FromName(ColorName name, double luminance, double transparency)
    Public Shared Function FromName(name As ColorName, luminance As Double, transparency As Double) As Color
    Parameters
    name
    ColorName

    The color name.

    luminance
    System.Double

    The luminance (-1 = darkest, 0 = none, 1 = lightest).

    transparency
    System.Double

    The transparency (0 = fully opaque, 1 = fully transparent).

    Returns
    Color

    A color instance with the specified name, luminance and transparency.

    FromRgb(Int32, Int32, Int32)

    Creates a new color instance from the specified Red, Green and Blue components.

    • C#
    • VB.NET
    public static Color FromRgb(int r, int g, int b)
    Public Shared Function FromRgb(r As Integer, g As Integer, b As Integer) As Color
    Parameters
    r
    System.Int32

    The Red component (from 0 to 255).

    g
    System.Int32

    The Green component (from 0 to 255).

    b
    System.Int32

    The Blue component (from 0 to 255).

    Returns
    Color

    A new color instance from the specified Red, Green and Blue components.

    FromRgb(Int32, Int32, Int32, Double)

    Creates a new color instance from the specified Red, Green and Blue components and transparency.

    • C#
    • VB.NET
    public static Color FromRgb(int r, int g, int b, double transparency)
    Public Shared Function FromRgb(r As Integer, g As Integer, b As Integer, transparency As Double) As Color
    Parameters
    r
    System.Int32

    The Red component (from 0 to 255).

    g
    System.Int32

    The Green component (from 0 to 255).

    b
    System.Int32

    The Blue component (from 0 to 255).

    transparency
    System.Double

    The transparency (0 = fully opaque, 1 = fully transparent).

    Returns
    Color

    A new color instance from the specified Red, Green and Blue components and transparency.

    GetHashCode()

    Returns a hash code for this Color instance.

    • C#
    • VB.NET
    public override int GetHashCode()
    Public Overrides Function GetHashCode As Integer
    Returns
    System.Int32

    An integer value that specifies a hash value for this Color instance.

    Overrides
    System.ValueType.GetHashCode()

    ToString()

    Returns a System.String that represents this Color instance.

    • C#
    • VB.NET
    public override string ToString()
    Public Overrides Function ToString As String
    Returns
    System.String

    A System.String that represents this Color instance.

    Overrides
    System.ValueType.ToString()

    Operators

    Equality(Color, Color)

    Determines whether first and second Colors are equal.

    • C#
    • VB.NET
    public static bool operator ==(Color first, Color second)
    Public Shared Operator =(first As Color, second As Color) As Boolean
    Parameters
    first
    Color

    The first color.

    second
    Color

    The second color.

    Returns
    System.Boolean

    true if first and second colors are equal; otherwise, false.

    Inequality(Color, Color)

    Determines whether first and second Colors are not equal.

    • C#
    • VB.NET
    public static bool operator !=(Color first, Color second)
    Public Shared Operator <>(first As Color, second As Color) As Boolean
    Parameters
    first
    Color

    The first color.

    second
    Color

    The second color.

    Returns
    System.Boolean

    true if first and second colors are not equal; otherwise, false.

    Implements

    System.IEquatable<T>
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.