Documentation ¶
Index ¶
- Variables
- func BW() color.Palette
- func ConvHSLAtoRGBA(hsla []float64) []float64
- func ConvRGBAtoHSLA(rgba []float64) []float64
- func Create(img image.Image, k int) color.Palette
- func ToRGBA(origColor color.Color) color.RGBA
- type ColorPalette
- func (colorpalette *ColorPalette) ToJSONFile(jsonFileName string)
- func (colorpalette *ColorPalette) ToJSONFileNoIndent(jsonFileName string)
- func (colorpalette *ColorPalette) ToPalette() color.Palette
- func (colorpalette *ColorPalette) Traverse(img *image.Image, ltr bool, name string) (ColorPalette, int)
Constants ¶
This section is empty.
Variables ¶
var KMAccuracy = 0.01
KMAccuracy is he accuracy needed for convergence of the k-means algorithm used in function Create
var KMConsecutive = 2
KMConsecutive is the consecutive accuracy hits needed for convergence of the k-means algorithm used in function Create
var KMTimes = 3
KMTimes descibes how many times the Kmeans algorithm needs to be run with random start
var SampleFactor = 5
SampleFactor describes the fraction of pixels to be used in creating a palette.
Functions ¶
func ConvHSLAtoRGBA ¶
ConvHSLAtoRGBA converts between HSLA and RGBA color formats
func ConvRGBAtoHSLA ¶
ConvRGBAtoHSLA converts between RGBA and HSLA color formats
func Create ¶ added in v0.6.0
Create creates a new colorpalette using the k-means clustering algorithm
- samplefactor: how many pixles to skip, during sampling for the creatrion of the KMeans problem's cluster points (higher means faster, because less points to iterate over)
- kmTimes defines the amount of times to start the k-means algorithm with random init, the best output is choosen
Types ¶
type ColorPalette ¶
ColorPalette contains name and colors of one colorpalette
func CreatePLT ¶ added in v0.9.4
func CreatePLT(img image.Image, k int) ColorPalette
CreatePLT creates a new colorpalette using the k-means clustering algorithm
- samplefactor: how many pixles to skip, during sampling for the creatrion of the KMeans problem's cluster points (higher means faster, because less points to iterate over)
- kmTimes defines the amount of times to start the k-means algorithm with random init, the best output is choosen
func GetPaletteWithName ¶
func GetPaletteWithName(name string, palettes []ColorPalette) *ColorPalette
GetPaletteWithName returns a specific from a slice of ColorPalette. The palette is specified by name. If there is none that matches, a black ColorPalette is returned.
func GetPalettesFromJSON ¶
func GetPalettesFromJSON(jsonFileName string) []ColorPalette
GetPalettesFromJSON returns a slice of ColorPalettes after reading them from a JSON file.
func (*ColorPalette) ToJSONFile ¶
func (colorpalette *ColorPalette) ToJSONFile(jsonFileName string)
ToJSONFile writes the given ColorPalette out to the specified path, as a JSON file (formatted).
func (*ColorPalette) ToJSONFileNoIndent ¶ added in v0.9.4
func (colorpalette *ColorPalette) ToJSONFileNoIndent(jsonFileName string)
ToJSONFileNoIndent writes the given ColorPalette out to the specified path, as a JSON file (formatted).
func (*ColorPalette) ToPalette ¶
func (colorpalette *ColorPalette) ToPalette() color.Palette
ToPalette converts between this custom ColorPalette and the Go standard library color.Palette type struct
func (*ColorPalette) Traverse ¶ added in v0.9.4
func (colorpalette *ColorPalette) Traverse(img *image.Image, ltr bool, name string) (ColorPalette, int)
Traverse is used to find colours on one line in the image