30 using System.Globalization;
 
   31 using System.Runtime.InteropServices;
 
   33 namespace SiliconStudio.Core.Mathematics
 
   38     [DataContract(
"Color3")]
 
   40     [StructLayout(LayoutKind.Sequential, Pack = 4)]
 
   76         public Color3(
float red, 
float green, 
float blue)
 
  101             R = ((rgb >> 16) & 255) / 255.0f;
 
  102             G = ((rgb >> 8) & 255) / 255.0f;
 
  103             B = (rgb & 255) / 255.0f;
 
  115                 throw new ArgumentNullException(
"values");
 
  116             if (values.Length != 3)
 
  117                 throw new ArgumentOutOfRangeException(
"values", 
"There must be three and only three input values for Color3.");
 
  131         public float this[
int index]
 
  142                 throw new ArgumentOutOfRangeException(
"index", 
"Indices for Color3 run from 0 to 2, inclusive.");
 
  149                     case 0: R = value; 
break;
 
  150                     case 1: G = value; 
break;
 
  151                     case 2: B = value; 
break;
 
  152                     default: 
throw new ArgumentOutOfRangeException(
"index", 
"Indices for Color3 run from 0 to 2, inclusive.");
 
  165             uint r = (uint)(R * 255.0f);
 
  166             uint g = (uint)(G * 255.0f);
 
  167             uint 
b = (uint)(B * 255.0f);
 
  181         public void Pow(
float exponent)
 
  183             R = (float)Math.Pow(R, exponent);
 
  184             G = (float)Math.Pow(G, exponent);
 
  185             B = (float)Math.Pow(B, exponent);
 
  203             return new float[] { R, G, B };
 
  214             result.R = left.R + right.R;
 
  215             result.G = left.G + right.G;
 
  216             result.B = left.B + right.B;
 
  227             return new Color3(left.
R + right.
R, left.
G + right.
G, left.
B + right.
B);
 
  238             result.R = left.R - right.R;
 
  239             result.G = left.G - right.G;
 
  240             result.B = left.B - right.B;
 
  251             return new Color3(left.
R - right.
R, left.
G - right.
G, left.
B - right.
B);
 
  262             result.R = left.R * right.R;
 
  263             result.G = left.G * right.G;
 
  264             result.B = left.B * right.B;
 
  275             return new Color3(left.
R * right.
R, left.
G * right.
G, left.
B * right.
B);
 
  286             result.R = value.R * scale;
 
  287             result.G = value.G * scale;
 
  288             result.B = value.B * scale;
 
  299             return new Color3(value.
R * scale, value.
G * scale, value.
B * scale);
 
  309             result.R = 1.0f - value.R;
 
  310             result.G = 1.0f - value.G;
 
  311             result.B = 1.0f - value.B;
 
  321             return new Color3(1.0f - value.
R, 1.0f - value.
G, 1.0f - value.
B);
 
  334             red = (red > max.R) ? max.R : red;
 
  335             red = (red < min.R) ? min.R : red;
 
  337             float green = value.G;
 
  338             green = (green > max.G) ? max.G : green;
 
  339             green = (green < min.G) ? min.G : green;
 
  341             float blue = value.B;
 
  342             blue = (blue > max.B) ? max.B : blue;
 
  343             blue = (blue < min.B) ? min.B : blue;
 
  345             result = 
new Color3(red, green, blue);
 
  358             Clamp(ref value, ref min, ref max, out result);
 
  376             result.R = start.R + amount * (end.R - start.R);
 
  377             result.G = start.G + amount * (end.G - start.G);
 
  378             result.B = start.B + amount * (end.B - start.B);
 
  396                 start.
R + amount * (end.
R - start.
R),
 
  397                 start.
G + amount * (end.
G - start.
G),
 
  398                 start.
B + amount * (end.
B - start.
B));
 
  410             amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f : amount);
 
  411             amount = (amount * amount) * (3.0f - (2.0f * amount));
 
  413             result.R = start.R + ((end.R - start.R) * amount);
 
  414             result.G = start.G + ((end.G - start.G) * amount);
 
  415             result.B = start.B + ((end.B - start.B) * amount);
 
  427             amount = (amount > 1.0f) ? 1.0f : ((amount < 0.0f) ? 0.0f : amount);
 
  428             amount = (amount * amount) * (3.0f - (2.0f * amount));
 
  431                 start.
R + ((end.
R - start.
R) * amount),
 
  432                 start.
G + ((end.
G - start.
G) * amount),
 
  433                 start.
B + ((end.
B - start.
B) * amount));
 
  444             result.R = (left.R > right.R) ? left.R : right.R;
 
  445             result.G = (left.G > right.G) ? left.G : right.G;
 
  446             result.B = (left.B > right.B) ? left.B : right.B;
 
  458             Max(ref left, ref right, out result);
 
  470             result.R = (left.R < right.R) ? left.R : right.R;
 
  471             result.G = (left.G < right.G) ? left.G : right.G;
 
  472             result.B = (left.B < right.B) ? left.B : right.B;
 
  484             Min(ref left, ref right, out result);
 
  496             result.R = 0.5f + contrast * (value.R - 0.5f);
 
  497             result.G = 0.5f + contrast * (value.G - 0.5f);
 
  498             result.B = 0.5f + contrast * (value.B - 0.5f);
 
  510                 0.5f + contrast * (value.
R - 0.5f),
 
  511                 0.5f + contrast * (value.
G - 0.5f),
 
  512                 0.5f + contrast * (value.
B - 0.5f));
 
  523             float grey = value.R * 0.2125f + value.G * 0.7154f + value.B * 0.0721f;
 
  525             result.R = grey + saturation * (value.R - grey);
 
  526             result.G = grey + saturation * (value.G - grey);
 
  527             result.B = grey + saturation * (value.B - grey);
 
  538             float grey = value.R * 0.2125f + value.G * 0.7154f + value.B * 0.0721f;
 
  541                 grey + saturation * (value.
R - grey),
 
  542                 grey + saturation * (value.
G - grey),
 
  543                 grey + saturation * (value.
B - grey));
 
  554             return new Color3(left.
R + right.
R, left.
G + right.
G, left.
B + right.
B);
 
  575             return new Color3(left.
R - right.
R, left.
G - right.
G, left.
B - right.
B);
 
  585             return new Color3(-value.
R, -value.
G, -value.
B);
 
  596             return new Color3(value.
R * scale, value.
G * scale, value.
B * scale);
 
  607             return new Color3(value.
R * scale, value.
G * scale, value.
B * scale);
 
  618             return new Color3(left.
R * right.
R, left.
G * right.
G, left.
B * right.
B);
 
  629             return left.Equals(right);
 
  640             return !left.Equals(right);
 
  650             return new Color4(1.0f, value.
R, value.
G, value.
B);
 
  660             return new Vector3(value.
R, value.
G, value.
B);
 
  670             return new Color3(value.
X, value.
Y, value.
Z);
 
  678         public static explicit operator Color3(
int value)
 
  691             return string.Format(CultureInfo.CurrentCulture, 
"Red:{0} Green:{1} Blue:{2}", R, G, B);
 
  706             return string.Format(CultureInfo.CurrentCulture, 
"Red:{0} Green:{1} Blue:{2}", R.ToString(
format, CultureInfo.CurrentCulture),
 
  707                 G.ToString(format, CultureInfo.CurrentCulture), B.ToString(
format, CultureInfo.CurrentCulture));
 
  717         public string ToString(IFormatProvider formatProvider)
 
  719             return string.Format(formatProvider, 
"Red:{0} Green:{1} Blue:{2}", R, G, B);
 
  733                 return ToString(formatProvider);
 
  735             return string.Format(formatProvider, 
"Red:{1} Green:{2} Blue:{3}",R.ToString(
format, formatProvider),
 
  736                 G.ToString(format, formatProvider), B.ToString(
format, formatProvider));
 
  747             return R.GetHashCode() + G.GetHashCode() + B.GetHashCode();
 
  759             return R == other.R && G == other.G && B == other.B;
 
  769         public override bool Equals(
object value)
 
  774             if (value.GetType() != GetType())
 
  777             return Equals((
Color3)value);
 
  786         public static implicit 
operator SlimDX.Color3(
Color3 value)
 
  788             return new SlimDX.Color3(value.Red, value.Green, value.Blue);
 
  796         public static implicit 
operator Color3(SlimDX.Color3 value)
 
  798             return new Color3(value.Red, value.Green, value.Blue);
 
  808         public static explicit operator System.Windows.Media.Color(Color3 value)
 
  810             return new System.Windows.Media.Color()
 
  813                 R = (byte)(255f * value.Red),
 
  814                 G = (byte)(255f * value.Green),
 
  815                 B = (byte)(255f * value.Blue)
 
  824         public static explicit operator Color3(
System.Windows.Media.Color value)
 
  828                 Red = (float)value.R / 255f,
 
  829                 Green = (
float)value.G / 255f,
 
  830                 Blue = (float)value.B / 255f
 
  841         public static implicit 
operator System.Drawing.Color(Color3 value)
 
  843             return System.Drawing.Color.FromArgb(
 
  844                 (byte)(255f * value.Red),
 
  845                 (byte)(255f * value.Green),
 
  846                 (byte)(255f * value.Blue));
 
  854         public static implicit 
operator Color3(
System.Drawing.Color value)
 
  858                 Red = (float)value.R / 255f,
 
  859                 Green = (
float)value.G / 255f,
 
  860                 Blue = (float)value.B / 255f
 
static void Max(ref Color3 left, ref Color3 right, out Color3 result)
Returns a color containing the smallest components of the specified colorss. 
 
float[] ToArray()
Creates an array containing the elements of the color. 
 
FbxDouble3 operator*(double factor, FbxDouble3 vector)
 
float Y
The Y component of the vector. 
 
static Color3 Modulate(Color3 left, Color3 right)
Modulates two colors. 
 
static void Subtract(ref Color3 left, ref Color3 right, out Color3 result)
Subtracts two colors. 
 
string ToString(string format)
Returns a System.String that represents this instance. 
 
Color3(float red, float green, float blue)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Color3 struct. 
 
static Color3 Clamp(Color3 value, Color3 min, Color3 max)
Restricts a value to be within a specified range. 
 
static Color3 Scale(Color3 value, float scale)
Scales a color. 
 
static Color3 SmoothStep(Color3 start, Color3 end, float amount)
Performs a cubic interpolation between two colors. 
 
static void Modulate(ref Color3 left, ref Color3 right, out Color3 result)
Modulates two colors. 
 
Represents a color in the form of rgb. 
 
float B
The blue component of the color. 
 
Color3(float[] values)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Color3 struct. 
 
bool Equals(Color3 other)
Determines whether the specified SiliconStudio.Core.Mathematics.Color3 is equal to this instance...
 
static Color3 Lerp(Color3 start, Color3 end, float amount)
Performs a linear interpolation between two colors. 
 
Color3(int rgb)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Color3 struct. 
 
Vector3 ToVector3()
Converts the color into a three component vector. 
 
float R
The red component of the color. 
 
static Color3 Subtract(Color3 left, Color3 right)
Subtracts two colors. 
 
float X
The X component of the vector. 
 
Represents a three dimensional mathematical vector. 
 
Allow data to be stored in the blue component. 
 
static void AdjustContrast(ref Color3 value, float contrast, out Color3 result)
Adjusts the contrast of a color. 
 
static Color3 AdjustContrast(Color3 value, float contrast)
Adjusts the contrast of a color. 
 
static void SmoothStep(ref Color3 start, ref Color3 end, float amount, out Color3 result)
Performs a cubic interpolation between two colors. 
 
static Color3 Negate(Color3 value)
Negates a color. 
 
static Color3 Add(Color3 left, Color3 right)
Adds two colors. 
 
Represents a color in the form of rgba. 
 
static void AdjustSaturation(ref Color3 value, float saturation, out Color3 result)
Adjusts the saturation of a color. 
 
static void Clamp(ref Color3 value, ref Color3 min, ref Color3 max, out Color3 result)
Restricts a value to be within a specified range. 
 
override string ToString()
Returns a System.String that represents this instance. 
 
override bool Equals(object value)
Determines whether the specified System.Object is equal to this instance. 
 
string ToString(string format, IFormatProvider formatProvider)
Returns a System.String that represents this instance. 
 
Allow data to be stored in the red component. 
 
static void Min(ref Color3 left, ref Color3 right, out Color3 result)
Returns a color containing the smallest components of the specified colors. 
 
static void Scale(ref Color3 value, float scale, out Color3 result)
Scales a color. 
 
static Color3 AdjustSaturation(Color3 value, float saturation)
Adjusts the saturation of a color. 
 
float G
The green component of the color. 
 
static void Add(ref Color3 left, ref Color3 right, out Color3 result)
Adds two colors. 
 
SiliconStudio.Core.Mathematics.Vector3 Vector3
 
string ToString(IFormatProvider formatProvider)
Returns a System.String that represents this instance. 
 
static void Lerp(ref Color3 start, ref Color3 end, float amount, out Color3 result)
Performs a linear interpolation between two colors. 
 
override int GetHashCode()
Returns a hash code for this instance. 
 
_In_ size_t _In_ size_t _In_ DXGI_FORMAT format
 
Color3(Vector3 value)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Color3 struct. 
 
static Color3 Max(Color3 left, Color3 right)
Returns a color containing the largest components of the specified colorss. 
 
static void Negate(ref Color3 value, out Color3 result)
Negates a color. 
 
float Z
The Z component of the vector. 
 
int ToRgb()
Converts the color into a packed integer. 
 
Color3(float value)
Initializes a new instance of the SiliconStudio.Core.Mathematics.Color3 struct. 
 
static Color3 Min(Color3 left, Color3 right)
Returns a color containing the smallest components of the specified colors. 
 
DataStyle
Specifies the style used for textual serialization when an array/list or a dictionary/map must be ser...
 
void Pow(float exponent)
Raises the exponent for each components.