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).HexString())
fmt.Println(grad.At(1).HexString())
}
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).HexString())
}
Output: 0 1 #6e40aa
Index ¶
- Variables
- type BlendMode
- type Color
- 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 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
- type GradientBuilder
- func (gb *GradientBuilder) Build() (Gradient, error)
- func (gb *GradientBuilder) Colors(colors ...Color) *GradientBuilder
- func (gb *GradientBuilder) Css(s string) *GradientBuilder
- func (gb *GradientBuilder) Domain(positions ...float64) *GradientBuilder
- func (gb *GradientBuilder) GetColors() *[]Color
- func (gb *GradientBuilder) GetPositions() *[]float64
- func (gb *GradientBuilder) HtmlColors(htmlColors ...string) *GradientBuilder
- func (gb *GradientBuilder) Interpolation(mode Interpolation) *GradientBuilder
- func (gb *GradientBuilder) Mode(mode BlendMode) *GradientBuilder
- func (gb *GradientBuilder) Reset() *GradientBuilder
- type GradientCore
- type Interpolation
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Hsl = csscolorparser.FromHsl
View Source
var Hsv = csscolorparser.FromHsv
View Source
var Hwb = csscolorparser.FromHwb
View Source
var Lab = csscolorparser.FromLab
View Source
var Lch = csscolorparser.FromLch
View Source
var LinearRgb = csscolorparser.FromLinearRGB
View Source
var Oklab = csscolorparser.FromOklab
View Source
var Oklch = csscolorparser.FromOklch
Functions ¶
This section is empty.
Types ¶
type Color ¶ added in v0.10.0
type Color = csscolorparser.Color
type Gradient ¶
type Gradient struct {
Core GradientCore
Min float64
Max float64
}
func CubehelixDefault ¶ added in v0.2.0
func CubehelixDefault() 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) *GradientBuilder
func (*GradientBuilder) Css ¶ added in v0.10.1
func (gb *GradientBuilder) Css(s string) *GradientBuilder
func (*GradientBuilder) Domain ¶
func (gb *GradientBuilder) Domain(positions ...float64) *GradientBuilder
func (*GradientBuilder) GetColors ¶ added in v0.10.0
func (gb *GradientBuilder) GetColors() *[]Color
For testing purposes
func (*GradientBuilder) GetPositions ¶ added in v0.10.0
func (gb *GradientBuilder) GetPositions() *[]float64
For testing purposes
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
func (*GradientBuilder) Reset ¶ added in v0.11.0
func (gb *GradientBuilder) Reset() *GradientBuilder
type GradientCore ¶ added in v0.11.0
type Interpolation ¶ added in v0.9.0
type Interpolation int
const ( InterpolationLinear Interpolation = iota InterpolationSmoothstep InterpolationCatmullRom InterpolationBasis )
func (Interpolation) String ¶ added in v0.9.1
func (i Interpolation) String() string
Click to show internal directories.
Click to hide internal directories.




















