Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AveragingFunc ¶
type AveragingFunc func([]AveragingPoint) RGB
AveragingFunc is a function that averages a slice of colors into a single color.
func NewNearestAveraging ¶
func NewNearestAveraging() AveragingFunc
NewNearestAveraging creates a new AveragingFunc that averages a slice of colors into a single color. It simply returns the first color in the slice.
func NewSimpleAveraging ¶
func NewSimpleAveraging() AveragingFunc
NewSimpleAveraging creates a new AveragingFunc that averages a slice of colors into a single color. It simply averages the red, green, and blue values of the colors.
This function can handle about 2.8 million colors before overflowing.
func NewSquaredAveraging ¶
func NewSquaredAveraging() AveragingFunc
NewSquaredAveraging creates a new AveragingFunc that averages a slice of colors into a single color. It squares the red, green, and blue values of the colors before averaging them to give more weight to brighter colors.
This function can handle about 33 thousand colors before overflowing.
For more information, see: https://sighack.com/post/averaging-rgb-colors-the-right-way
type AveragingPoint ¶
AveragingPoint is a point that is used to average a slice of colors into a single color.
type AveragingType ¶
type AveragingType uint8
const ( SimpleAveragingType AveragingType SquaredAveragingType NearestNeighborAveragingType )
type RGB ¶
type RGB struct {
R, G, B uint8
}
RGB is a color in the RGB color space. It is represented as 3 8-bit values for red, green, and blue.
func RGBFromColor ¶
RGBFromColor converts any color.Color to RGB.
func RGBFromString ¶
RGBFromString converts a string to RGB.
func (RGB) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. It marshals RGB as an integer.
func (RGB) String ¶
String implements the fmt.Stringer interface. It returns the color in hexadecimal notation.
func (*RGB) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. It unmarshals an integer as RGB.