Documentation ¶
Index ¶
- Variables
- func RGBDistance(c1 RGB, c2 RGB) float64
- type RGB
- func (rgb RGB) Invert() (inv RGB)
- func (mj *RGB) MarshalJSON() ([]byte, error)
- func (mj *RGB) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (rgb *RGB) To256() (conv RGB256)
- func (uj *RGB) UnmarshalJSON(input []byte) error
- func (uj *RGB) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type RGB256
Constants ¶
This section is empty.
Variables ¶
var ( Black = RGB{Red: 0.0, Green: 0.0, Blue: 0.0} White = RGB{Red: 1.0, Green: 1.0, Blue: 1.0} Red = RGB{Red: 1.0, Green: 0.0, Blue: 0.0} Green = RGB{Red: 0.0, Green: 1.0, Blue: 0.0} Blue = RGB{Red: 0.0, Green: 0.0, Blue: 1.0} Yellow = RGB{Red: 1.0, Green: 1.0, Blue: 0.0} Magenta = RGB{Red: 1.0, Green: 0.0, Blue: 1.0} Cyan = RGB{Red: 0.0, Green: 1.0, Blue: 1.0} Orange = RGB{Red: 1.0, Green: 0.5, Blue: 0.0} )
Functions ¶
func RGBDistance ¶
RGBDistance quantifies the value difference between two RGB structs, returning a floating-point ratio from 0.0 to 1.0. Multiply the returned value by100 for a percentage. NOTE: this is a distinct concept from the distance between them as 3D vectors, as there would be 2 other RGB for any RGB with an identical magnitude. e.g. [1.0 0 0] [0 1.0 0] [0 0 1.0] will all have the same magnitude, but are pure Red, pure Blue, pure Green respectively!
Types ¶
type RGB ¶
type RGB struct { Red float64 `json:"red"` Green float64 `json:"green"` Blue float64 `json:"blue"` }
RGB stores a floating-point representation of 3 colour channel RGB colour (Red Green Blue), where each value is in range [0,1] Colours live in a form of vector space.
func RandRGB ¶
func RandRGB() RGB
RandRGB will return a random valid RGB object within the complete range of all possible RGB values.
func RandRGBClamped ¶
RandRGBClamped will return a random valid RGB object within some differential of `col`
func (*RGB) MarshalJSON ¶
func (*RGB) MarshalJSONBuf ¶
func (mj *RGB) MarshalJSONBuf(buf fflib.EncodingBuffer) error
func (*RGB) To256 ¶
To256 returns the conversion from floating point ranged RGB values to those in range [0,256)
func (*RGB) UnmarshalJSON ¶
func (*RGB) UnmarshalJSONFFLexer ¶
type RGB256 ¶
RGB256 stores a integer representation of 3 colour channel RGB colour (Red Green Blue), where each value is in range [0,256)
func (*RGB256) MarshalJSON ¶
func (*RGB256) MarshalJSONBuf ¶
func (mj *RGB256) MarshalJSONBuf(buf fflib.EncodingBuffer) error