Class ByteColor
Fast 4 byte item variation of a color for efficient storage and operating inside chunk.
Allows to store colors more efficiently for each chunk per 1000+ block each
Good as we do not care about alpha, and has less memory that hex color storage.
Occupies 4 times less memory that regular color.
So for min draw distance in eco it will be small 256kb overhead instead of 1mb of data. (loaded 8x8 chunk grid)
Inheritance
System.Object
ByteColor
Assembly: Eco.Shared.dll
Syntax
[Serialized]
public sealed class ByteColor : ValueType, IBsonSerialize, IBsonSerializable, IBsonDeserializable
Constructors
ByteColor(Byte, Byte, Byte)
Declaration
public ByteColor(byte r, byte g, byte b)
Parameters
Type |
Name |
Description |
System.Byte |
r |
|
System.Byte |
g |
|
System.Byte |
b |
|
ByteColor(Byte, Byte, Byte, Byte)
Declaration
public ByteColor(byte r, byte g, byte b, byte a)
Parameters
Type |
Name |
Description |
System.Byte |
r |
|
System.Byte |
g |
|
System.Byte |
b |
|
System.Byte |
a |
|
Fields
Clear
Declaration
public static ByteColor Clear
Field Value
White
Declaration
public static ByteColor White
Field Value
Properties
A
Declaration
[Serialized]
public byte A { get; }
Property Value
Type |
Description |
System.Byte |
|
B
Declaration
[Serialized]
public byte B { get; }
Property Value
Type |
Description |
System.Byte |
|
G
Declaration
[Serialized]
public byte G { get; }
Property Value
Type |
Description |
System.Byte |
|
HexRGB
Declaration
public string HexRGB { get; }
Property Value
Type |
Description |
System.String |
|
HexRGBA
Declaration
public string HexRGBA { get; }
Property Value
Type |
Description |
System.String |
|
R
Declaration
[Serialized]
public byte R { get; }
Property Value
Type |
Description |
System.Byte |
|
Methods
Clamped(Single, Single, Single)
Returns clamped byte color instance in [0-225] range, based on integer input
Declaration
public static ByteColor Clamped(float r, float g, float b)
Parameters
Type |
Name |
Description |
System.Single |
r |
|
System.Single |
g |
|
System.Single |
b |
|
Returns
CompareHexRGB(String)
Compares 2 color hex values as string. Counts only for RGB, without alpha
Declaration
public bool CompareHexRGB(string hexString)
Parameters
Type |
Name |
Description |
System.String |
hexString |
|
Returns
Type |
Description |
System.Boolean |
|
Convert()
Converts Byte color to Eco.Shared.Color
Declaration
Returns
Distance(ByteColor)
Calculate the Euclidean distance between current color and target. Ignores Alpha.
Declaration
public float Distance(ByteColor c)
Parameters
Returns
Type |
Description |
System.Single |
|
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
EqualsNoAlpha(ByteColor)
Declaration
public bool EqualsNoAlpha(ByteColor other)
Parameters
Returns
Type |
Description |
System.Boolean |
|
FromBson(BSONArray)
Declaration
public void FromBson(BSONArray bson)
Parameters
FromHex(String)
Declaration
public static ByteColor FromHex(string hex)
Parameters
Type |
Name |
Description |
System.String |
hex |
|
Returns
Get(Color)
Converts Eco.Shared.Utils.Color to ByteColor. Trims alpha and changes to byte.
Declaration
public static ByteColor Get(Color color)
Parameters
Type |
Name |
Description |
Color |
color |
|
Returns
Get(Single, Single, Single, Single)
Declaration
public static ByteColor Get(float r, float g, float b, float a)
Parameters
Type |
Name |
Description |
System.Single |
r |
|
System.Single |
g |
|
System.Single |
b |
|
System.Single |
a |
|
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
GetHue()
Get hue value of byte color
Declaration
Returns
Type |
Description |
System.Single |
|
Lerp(ByteColor, Single)
Interpolates color towards another
Declaration
public ByteColor Lerp(ByteColor to, float t)
Parameters
Type |
Name |
Description |
ByteColor |
to |
|
System.Single |
t |
|
Returns
ToBson()
Declaration
public BSONArray ToBson()
Returns
ValidateHex(String)
Tries to validate provided hex input, puts # if missing, returns white if bad format
Declaration
public static string ValidateHex(string hex)
Parameters
Type |
Name |
Description |
System.String |
hex |
|
Returns
Type |
Description |
System.String |
|
WithAlpha(Byte)
Returns new instance of byte color with target Alpha
Declaration
public ByteColor WithAlpha(byte coat)
Parameters
Type |
Name |
Description |
System.Byte |
coat |
|
Returns
Operators
Addition(ByteColor, ByteColor)
Declaration
public static ByteColor operator +(ByteColor a, ByteColor b)
Parameters
Returns
Equality(ByteColor, ByteColor)
Declaration
public static bool operator ==(ByteColor left, ByteColor right)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Inequality(ByteColor, ByteColor)
Declaration
public static bool operator !=(ByteColor left, ByteColor right)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Multiply(ByteColor, Single)
Declaration
public static ByteColor operator *(ByteColor a, float b)
Parameters
Type |
Name |
Description |
ByteColor |
a |
|
System.Single |
b |
|
Returns
Implements
Extension Methods