# Color

### Color Struct

The Color class holds RGBA values that define a color.

### Syntax

public struct **Color**

### Member Details

#### Color Constructor

> Creates a new color with the supplied values.
>
> #### Syntax
>
> **Parameters**
>
> > *v*
> >
> > Initializes the color from a [Mono.Simd.Vector4f](http://docs.go-mono.com/?link=T%3aMono.Simd.Vector4f).
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Color Constructor

> Creates a new solid color with the supplied values.
>
> #### Syntax
>
> **Parameters**
>
> > *r*
> >
> > The red component.
> >
> > *g*
> >
> > The green component.
> >
> > *b*
> >
> > The blue component.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Color Constructor

> Creates a new color with the supplied values.
>
> #### Syntax
>
> **Parameters**
>
> > *r*
> >
> > The red component.
> >
> > *g*
> >
> > The green component.
> >
> > *b*
> >
> > The blue component.
> >
> > *a*
> >
> > The alpha component.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### A Property

> The alpha component of the color.
>
> #### Syntax
>
> public [float](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Single) **A** { get; set; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### B Property

> The blue component of the color.
>
> #### Syntax
>
> public [float](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Single) **B** { get; set; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Black Field

> Black
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Black**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Blue Field

> Blue
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Blue**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Clear Field

> Clear
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Clear**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Cyan Field

> Cyan
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Cyan**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### G Property

> The green component of the color.
>
> #### Syntax
>
> public [float](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Single) **G** { get; set; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Gray Field

> Gray
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Gray**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Green Field

> Green
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Green**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Lerp Method

> Performs a linear interpolation between two colors.
>
> #### Syntax
>
> **Parameters**
>
> > *c*
> >
> > The second color.
> >
> > *amount*
> >
> > Value from \[0..1] indicating the weight for the second color.
>
> **Returns**
>
> > A color that is linearly interpolated between the two sources.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Magenta Field

> Magenta
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Magenta**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### op\_Addition Method

> Performs color addition.
>
> #### Syntax
>
> **Parameters**
>
> > *a*
> >
> > The first Color.
> >
> > *b*
> >
> > The second Color.
>
> **Returns**
>
> > A new color that is the sum of the arguments.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### op\_Division Method

> Divides color components by a scalar.
>
> #### Syntax
>
> **Parameters**
>
> > *c*
> >
> > The color.
> >
> > *s*
> >
> > The scalar.
>
> **Returns**
>
> > Returns a new color with value \[c.R/s, c.G/s, c.B/s, c.A/s]
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Conversion Method

> Converts a Mono.Simd.Vector4f to a Color.
>
> #### Syntax
>
> **Parameters**
>
> > *v*
> >
> > Vector to convert
>
> **Returns**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Conversion Method

> Converts a Color to a Mono.Simd.Vector4f
>
> #### Syntax
>
> **Parameters**
>
> > *c*
> >
> > Color to convert
>
> **Returns**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### op\_Multiply Method

> Performs a color scalar multiplication.
>
> #### Syntax
>
> **Parameters**
>
> > *c*
> >
> > The color.
> >
> > *s*
> >
> > The scalar.
>
> **Returns**
>
> > Returns a new color with value \[c.R\*s, c.G\*s, c.B\*s, c.A\*s]
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### op\_Multiply Method

> Performs a color scalar multiplication.
>
> #### Syntax
>
> **Parameters**
>
> > *s*
> >
> > The scalar.
> >
> > *c*
> >
> > The color.
>
> **Returns**
>
> > Returns a new color with value \[s\*c.R, s\*c.G, s\*c.B, s\*c.A]
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### op\_Subtraction Method

> Performs color subtraction.
>
> #### Syntax
>
> **Parameters**
>
> > *a*
> >
> > The first Color.
> >
> > *b*
> >
> > The second Color.
>
> **Returns**
>
> > A new color that is the difference of the arguments.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Parse Method

> Parse a Color from a string.
>
> #### Syntax
>
> public static [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Parse** ([string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) colorString)
>
> **Parameters**
>
> > *colorString*
> >
> > A string of the format (R,G,B) or (R,G,B,A)
>
> **Returns**
>
> > The Color parsed from the string.
>
> **Exceptions**

| Type                                                                                          | Reason                                                                     |
| --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [ArgumentException](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.ArgumentException) | If colorString is null.                                                    |
| [FormatException](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.FormatException)     | If the string is not a valid color or its components are not valid floats. |

> #### Remarks
>
> #### Example

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><strong>C# Example</strong></td></tr><tr><td><pre><code>Color myColor = Color.Parse("(0.5,1.0,0.8)");
</code></pre></td></tr><tr><td></td></tr></tbody></table>

> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### R Property

> The red component of the color.
>
> #### Syntax
>
> public [float](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Single) **R** { get; set; }
>
> **Value**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Red Field

> Red
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Red**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### ToRGB Method

> Generates a string RGB representation of the color.
>
> #### Syntax
>
> **Returns**
>
> > The RGB color as a string.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### ToRGBA Method

> Generates a string RGBA representation of the color.
>
> #### Syntax
>
> **Returns**
>
> > The RGBA color as a string.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### ToString Method

> Generates a string representation of the color.
>
> #### Syntax
>
> public override [string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) **ToString** ()
>
> **Returns**
>
> > The color as a string.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### ToString Method

> Generates a string representation of the color.
>
> #### Syntax
>
> **Parameters**
>
> > *format*
> >
> > Format to use for each of the coordinates.
>
> **Returns**
>
> > The color as a string.
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### TryParse Method

> Attempt to parse a Color from a string
>
> #### Syntax
>
> public static [bool](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean) **TryParse** ([string](http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String) colorString, *out* [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) color)
>
> **Parameters**
>
> > *colorString*
> >
> > A string of the format (R,G,B) or (R,G,B,A)
> >
> > *color*
> >
> > The color that will be set if colorString represents a valid color.
>
> **Returns**
>
> > True if successfully parsed a color, false if not.
>
> #### Remarks
>
> #### Example

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><strong>C# Example</strong></td></tr><tr><td><pre><code>Color myColor;
</code></pre></td></tr></tbody></table>

```
        if (Color.Parse("(0.5,1.0,0.8)", out myColor)
        {
            // myColor is set
        }
```

|

> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### White Field

> White
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **White**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
>
> ***

#### Yellow Field

> Yellow
>
> #### Syntax
>
> public static readonly [Color](https://docs.sansar.com/latest/script-api-docs/sansar-namespace/color) **Yellow**
>
> #### Remarks
>
> #### Requirements
>
> **Namespace:** Sansar\
> **Assembly:** Sansar.Script (in Sansar.Script.dll)\
> **Assembly Versions:** 1.0.0.0
