Color Struct
The Color class holds RGBA values that define a color.
Syntax
public struct Color
Remarks
Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Members
See Also: Inherited members from ValueType.
Public Constructors
Public Fields
static readonly
|
Black | Color . Black |
static readonly
|
Blue | Color . Blue |
static readonly
|
Clear | Color . Clear |
static readonly
|
Cyan | Color . Cyan |
static readonly
|
Gray | Color . Gray |
static readonly
|
Green | Color . Green |
static readonly
|
Magenta | Color . Magenta |
static readonly
|
Red | Color . Red |
static readonly
|
White | Color . White |
static readonly
|
Yellow | Color . Yellow |
Public Properties
Public Methods
|
Lerp (ref Color, float) : Color
Performs a linear interpolation between two colors. |
|
static
|
Parse (string) : Color
Parse a Color from a string. |
|
|
ToRGB () : string
Generates a string RGB representation of the color. |
|
|
ToRGBA () : string
Generates a string RGBA representation of the color. |
|
override
|
ToString () : string
Generates a string representation of the color. |
|
|
ToString (string) : string
Generates a string representation of the color. |
|
static
|
TryParse (string, out Color) : bool
Attempt to parse a Color from a string |
Public Operators
static
|
Addition (Color, Color) | Performs color addition. |
static
|
Division (Color, float) | Divides color components by a scalar. |
static
|
Multiply (Color, float) | Performs a color scalar multiplication. |
static
|
Multiply (float, Color) | Performs a color scalar multiplication. |
static
|
Subtraction (Color, Color) | Performs color subtraction. |
static
|
Conversion to Sansar.Color (Implicit) | Converts a Mono.Simd.Vector4f to a Color. |
static
|
Conversion to Mono.Simd.Vector4f (Implicit) | Converts a Color to a Mono.Simd.Vector4f |
Member Details
Color Constructor
Creates a new color with the supplied values.Syntax
public Color (Mono.Simd.Vector4f v)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
The alpha component is set to 1.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
Alpha is 1 by default.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
BlackSyntax
public static readonly Color BlackRemarks
Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Blue Field
BlueSyntax
public static readonly Color BlueRemarks
Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Clear Field
ClearSyntax
public static readonly Color ClearRemarks
Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Cyan Field
CyanSyntax
public static readonly Color CyanRemarks
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
GraySyntax
public static readonly Color GrayRemarks
Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Green Field
GreenSyntax
public static readonly Color GreenRemarks
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
a + (c-a) * amount.Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Magenta Field
MagentaSyntax
public static readonly Color MagentaRemarks
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
public static implicit operator Color (Mono.Simd.Vector4f v)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.Vector4fSyntax
public static implicit operator Mono.Simd.Vector4f (Color c)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
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 If colorString is null. FormatException 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
RedSyntax
public static readonly Color RedRemarks
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
public string ToRGB ()Returns
The RGB color as a string.Remarks
RGB values are based on a scale from 0 to 255.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
public string ToRGBA ()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 stringSyntax
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
WhiteSyntax
public static readonly Color WhiteRemarks
Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
Yellow Field
YellowSyntax
public static readonly Color YellowRemarks
Requirements
Namespace: Sansar
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0
0 Comments