iro

package
v0.0.0-...-414057b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2020 License: Unlicense Imports: 2 Imported by: 0

Documentation

Overview

Package iro provides color interpolation functionality for multiple color spaces and convertions between them.

Index

Constants

This section is empty.

Variables

View Source
var Viridis = []Color{}/* 256 elements not displayed */

This function creates a vector of n equally spaced colors along the Matplolib 'viridis' color map created by Stéfan van der Walt and Nathaniel Smith. This color map is designed in such a way that it will analytically be perfectly perceptually-uniform, both in regular form and also when converted to black-and-white. It is also designed to be perceived by readers with the most common form of color blindness.

Functions

This section is empty.

Types

type Color

type Color interface {
	// Interpolation methods.
	Lerp(Color, float64) Color

	// Color model convertion methods.
	HSV() HSV
	RGB() (float64, float64, float64)
	RGBA() RGBA
	StandardRGBA() color.RGBA
}

Color should be able to interpolate between another color and convert to other color models.

func ToColors

func ToColors(rgbas []RGBA) []Color

type Gradient

type Gradient struct {
	Colors []Color
	Stops  []float64
	Base   Color
	// contains filtered or unexported fields
}

Gradient contains colors and interpolation points to allow for non-uniform gradients. Also uses a base color for interpolations outside the gradient range.

func NewGradient

func NewGradient(colors []Color, stops []float64, base Color, granularity int) (g Gradient)

NewGradient creates a new gradient from colors, stop points and a base color. Granularity controls the number of interpolated colors to pre-calculate.

func (Gradient) Len

func (g Gradient) Len() int

Len returns the length of the gradient.

func (Gradient) Lookup

func (g Gradient) Lookup(t float64) Color

Lookup returns an interpolated color from the gradient. The value t should be inside the range of the gradient, if it isn't the base color will be used.

type HSV

type HSV struct {
	H, S, V, A float64
}

HSV color model for more intuitive color manipulation and more aesthetic color interpolations.

func (HSV) HSV

func (c HSV) HSV() HSV

HSV converts the color to HSV.

func (HSV) Lerp

func (a HSV) Lerp(blend Color, t float64) Color

Lerp interpolates between the two colors in the HSV color space. The shortest angle between the two colors in the HSV color space will be used.

Note: calling order matters for alpha interpolation.

func (HSV) RGB

func (c HSV) RGB() (float64, float64, float64)

RGB returns the R, G, B color values of the color.

func (HSV) RGBA

func (col HSV) RGBA() RGBA

RGBA converts the color to RGBA.

func (HSV) StandardRGBA

func (c HSV) StandardRGBA() color.RGBA

StandardRGBA returns a standard library version of the color.

type RGBA

type RGBA struct {
	R, G, B, A float64
}

RGBA is float color representation for easier interpolation and gradient creation.

func (RGBA) HSV

func (c RGBA) HSV() HSV

HSV converts to the HSV color space.

func (RGBA) Lerp

func (a RGBA) Lerp(blend Color, t float64) Color

Lerp interpolates between the two colors in the RGB color space.

Note: calling order matters for alpha interpolation.

func (RGBA) RGB

func (c RGBA) RGB() (float64, float64, float64)

RGB returns the R, G, B color values of the color.

func (RGBA) RGBA

func (c RGBA) RGBA() RGBA

RGBA converts the color to RGBA.

func (RGBA) StandardRGBA

func (c RGBA) StandardRGBA() color.RGBA

StandardRGBA returns a standard library version of the color.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL