Documentation ¶
Overview ¶
Example (CustomGradient) ¶
package main import ( "fmt" "github.com/mazznoer/colorgrad" ) func main() { grad, err := colorgrad.NewGradient(). HtmlColors("red", "#FFD700", "lime"). Domain(0, 0.35, 1). Mode(colorgrad.BlendOklab). Build() if err != nil { panic(err) } fmt.Println(grad.At(0).Hex()) fmt.Println(grad.At(1).Hex()) }
Output: #ff0000 #00ff00
Example (PresetGradient) ¶
package main import ( "fmt" "github.com/mazznoer/colorgrad" ) func main() { grad := colorgrad.Rainbow() dmin, dmax := grad.Domain() fmt.Println(dmin, dmax) fmt.Println(grad.At(0).Hex()) }
Output: 0 1 #6e40aa
Index ¶
- type BlendMode
- type Gradient
- func Blues() Gradient
- func BrBG() Gradient
- func BuGn() Gradient
- func BuPu() Gradient
- func Cividis() Gradient
- func Cool() Gradient
- func CubehelixDefault() Gradient
- func GnBu() Gradient
- func Greens() Gradient
- func Greys() Gradient
- func Inferno() Gradient
- func Magma() Gradient
- func OrRd() Gradient
- func Oranges() Gradient
- func PRGn() Gradient
- func ParseGgr(r io.Reader, fg, bg colorful.Color) (Gradient, string, error)
- func PiYG() Gradient
- func Plasma() Gradient
- func PuBu() Gradient
- func PuBuGn() Gradient
- func PuOr() Gradient
- func PuRd() Gradient
- func Purples() Gradient
- func Rainbow() Gradient
- func RdBu() Gradient
- func RdGy() Gradient
- func RdPu() Gradient
- func RdYlBu() Gradient
- func RdYlGn() Gradient
- func Reds() Gradient
- func Sinebow() Gradient
- func Spectral() Gradient
- func Turbo() Gradient
- func Viridis() Gradient
- func Warm() Gradient
- func YlGn() Gradient
- func YlGnBu() Gradient
- func YlOrBr() Gradient
- func YlOrRd() Gradient
- func (g Gradient) At(t float64) colorful.Color
- func (g Gradient) ColorfulColors(count uint) []colorful.Color
- func (g Gradient) Colors(count uint) []color.Color
- func (g Gradient) Domain() (float64, float64)
- func (g Gradient) ReflectAt(t float64) colorful.Color
- func (g Gradient) RepeatAt(t float64) colorful.Color
- func (g Gradient) Sharp(segment uint, smoothness float64) Gradient
- type GradientBuilder
- func (gb *GradientBuilder) Build() (Gradient, error)
- func (gb *GradientBuilder) Colors(colors ...color.Color) *GradientBuilder
- func (gb *GradientBuilder) Domain(domain ...float64) *GradientBuilder
- func (gb *GradientBuilder) HtmlColors(htmlColors ...string) *GradientBuilder
- func (gb *GradientBuilder) Interpolation(mode Interpolation) *GradientBuilder
- func (gb *GradientBuilder) Mode(mode BlendMode) *GradientBuilder
- type Interpolation
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gradient ¶
type Gradient struct {
// contains filtered or unexported fields
}
func CubehelixDefault ¶ added in v0.2.0
func CubehelixDefault() Gradient
func (Gradient) ColorfulColors ¶ added in v0.5.0
Get n colors evenly spaced across gradient
type GradientBuilder ¶
type GradientBuilder struct {
// contains filtered or unexported fields
}
func NewGradient ¶
func NewGradient() *GradientBuilder
func (*GradientBuilder) Build ¶
func (gb *GradientBuilder) Build() (Gradient, error)
func (*GradientBuilder) Colors ¶
func (gb *GradientBuilder) Colors(colors ...color.Color) *GradientBuilder
func (*GradientBuilder) Domain ¶
func (gb *GradientBuilder) Domain(domain ...float64) *GradientBuilder
func (*GradientBuilder) HtmlColors ¶ added in v0.4.0
func (gb *GradientBuilder) HtmlColors(htmlColors ...string) *GradientBuilder
func (*GradientBuilder) Interpolation ¶ added in v0.9.0
func (gb *GradientBuilder) Interpolation(mode Interpolation) *GradientBuilder
func (*GradientBuilder) Mode ¶
func (gb *GradientBuilder) Mode(mode BlendMode) *GradientBuilder
type Interpolation ¶ added in v0.9.0
type Interpolation int
const ( InterpolationLinear Interpolation = iota InterpolationCatmullRom InterpolationBasis )
func (Interpolation) String ¶ added in v0.9.1
func (i Interpolation) String() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.