f32color

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: MIT, Unlicense Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Disabled

func Disabled(c color.NRGBA) (d color.NRGBA)

Disabled blends color towards the luminance and multiplies alpha. Blending towards luminance will desaturate the color. Multiplying alpha blends the color together more with the background.

func Hovered

func Hovered(c color.NRGBA) (d color.NRGBA)

Hovered blends color towards a brighter color.

func MulAlpha

func MulAlpha(c color.NRGBA, alpha uint8) color.NRGBA

MulAlpha applies the alpha to the color.

func NRGBAToLinearRGBA

func NRGBAToLinearRGBA(col color.NRGBA) color.RGBA

NRGBAToLinearRGBA converts from non-premultiplied sRGB color to premultiplied linear RGBA color.

Each component in the result is `c * alpha`, where `c` is the linear color.

func NRGBAToRGBA

func NRGBAToRGBA(col color.NRGBA) color.RGBA

NRGBAToRGBA converts from non-premultiplied sRGB color to premultiplied sRGB color.

Each component in the result is `sRGBToLinear(c * alpha)`, where `c` is the linear color.

func RGBAToNRGBA

func RGBAToNRGBA(col color.RGBA) color.NRGBA

RGBAToNRGBA converts from premultiplied sRGB color to non-premultiplied sRGB color.

Types

type RGBA

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

RGBA is a 32 bit floating point linear premultiplied color space.

func LinearFromSRGB

func LinearFromSRGB(col color.NRGBA) RGBA

LinearFromSRGB converts from col in the sRGB colorspace to RGBA.

func (RGBA) Array

func (rgba RGBA) Array() [4]float32

Array returns rgba values in a [4]float32 array.

func (RGBA) Float32

func (col RGBA) Float32() (r, g, b, a float32)

Float32 returns r, g, b, a values.

func (RGBA) Luminance

func (col RGBA) Luminance() float32

Luminance calculates the relative luminance of a linear RGBA color. Normalized to 0 for black and 1 for white.

See https://www.w3.org/TR/WCAG20/#relativeluminancedef for more details

func (RGBA) Opaque

func (col RGBA) Opaque() RGBA

Opaque returns the color without alpha component.

func (RGBA) SRGB

func (col RGBA) SRGB() color.NRGBA

SRGBA converts from linear to sRGB color space.

Jump to

Keyboard shortcuts

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