# xenko3d/xenko

Make alpha optional in Color4

phr00t authored and xen2 committed Mar 21, 2019
1 parent 83e0c19 commit fdad9d838a6c52afb8e3aa6a58c83263d2ebd35a
Showing with 6 additions and 6 deletions.
1. +6 −6 sources/core/Xenko.Core.Mathematics/Color4.cs
@@ -92,7 +92,7 @@ public Color4(float value)
/// <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 Color4(float red, float green, float blue, float alpha)
public Color4(float red, float green, float blue, float alpha = 1f)
{
R = red;
G = green;
@@ -117,7 +117,7 @@ public Color4(Vector4 value)
/// </summary>
/// <param name="value">The red, green, and blue components of the color.</param>
/// <param name="alpha">The alpha component of the color.</param>
public Color4(Vector3 value, float alpha)
public Color4(Vector3 value, float alpha = 1f)
{
R = value.X;
G = value.Y;
@@ -159,13 +159,13 @@ public Color4(float[] values)
{
if (values == null)
throw new ArgumentNullException(nameof(values));
if (values.Length != 4)
throw new ArgumentOutOfRangeException(nameof(values), "There must be four and only four input values for Color4.");
if (values.Length != 3 && values.Length != 4)
throw new ArgumentOutOfRangeException(nameof(values), "There must be 3 or 4 float[] values for Color4.");

R = values[0];
G = values[1];
B = values[2];
A = values[3];
A = values.Length >= 4 ? values[3] : 1f;

#### aaronfranke May 21, 2019

Contributor

This can just be `==`

}

/// <summary>
@@ -209,7 +209,7 @@ public Color4(ColorBGRA color)
/// </summary>
/// <param name="color"><see cref="Color3"/> used to initialize the color.</param>
/// <param name="alpha">The alpha component of the color.</param>
public Color4(Color3 color, float alpha)
public Color4(Color3 color, float alpha = 1f)
{
R = color.R;
G = color.G;