Documentation
¶
Overview ¶
Package gradient implements gradients that can be used with Ilysa.
Index ¶
- Variables
- type LerpFn
- type Point
- type Set
- type Table
- func (gt Table) Boost(m float64) Table
- func (gt Table) Colors() []colorful.Color
- func (gt Table) Lerp(t float64) colorful.Color
- func (gt Table) LerpIn(t float64, fn LerpFn) colorful.Color
- func (gt Table) Reverse() Table
- func (gt Table) Rotate(n int) Table
- func (gt Table) RotateRand() Table
- func (gt Table) Set() colorful.Set
- func (gt Table) ToSet() colorful.Setdeprecated
Constants ¶
This section is empty.
Variables ¶
var DeclaredGradients = map[string]Table{}
var Rainbow = Table{ {colorful.Hex("#9e0142"), 0.0}, {colorful.Hex("#d53e4f"), 0.1}, {colorful.Hex("#f46d43"), 0.2}, {colorful.Hex("#fdae61"), 0.3}, {colorful.Hex("#fee090"), 0.4}, {colorful.Hex("#ffffbf"), 0.5}, {colorful.Hex("#e6f598"), 0.6}, {colorful.Hex("#abdda4"), 0.7}, {colorful.Hex("#66c2a5"), 0.8}, {colorful.Hex("#3288bd"), 0.9}, {colorful.Hex("#5e4fa2"), 1.0}, }
Functions ¶
This section is empty.
Types ¶
type LerpFn ¶ added in v0.0.8
var DefaultLerpFn LerpFn = colorful.BlendOklab
DefaultLerpFn is the function used by Lerp to interpolate between two colors.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
A Set is an ordered set of gradients. Set provides convenience methods such as picking a random gradient from a Set (Set.Rand()) and picking successive gradients from a Set (Set.Next()).
func (Set) Idx ¶ added in v0.0.8
Idx returns the gradient at the ith position. Idx is syntax sugar for Index.
func (Set) Index ¶
Index returns the gradient at the ith position. If i is out of range, i is "wrapped around" to bring it back in range.
type Table ¶
type Table []Point
Table represents a gradient and contains its "points". The position of each keypoint must lie in the range [0,1] and points must be sorted in ascending order.
func NewPingPong ¶
NewPingPong returns a gradient consisting of: (1) colors in order; followed by (2) count copies of colors, alternating between:
(a) colors in reverse order, with the first color omitted; and (b) colors in order, with the first color omitted.
func (Table) Boost ¶ added in v0.0.6
Boost returns a new gradient with each color's RGB value multiplied by m. Boost does not affect a color's A or position.
func (Table) Lerp ¶
Lerp returns interpolated color at t. By default, the interpolation is done in the Oklab colorspace. Change DefaultLerpFn to change the default. Use LerpIn to interpolate in a specific colorspace.
func (Table) LerpIn ¶ added in v0.0.8
LerpIn returns the interpolated color at t, with the interpolation done by fn.
func (Table) Rotate ¶
Rotate returns a copy of the gradient with its colors rotated to the left by n.
func (Table) RotateRand ¶
RotateRand returns a new gradient rotated by a random number.