/// <summary> /// Initializes a new instance of the <see cref="Color"/> struct. Alpha is set to 255. Passed values are clamped within byte range. /// </summary> /// <param name="red">The red component of the color.</param> /// <param name="green">The green component of the color.</param> /// <param name="blue">The blue component of the color.</param> public Color(int red, int green, int blue) : this() { R = PackHelpers.ToByte(red); G = PackHelpers.ToByte(green); B = PackHelpers.ToByte(blue); A = 255; }
/// <summary> /// Initializes a new instance of the <see cref="Color"/> struct. Passed values are clamped within byte range. /// </summary> /// <param name="red">The red component of the color.</param> /// <param name="green">The green component of the color.</param> /// <param name="blue">The blue component of the color.</param> /// <param name="alpha">The alpha component of the color</param> public Color(int red, int green, int blue, int alpha) : this() { R = PackHelpers.ToByte(red); G = PackHelpers.ToByte(green); B = PackHelpers.ToByte(blue); A = PackHelpers.ToByte(alpha); }
/// <summary> /// Initializes a new instance of the <see cref="Color"/> struct. /// </summary> /// <param name="value">The value that will be assigned to all components.</param> public Color(float value) : this() { _packedValue = PackHelpers.PackRGBA(value, value, value, value); }
/// <summary> /// Convert this instance to a <see cref="Color4"/> /// </summary> public Color4 ToColor4() { PackHelpers.UnpackRGBA(_packedValue, out var x, out var y, out var z, out var w); return(new Color4(x, y, z, w)); }
/// <summary> /// Initializes a new instance of the <see cref="Color"/> struct. /// </summary> /// <param name="vector">A four-component color.</param> public Color(Vector4 vector) : this() { _packedValue = PackHelpers.PackRGBA(vector.X, vector.Y, vector.Z, vector.W); }
/// <summary> /// Initializes a new instance of the <see cref="Color"/> struct. /// </summary> /// <param name="vector">The red, green, and blue components of the color.</param> /// <param name="alpha">The alpha component of the color.</param> public Color(Vector3 vector, float alpha) : this() { _packedValue = PackHelpers.PackRGBA(vector.X, vector.Y, vector.Z, alpha); }
/// <summary> /// Initializes a new instance of the <see cref="Color"/> struct. /// </summary> /// <param name="r">Red component.</param> /// <param name="g">Green component.</param> /// <param name="b">Blue component.</param> /// <param name="a">Alpha component.</param> public Color(float r, float g, float b, float a) : this() { _packedValue = PackHelpers.PackRGBA(r, g, b, a); }