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.

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 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 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 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 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 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 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 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 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 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 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 Parse (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

TypeReason

If colorString is null.

If the string is not a valid color or its components are not valid floats.

Remarks

Example

C# Example

Color myColor = Color.Parse("(0.5,1.0,0.8)");

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 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 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 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 TryParse (string colorString, out 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

C# Example

Color myColor;
        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 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 Yellow

Remarks

Requirements

Namespace: Sansar Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0

Last updated