Documentation
¶
Index ¶
- Constants
- Variables
- type AnyScaleDef
- type Curve
- type CurveFunc
- type CurveXYPoints
- type HuePalette
- type NumberColorKV
- type NumberFloatKV
- type NumberKV
- type NumberPaletteKV
- type NumberScaleDef
- type NumberStringKV
- type Palette
- type Palettes
- type ScaleDef
- type StringColorKV
- type StringFloatKV
- type StringKV
- type StringNumberKV
- type StringPaletteKV
- type StringScaleDef
- type ValuesDef
- type XYCurve
Examples ¶
Constants ¶
View Source
const ( // These values are established by empiricism with // tests (tradeoff: performance VS precision) NEWTON_ITERATIONS = 4 NEWTON_MIN_SLOPE = 0.001 SUBDIVISION_PRECISION = 0.0000001 SUBDIVISION_MAX_ITERATIONS = float64(10) )
Variables ¶
View Source
var ( // Screens represents measures/scale of supported screen sizes. Screens = StringScale("sm", "md", "lg", "xl") // Colors represents measure/scale of possible color variants. Colors = NumberScale(100, 200, 300, 400, 500, 600, 700, 800, 900) )
View Source
var EaseInBack = BezierXYPoints(0.6, -0.28, 0.735, 0.045)
View Source
var EaseInBackTCurve = BezierTPoints(0.6, -0.28, 0.735, 0.045)
View Source
var EaseInCirc = BezierXYPoints(0.6, 0.04, 0.98, 0.335)
View Source
var EaseInCircTCurve = BezierTPoints(0.6, 0.04, 0.98, 0.335)
View Source
var EaseInCubic = BezierXYPoints(0.55, 0.055, 0.675, 0.19)
View Source
var EaseInCubicTCurve = BezierTPoints(0.55, 0.055, 0.675, 0.19)
View Source
var EaseInExpo = BezierXYPoints(0.95, 0.05, 0.795, 0.035)
View Source
var EaseInExpoTCurve = BezierTPoints(0.95, 0.05, 0.795, 0.035)
View Source
var EaseInOutBack = BezierXYPoints(0.68, -0.55, 0.265, 1.55)
View Source
var EaseInOutBackTCurve = BezierTPoints(0.68, -0.55, 0.265, 1.55)
View Source
var EaseInOutCirc = BezierXYPoints(0.785, 0.135, 0.15, 0.86)
View Source
var EaseInOutCircTCurve = BezierTPoints(0.785, 0.135, 0.15, 0.86)
View Source
var EaseInOutCubic = BezierXYPoints(0.645, 0.045, 0.355, 1)
View Source
var EaseInOutCubicTCurve = BezierTPoints(0.645, 0.045, 0.355, 1)
View Source
var EaseInOutExpo = BezierXYPoints(1, 0, 0, 1)
View Source
var EaseInOutExpoTCurve = BezierTPoints(1, 0, 0, 1)
View Source
var EaseInOutQuad = BezierXYPoints(0.455, 0.03, 0.515, 0.955)
View Source
var EaseInOutQuadTCurve = BezierTPoints(0.455, 0.03, 0.515, 0.955)
View Source
var EaseInOutQuart = BezierXYPoints(0.77, 0, 0.175, 1)
View Source
var EaseInOutQuartTCurve = BezierTPoints(0.77, 0, 0.175, 1)
View Source
var EaseInOutQuint = BezierXYPoints(0.86, 0, 0.07, 1)
View Source
var EaseInOutQuintTCurve = BezierTPoints(0.86, 0, 0.07, 1)
View Source
var EaseInOutSine = BezierXYPoints(0.445, 0.05, 0.55, 0.95)
View Source
var EaseInOutSineTCurve = BezierTPoints(0.445, 0.05, 0.55, 0.95)
View Source
var EaseInQuad = BezierXYPoints(0.55, 0.085, 0.68, 0.53)
View Source
var EaseInQuadTCurve = BezierTPoints(0.55, 0.085, 0.68, 0.53)
View Source
var EaseInQuart = BezierXYPoints(0.895, 0.03, 0.685, 0.22)
View Source
var EaseInQuartTCurve = BezierTPoints(0.895, 0.03, 0.685, 0.22)
View Source
var EaseInQuint = BezierXYPoints(0.755, 0.05, 0.855, 0.06)
View Source
var EaseInQuintTCurve = BezierTPoints(0.755, 0.05, 0.855, 0.06)
View Source
var EaseInSine = BezierXYPoints(0.47, 0, 0.745, 0.715)
View Source
var EaseInSineTCurve = BezierTPoints(0.47, 0, 0.745, 0.715)
View Source
var EaseOutBack = BezierXYPoints(0.175, 0.885, 0.32, 1.275)
View Source
var EaseOutBackTCurve = BezierTPoints(0.175, 0.885, 0.32, 1.275)
View Source
var EaseOutCirc = BezierXYPoints(0.075, 0.82, 0.165, 1)
View Source
var EaseOutCircTCurve = BezierTPoints(0.075, 0.82, 0.165, 1)
View Source
var EaseOutCubic = BezierXYPoints(0.215, 0.61, 0.355, 1)
View Source
var EaseOutCubicTCurve = BezierTPoints(0.215, 0.61, 0.355, 1)
View Source
var EaseOutExpo = BezierXYPoints(0.19, 1, 0.22, 1)
View Source
var EaseOutExpoTCurve = BezierTPoints(0.19, 1, 0.22, 1)
View Source
var EaseOutQuad = BezierXYPoints(0.25, 0.46, 0.45, 0.94)
View Source
var EaseOutQuadTCurve = BezierTPoints(0.25, 0.46, 0.45, 0.94)
View Source
var EaseOutQuart = BezierXYPoints(0.165, 0.84, 0.44, 1)
View Source
var EaseOutQuartTCurve = BezierTPoints(0.165, 0.84, 0.44, 1)
View Source
var EaseOutQuint = BezierXYPoints(0.23, 1, 0.32, 1)
View Source
var EaseOutQuintTCurve = BezierTPoints(0.23, 1, 0.32, 1)
View Source
var EaseOutSine = BezierXYPoints(0.39, 0.575, 0.565, 1)
View Source
var EaseOutSineTCurve = BezierTPoints(0.39, 0.575, 0.565, 1)
View Source
var Linear = BezierXYPoints(0.5, 0.5, 0.5, 0.5)
View Source
var LinearTCurve = BezierTPoints(0.5, 0.5, 0.5, 0.5)
Functions ¶
This section is empty.
Types ¶
type AnyScaleDef ¶
type AnyScaleDef struct {
// contains filtered or unexported fields
}
func AnyScale ¶
func AnyScale(values ...interface{}) *AnyScaleDef
func (*AnyScaleDef) Count ¶
func (s *AnyScaleDef) Count() int
func (*AnyScaleDef) HasIndex ¶
func (s *AnyScaleDef) HasIndex(i int) bool
func (*AnyScaleDef) Index ¶
func (s *AnyScaleDef) Index(i int) interface{}
func (*AnyScaleDef) IsKeyType ¶
func (s *AnyScaleDef) IsKeyType(i interface{}) bool
IsKeyType always returns true for AnyScaleDef.
func (*AnyScaleDef) Key ¶
func (s *AnyScaleDef) Key(i interface{}) bool
type Curve ¶
func BezierTPoints ¶
type CurveXYPoints ¶
func BezierXYPointsList ¶
func BezierXYPointsList(points ...float64) CurveXYPoints
type HuePalette ¶
type HuePalette struct { Steps int // number of colors to be generated HueStart int // Hue value (0-359) HueEnd int // Hue value (0-359) HueCurve Curve // Hue bezier curve points SaturationRate float64 // rate of saturation increase (0-200) SaturationStart int // Saturation value (0-100) SaturationEnd int // Saturation value (0-100) SaturationCurve Curve // Bezier curve points for saturation LuminousityStart int // Luminous value (0-100) LuminousityEnd int // Luminous value (0-100) LuminosityCurve Curve // Luminosity bezier curve points ContrastColorLight *gocolorful.Color // Provides light color contrast to be used for calculating contrast ContrastColorDark *gocolorful.Color // Provides dark color contrast to be used for calculating contrast }
HuePalette implements the color algorithm defined in the lyft color algorithm which provides a more concise way of generating colors for specific hues, saturation and luminousity levels that match how we perceive colors.
See - [Re-Approaching Color by Lyft Design](https://design.lyft.com/re-approaching-color-9e604ba22c88) and [Life Color Algorithm](https://github.com/lyft/coloralgorithm).
type NumberColorKV ¶
type NumberColorKV struct {
Values *ValuesDef
}
func NewNumberColorKV ¶
func NewNumberColorKV(scale ScaleDef) *NumberColorKV
func (*NumberColorKV) Index ¶
func (skv *NumberColorKV) Index(i int, v gocolorful.Color) *NumberColorKV
func (*NumberColorKV) Key ¶
func (skv *NumberColorKV) Key(k int, v gocolorful.Color) *NumberColorKV
func (*NumberColorKV) ValuesAtIndex ¶
func (skv *NumberColorKV) ValuesAtIndex(i int) gocolorful.Color
func (*NumberColorKV) ValuesAtKey ¶
func (skv *NumberColorKV) ValuesAtKey(k int) gocolorful.Color
type NumberFloatKV ¶
type NumberFloatKV struct {
Values *ValuesDef
}
func NewNumberFloatKV ¶
func NewNumberFloatKV(scale ScaleDef) *NumberFloatKV
func (*NumberFloatKV) Index ¶
func (skv *NumberFloatKV) Index(i int, v float64) *NumberFloatKV
func (*NumberFloatKV) Key ¶
func (skv *NumberFloatKV) Key(k int, v float64) *NumberFloatKV
func (*NumberFloatKV) ValuesAtIndex ¶
func (skv *NumberFloatKV) ValuesAtIndex(i int) float64
func (*NumberFloatKV) ValuesAtKey ¶
func (skv *NumberFloatKV) ValuesAtKey(k int) float64
type NumberKV ¶
type NumberKV struct {
Values *ValuesDef
}
func NewNumberKV ¶
func (*NumberKV) ValuesAtIndex ¶
func (*NumberKV) ValuesAtKey ¶
type NumberPaletteKV ¶
type NumberPaletteKV struct {
Values *ValuesDef
}
func NewNumberPaletteKV ¶
func NewNumberPaletteKV(scale ScaleDef) *NumberPaletteKV
func (*NumberPaletteKV) Index ¶
func (skv *NumberPaletteKV) Index(i int, v Palette) *NumberPaletteKV
func (*NumberPaletteKV) Key ¶
func (skv *NumberPaletteKV) Key(k int, v Palette) *NumberPaletteKV
func (*NumberPaletteKV) ValuesAtIndex ¶
func (skv *NumberPaletteKV) ValuesAtIndex(i int) Palette
func (*NumberPaletteKV) ValuesAtKey ¶
func (skv *NumberPaletteKV) ValuesAtKey(k int) Palette
type NumberScaleDef ¶
type NumberScaleDef struct {
// contains filtered or unexported fields
}
func NumberScale ¶
func NumberScale(values ...int) *NumberScaleDef
func (*NumberScaleDef) Count ¶
func (s *NumberScaleDef) Count() int
func (*NumberScaleDef) HasIndex ¶
func (s *NumberScaleDef) HasIndex(i int) bool
func (*NumberScaleDef) Index ¶
func (s *NumberScaleDef) Index(i int) interface{}
func (*NumberScaleDef) IsKeyType ¶
func (s *NumberScaleDef) IsKeyType(i interface{}) bool
func (*NumberScaleDef) IsValueType ¶
func (s *NumberScaleDef) IsValueType(i interface{}) bool
func (*NumberScaleDef) Key ¶
func (s *NumberScaleDef) Key(i interface{}) bool
type NumberStringKV ¶
type NumberStringKV struct {
Values *ValuesDef
}
func NewNumberStringKV ¶
func NewNumberStringKV(scale ScaleDef) *NumberStringKV
func (*NumberStringKV) Index ¶
func (skv *NumberStringKV) Index(i int, v string) *NumberStringKV
func (*NumberStringKV) Key ¶
func (skv *NumberStringKV) Key(k int, v string) *NumberStringKV
func (*NumberStringKV) ValuesAtIndex ¶
func (skv *NumberStringKV) ValuesAtIndex(i int) string
func (*NumberStringKV) ValuesAtKey ¶
func (skv *NumberStringKV) ValuesAtKey(k int) string
type Palette ¶
type Palette struct { Step int Steps int Hex string RGB gocolorful.Color HCL gocolorful.Color HSV gocolorful.Color HSL gocolorful.Color ContrastDark float64 ContrastLight float64 HueRange []int Hue float64 Saturation float64 Luminosity float64 }
Palette defines the generated color set which is produced from provided HuePalette.
Example ¶
var palette = CreatePalette(HuePalette{ Steps: 10, HueStart: 100, HueEnd: 359, HueCurve: EaseInCubicTCurve, SaturationRate: 30, SaturationStart: 10, SaturationEnd: 80, SaturationCurve: EaseInCubicTCurve, LuminousityStart: 5, LuminousityEnd: 80, LuminosityCurve: EaseInCubicTCurve, ContrastColorLight: nil, ContrastColorDark: nil, }) var json, err = json2.Marshal(palette) if err != nil { log.Fatal(err.Error()) } fmt.Println(json)
Output:
type Palettes ¶
type Palettes struct { LightMode []Palette DarkMode []Palette // will be a list of LightMode palette set reversed. }
func CreatePalette ¶
func CreatePalette(config HuePalette) Palettes
type StringColorKV ¶
type StringColorKV struct {
Values *ValuesDef
}
func NewStringColorKV ¶
func NewStringColorKV(scale ScaleDef) *StringColorKV
func (*StringColorKV) Index ¶
func (skv *StringColorKV) Index(i int, v gocolorful.Color) *StringColorKV
func (*StringColorKV) Key ¶
func (skv *StringColorKV) Key(k string, v gocolorful.Color) *StringColorKV
func (*StringColorKV) ValuesAtIndex ¶
func (skv *StringColorKV) ValuesAtIndex(i int) gocolorful.Color
func (*StringColorKV) ValuesAtKey ¶
func (skv *StringColorKV) ValuesAtKey(k string) gocolorful.Color
type StringFloatKV ¶
type StringFloatKV struct {
Values *ValuesDef
}
func NewStringFloatKV ¶
func NewStringFloatKV(scale ScaleDef) *StringFloatKV
func (*StringFloatKV) Index ¶
func (skv *StringFloatKV) Index(i int, v float64) *StringFloatKV
func (*StringFloatKV) Key ¶
func (skv *StringFloatKV) Key(k string, v float64) *StringFloatKV
func (*StringFloatKV) ValuesAtIndex ¶
func (skv *StringFloatKV) ValuesAtIndex(i int) float64
func (*StringFloatKV) ValuesAtKey ¶
func (skv *StringFloatKV) ValuesAtKey(k string) float64
type StringKV ¶
type StringKV struct {
Values *ValuesDef
}
func NewStringKV ¶
func (*StringKV) ValuesAtIndex ¶
func (*StringKV) ValuesAtKey ¶
type StringNumberKV ¶
type StringNumberKV struct {
Values *ValuesDef
}
func NewStringNumberKV ¶
func NewStringNumberKV(scale ScaleDef) *StringNumberKV
func (*StringNumberKV) Index ¶
func (skv *StringNumberKV) Index(i int, v int) *StringNumberKV
func (*StringNumberKV) Key ¶
func (skv *StringNumberKV) Key(k string, v int) *StringNumberKV
func (*StringNumberKV) ValuesAtIndex ¶
func (skv *StringNumberKV) ValuesAtIndex(i int) int
func (*StringNumberKV) ValuesAtKey ¶
func (skv *StringNumberKV) ValuesAtKey(k string) int
type StringPaletteKV ¶
type StringPaletteKV struct {
Values *ValuesDef
}
func NewStringPaletteKV ¶
func NewStringPaletteKV(scale ScaleDef) *StringPaletteKV
func (*StringPaletteKV) Index ¶
func (skv *StringPaletteKV) Index(i int, v Palette) *StringPaletteKV
func (*StringPaletteKV) Key ¶
func (skv *StringPaletteKV) Key(k string, v Palette) *StringPaletteKV
func (*StringPaletteKV) ValuesAtIndex ¶
func (skv *StringPaletteKV) ValuesAtIndex(i int) Palette
func (*StringPaletteKV) ValuesAtKey ¶
func (skv *StringPaletteKV) ValuesAtKey(k string) Palette
type StringScaleDef ¶
type StringScaleDef struct {
// contains filtered or unexported fields
}
func StringScale ¶
func StringScale(values ...string) *StringScaleDef
func (*StringScaleDef) Count ¶
func (s *StringScaleDef) Count() int
func (*StringScaleDef) HasIndex ¶
func (s *StringScaleDef) HasIndex(i int) bool
func (*StringScaleDef) Index ¶
func (s *StringScaleDef) Index(i int) interface{}
func (*StringScaleDef) IsKeyType ¶
func (s *StringScaleDef) IsKeyType(i interface{}) bool
func (*StringScaleDef) IsValueType ¶
func (s *StringScaleDef) IsValueType(i interface{}) bool
func (*StringScaleDef) Key ¶
func (s *StringScaleDef) Key(i interface{}) bool
type ValuesDef ¶
type ValuesDef struct {
// contains filtered or unexported fields
}
func NewValuesDef ¶
func (*ValuesDef) ValueAtIndex ¶
func (*ValuesDef) ValueAtKey ¶
func (sv *ValuesDef) ValueAtKey(key interface{}) interface{}
Click to show internal directories.
Click to hide internal directories.