Color

csharp
public struct Color : IEquatable<Color>, IFormattable

Namespace NodeWorld.Flux.

A color, as Unity's: red, green, blue and alpha (opacity), 0 to 1 each.

Fields

r

csharp
public float r

Red.

g

csharp
public float g

Green.

b

csharp
public float b

Blue.

a

csharp
public float a

Alpha: 0 transparent, 1 opaque.

Constructors

Color

csharp
public Color(float r, float g, float b, float a)

A color of these components.

csharp
public Color(float r, float g, float b)

An opaque color (alpha 1).

Properties

red

csharp
public static Color red { get; }

Red (1, 0, 0, 1).

green

csharp
public static Color green { get; }

Green (0, 1, 0, 1).

blue

csharp
public static Color blue { get; }

Blue (0, 0, 1, 1).

white

csharp
public static Color white { get; }

White (1, 1, 1, 1).

black

csharp
public static Color black { get; }

Black (0, 0, 0, 1).

yellow

csharp
public static Color yellow { get; }

Yellow (1, 0.92, 0.016, 1).

cyan

csharp
public static Color cyan { get; }

Cyan (0, 1, 1, 1).

magenta

csharp
public static Color magenta { get; }

Magenta (1, 0, 1, 1).

gray

csharp
public static Color gray { get; }

Gray (0.5, 0.5, 0.5, 1).

grey

csharp
public static Color grey { get; }

Grey: the same as gray.

clear

csharp
public static Color clear { get; }

Transparent black (0, 0, 0, 0).

Methods

Lerp

csharp
public static Color Lerp(Color a, Color b, float t)

From a (t = 0) to b (t = 1), component by component; t is kept between 0 and 1.

Equals

csharp
public bool Equals(Color other)

The components are exactly equal.

csharp
public override bool Equals(object other)

other is a Color with exactly the same components.

GetHashCode

csharp
public override int GetHashCode()

A hash of the components.

ToString

csharp
public override string ToString()

"RGBA(r, g, b, a)" with 3 decimals.

csharp
public string ToString(string format)

The same text with the numbers in format.

csharp
public string ToString(string format, IFormatProvider formatProvider)

The same text with the numbers in format (F3 when empty) and formatProvider (the invariant culture when null).

Operators

operator +

csharp
public static Color operator +(Color a, Color b)

Sum, component by component.

operator -

csharp
public static Color operator -(Color a, Color b)

Difference, component by component.

operator *

csharp
public static Color operator *(Color a, Color b)

Product, component by component.

csharp
public static Color operator *(Color a, float t)

Each component times t.

csharp
public static Color operator *(float t, Color a)

Each component times t.

operator /

csharp
public static Color operator /(Color a, float t)

Each component divided by t.

operator ==

csharp
public static bool operator ==(Color lhs, Color rhs)

Approximately equal, as their Vector4.

operator !=

csharp
public static bool operator !=(Color lhs, Color rhs)

Not approximately equal (see ==).

implicit operator Vector4

csharp
public static implicit operator Vector4(Color c)

r, g, b, a as x, y, z, w.

implicit operator Color

csharp
public static implicit operator Color(Vector4 v)

x, y, z, w as r, g, b, a.