Class AciColor
Represents an ACI color (AutoCAD Color Index) that also supports true color.
Inheritance
Inherited Members
Namespace: netDxf
Assembly: CADability.dll
Syntax
public class AciColor : ICloneable, IEquatable<AciColor>
Constructors
| Improve this Doc View SourceAciColor()
Initializes a new instance of the AciColor class with black/white color index 7.
Declaration
public AciColor()
AciColor(Byte, Byte, Byte)
Initializes a new instance of the AciColor class.
Declaration
public AciColor(byte r, byte g, byte b)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte | r | Red component. |
| System.Byte | g | Green component. |
| System.Byte | b | Blue component. |
Remarks
By default the UseTrueColor will be set to true.
AciColor(Double, Double, Double)
Initializes a new instance of the AciColor class.
Declaration
public AciColor(double r, double g, double b)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | r | Red component. |
| System.Double | g | Green component. |
| System.Double | b | Blue component. |
Remarks
By default the UseTrueColor will be set to true.
AciColor(Color)
Initializes a new instance of the AciColor class.
Declaration
public AciColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Color | color | A System.Drawing.Color. |
Remarks
By default the UseTrueColor will be set to true.
AciColor(Int16)
Initializes a new instance of the AciColor class.
Declaration
public AciColor(short index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int16 | index | Color index. |
Remarks
By default the UseTrueColor will be set to false.
Accepted color index values range from 1 to 255.
Indexes from 1 to 255 represents a color, the index 0 and 256 are reserved for ByLayer and ByBlock colors.
AciColor(Single, Single, Single)
Initializes a new instance of the AciColor class.
Declaration
public AciColor(float r, float g, float b)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | r | Red component. |
| System.Single | g | Green component. |
| System.Single | b | Blue component. |
Remarks
By default the UseTrueColor will be set to true.
Properties
| Improve this Doc View SourceB
Gets the blue component of the AciColor.
Declaration
public byte B { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
Blue
Defines a default blue color.
Declaration
public static AciColor Blue { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
ByBlock
Gets the ByBlock color.
Declaration
public static AciColor ByBlock { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
ByLayer
Gets the ByLayer color.
Declaration
public static AciColor ByLayer { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
Cyan
Defines a default cyan color.
Declaration
public static AciColor Cyan { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
DarkGray
Defines a default dark gray color.
Declaration
public static AciColor DarkGray { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
Default
Defines a default white/black color.
Declaration
public static AciColor Default { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
G
Gets the green component of the AciColor.
Declaration
public byte G { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
Green
Defines a default green color.
Declaration
public static AciColor Green { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
Index
Gets or sets the color index.
Declaration
public short Index { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int16 |
Remarks
Accepted color index values range from 1 to 255. Indexes from 1 to 255 represents a color, the index 0 and 256 are reserved for ByLayer and ByBlock colors.
IndexRgb
A dictionary that contains the indexed colors, the key represents the color index and the value the RGB components of the color.
Declaration
public static IReadOnlyDictionary<byte, byte[]> IndexRgb { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyDictionary<System.Byte, System.Byte[]> |
IsByBlock
Defines if the color is defined by block.
Declaration
public bool IsByBlock { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsByLayer
Defines if the color is defined by layer.
Declaration
public bool IsByLayer { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
LightGray
Defines a default light gray color.
Declaration
public static AciColor LightGray { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
Magenta
Defines a default magenta color.
Declaration
public static AciColor Magenta { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
R
Gets the red component of the AciColor.
Declaration
public byte R { get; }
Property Value
| Type | Description |
|---|---|
| System.Byte |
Red
Defines a default red color.
Declaration
public static AciColor Red { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
UseTrueColor
Get or set if the AciColor should use true color values.
Declaration
public bool UseTrueColor { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
By default, the constructors that use RGB values will set this boolean to true while the constants and the constructor that use a color index will set it to false.
Yellow
Defines a default yellow color.
Declaration
public static AciColor Yellow { get; }
Property Value
| Type | Description |
|---|---|
| AciColor |
Methods
| Improve this Doc View SourceClone()
Creates a new color that is a copy of the current instance.
Declaration
public object Clone()
Returns
| Type | Description |
|---|---|
| System.Object | A new color that is a copy of this instance. |
Equals(AciColor)
Check if the components of two colors are equal.
Declaration
public bool Equals(AciColor other)
Parameters
| Type | Name | Description |
|---|---|---|
| AciColor | other | Another color to compare to. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the three components are equal or false in any other case. |
FromCadIndex(Int16)
Gets the AciColor from an index.
Declaration
public static AciColor FromCadIndex(short index)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int16 | index | A CAD indexed AciColor index. |
Returns
| Type | Description |
|---|---|
| AciColor | A AciColor. |
Remarks
Accepted index values range from 0 to 256. An index 0 represents a ByBlock color and an index 256 is a ByLayer color; any other value will return one of the 255 indexed AciColors.
FromColor(Color)
Converts a System.Drawing.Color to an System.Drawing.Color.
Declaration
public void FromColor(Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Color | color | A System.Drawing.Color. |
FromHsl(Vector3)
Converts HSL (hue, saturation, lightness) value to an AciColor.
Declaration
public static AciColor FromHsl(Vector3 hsl)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | hsl | A Vector3 containing the hue, saturation, and lightness components. |
Returns
| Type | Description |
|---|---|
| AciColor | An System.Drawing.Color that represents the actual HSL value. |
FromHsl(Double, Double, Double)
Converts HSL (hue, saturation, lightness) value to an AciColor.
Declaration
public static AciColor FromHsl(double hue, double saturation, double lightness)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | hue | Hue (input values range from 0 to 1). |
| System.Double | saturation | Saturation percentage (input values range from 0 to 1). |
| System.Double | lightness | Lightness percentage (input values range from 0 to 1). |
Returns
| Type | Description |
|---|---|
| AciColor | An System.Drawing.Color that represents the actual HSL value. |
FromTrueColor(Int32)
Gets the AciColor from a 24-bit color value.
Declaration
public static AciColor FromTrueColor(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | value | A 24-bit color value (BGR order). |
Returns
| Type | Description |
|---|---|
| AciColor | A AciColor. |
ToColor()
Converts the AciColor to a System.Drawing.Color.
Declaration
public Color ToColor()
Returns
| Type | Description |
|---|---|
| System.Drawing.Color | A System.Drawing.Color that represents the actual AciColor. |
Remarks
A default color white will be used for ByLayer and ByBlock colors.
ToHsl(AciColor)
Converts the RGB (red, green, blue) components of an AciColor to HSL (hue, saturation, lightness) values.
Declaration
public static Vector3 ToHsl(AciColor color)
Parameters
| Type | Name | Description |
|---|---|---|
| AciColor | color | A AciColor. |
Returns
| Type | Description |
|---|---|
| Vector3 | A Vector3 where the three coordinates x, y, z represents the hue, saturation, and lightness components (output values range from 0 to 1). |
ToHsl(AciColor, out Double, out Double, out Double)
Converts the RGB (red, green, blue) components of an AciColor to HSL (hue, saturation, lightness) values.
Declaration
public static void ToHsl(AciColor color, out double hue, out double saturation, out double lightness)
Parameters
| Type | Name | Description |
|---|---|---|
| AciColor | color | A AciColor. |
| System.Double | hue | Hue (output values range from 0 to 1). |
| System.Double | saturation | Saturation (output values range from 0 to 1). |
| System.Double | lightness | Lightness (output values range from 0 to 1). |
ToString()
Converts the value of this instance to its equivalent string representation.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | The string representation. |
Overrides
ToTrueColor(AciColor)
Gets the 24-bit color value from an AciColor.
Declaration
public static int ToTrueColor(AciColor color)
Parameters
| Type | Name | Description |
|---|---|---|
| AciColor | color | A AciColor. |
Returns
| Type | Description |
|---|---|
| System.Int32 | A 24-bit color value (BGR order). |