exp: golang.org/x/exp/shiny/iconvg/internal/gradient Index | Files

package gradient

import "golang.org/x/exp/shiny/iconvg/internal/gradient"

Package gradient provides linear and radial gradient images.

Index

Package Files

gradient.go

func AppendRanges Uses

func AppendRanges(a []Range, stops []Stop) []Range

AppendRanges appends to a the ranges defined by a's implicit final stop (if any exist) and stops.

type Gradient Uses

type Gradient struct {
    Shape  Shape
    Spread Spread

    // Pix2Grad transforms coordinates from pixel space (the arguments to the
    // Image.At method) to gradient space. Gradient space is where a linear
    // gradient ranges from x == 0 to x == 1, and a radial gradient has center
    // (0, 0) and radius 1.
    //
    // This is an affine transform, so it can represent elliptical gradients in
    // pixel space, including non-axis-aligned ellipses.
    //
    // For a linear gradient, the bottom row is ignored.
    Pix2Grad f64.Aff3

    Ranges []Range

    // First and Last are the first and last stop's colors.
    First, Last color.RGBA64
}

Gradient is a very large image.Image (the same size as an image.Uniform) whose colors form a gradient.

func (*Gradient) At Uses

func (g *Gradient) At(x, y int) color.Color

At satisfies the image.Image interface.

func (*Gradient) Bounds Uses

func (g *Gradient) Bounds() image.Rectangle

Bounds satisfies the image.Image interface.

func (*Gradient) ColorModel Uses

func (g *Gradient) ColorModel() color.Model

ColorModel satisfies the image.Image interface.

func (*Gradient) Init Uses

func (g *Gradient) Init(shape Shape, spread Spread, pix2Grad f64.Aff3, stops []Stop)

Init initializes g to a gradient whose geometry is defined by shape and pix2Grad and whose colors are defined by spread and stops.

type Range Uses

type Range struct {
    Offset0 float64
    Offset1 float64
    Width   float64
    R0      float64
    R1      float64
    G0      float64
    G1      float64
    B0      float64
    B1      float64
    A0      float64
    A1      float64
}

Range is the range between two stops.

func MakeRange Uses

func MakeRange(s0, s1 Stop) Range

MakeRange returns the range between two stops.

type Shape Uses

type Shape uint8

Shape is the gradient shape.

const (
    ShapeLinear Shape = iota
    ShapeRadial
)

type Spread Uses

type Spread uint8

Spread is the gradient spread, or how to spread a gradient past its nominal bounds (from offset being 0.0 to offset being 1.0).

const (
    // SpreadNone means that offsets outside of the [0, 1] range map to
    // transparent black.
    SpreadNone Spread = iota
    // SpreadPad means that offsets below 0 and above 1 map to the colors that
    // 0 and 1 would map to.
    SpreadPad
    // SpreadReflect means that the offset mapping is reflected start-to-end,
    // end-to-start, start-to-end, etc.
    SpreadReflect
    // SpreadRepeat means that the offset mapping is repeated start-to-end,
    // start-to-end, start-to-end, etc.
    SpreadRepeat
)

func (Spread) Clamp Uses

func (s Spread) Clamp(x float64) float64

Clamp clamps x to the range [0, 1]. If x is outside that range, it is converted to a value in that range according to s's semantics. It returns -1 if s is SpreadNone and x is outside the range [0, 1].

type Stop Uses

type Stop struct {
    Offset float64
    RGBA64 color.RGBA64
}

Stop is an offset and color.

Package gradient imports 4 packages (graph) and is imported by 2 packages. Updated 2017-09-30. Refresh now. Tools for package owners.