color

package
v0.0.0-...-ec9fd1c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2012 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package color provides abstracted color.

This interface specifically differs from the image.Color interfaces because the render uses floating point math. Also, colors in this package are not clamped to [0, 1], they are clamped to [0, Inf).

Index

Constants

This section is empty.

Variables

View Source
var Model color.Model = color.ModelFunc(toGorayColor)

Model is the color model for the renderer.

Functions

func Energy

func Energy(c Color) float64

Energy calculates the overall brightness of a color.

func IsBlack

func IsBlack(c Color) bool

IsBlack determines whether a color is absolute black.

Types

type Alpha

type Alpha interface {
	Alpha() float64
}

Alpha defines anything that has an alpha channel.

type AlphaColor

type AlphaColor interface {
	Color
	Alpha
}

AlphaColor defines anything that has red, green, blue, and alpha channels.

func AddAlpha

func AddAlpha(c1, c2 AlphaColor) AlphaColor

AddAlpha creates a new color that is equivalent to the sum of the colors given to it.

func MixAlpha

func MixAlpha(a, b AlphaColor, point float64) AlphaColor

MixAlpha creates a new color that is the additive mix of the two colors, using alpha to influence the mixing.

func MulAlpha

func MulAlpha(c1, c2 AlphaColor) AlphaColor

MulAlpha creates a new color that is equivalent to the product of the colors given to it.

func ScalarDivAlpha

func ScalarDivAlpha(c AlphaColor, f float64) AlphaColor

ScalarDivAlpha creates a new color that is equivalent to the color divided by a constant factor.

func ScalarMulAlpha

func ScalarMulAlpha(c AlphaColor, f float64) AlphaColor

ScalarMulAlpha creates a new color that is equivalent to the color multiplied by a constant factor.

func SubAlpha

func SubAlpha(c1, c2 AlphaColor) AlphaColor

SubAlpha creates a new color that is equivalent to the difference of the colors given to it.

type Color

type Color interface {
	Red() float64
	Green() float64
	Blue() float64
}

Color defines anything that has red, green, and blue channels.

var (
	Black Color = Gray(0)
	White Color = Gray(1)

	Red   Color = RGB{1, 0, 0}
	Green Color = RGB{0, 1, 0}
	Blue  Color = RGB{0, 0, 1}

	Cyan    Color = RGB{0, 1, 1}
	Yellow  Color = RGB{1, 1, 0}
	Magenta Color = RGB{1, 0, 1}
)

Predefined colors

func Abs

func Abs(c Color) Color

Abs ensures that a color is positive.

func Add

func Add(c1, c2 Color) Color

Add creates a new color that is equivalent to the sum of the colors given to it, disregarding alpha information.

func Invert

func Invert(c Color) Color

Invert computes the inverse of the color. However, black will always be black.

func Mix

func Mix(a, b Color, point float64) Color

Mix creates a new color that is the additive mix of the two colors, disregarding alpha information.

func Mul

func Mul(c1, c2 Color) Color

Mul creates a new color that is equivalent to the product of the colors given to it, disregarding alpha information.

func ScalarDiv

func ScalarDiv(c Color, f float64) Color

ScalarDiv creates a new color that is equivalent to the color divided by a constant factor, disregarding alpha information.

func ScalarMul

func ScalarMul(c Color, f float64) Color

ScalarMul creates a new color that is equivalent to the color multiplied by a constant factor, disregarding alpha information.

func Sub

func Sub(c1, c2 Color) Color

Sub creates a new color that is equivalent to the difference of the colors given to it, disregarding alpha information.

type Gray

type Gray float64

Gray defines a grayscale color. It fulfills the Color interface.

func (Gray) Blue

func (g Gray) Blue() float64

func (Gray) GoString

func (g Gray) GoString() string

func (Gray) Green

func (g Gray) Green() float64

func (Gray) RGBA

func (col Gray) RGBA() (r, g, b, a uint32)

func (Gray) Red

func (g Gray) Red() float64

func (Gray) String

func (g Gray) String() string

type RGB

type RGB struct {
	R, G, B float64
}

RGB defines a color that has red, green, and blue channels. It fulfills the Color interface.

func DiscardAlpha

func DiscardAlpha(c Color) RGB

DiscardAlpha returns a new RGB with the red, green, and blue components of another color.

func (RGB) Blue

func (c RGB) Blue() float64

func (*RGB) Copy

func (c *RGB) Copy(src Color)

func (RGB) GoString

func (c RGB) GoString() string

func (RGB) Green

func (c RGB) Green() float64

func (RGB) RGBA

func (c RGB) RGBA() (r, g, b, a uint32)

func (RGB) Red

func (c RGB) Red() float64

func (RGB) String

func (c RGB) String() string

type RGBA

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

RGBA defines a color with red, green, blue, and alpha channels. It fulfills the AlphaColor interface.

func NewRGBAFromColor

func NewRGBAFromColor(c Color, a float64) RGBA

NewRGBAFromColor creates an RGBA value from a color and an alpha value.

func (RGBA) Alpha

func (c RGBA) Alpha() float64

func (RGBA) AlphaPremultiply

func (c RGBA) AlphaPremultiply() RGBA

AlphaPremultiply multiplies the color channels by the alpha channel and then returns the resulting color.

func (RGBA) Blue

func (c RGBA) Blue() float64

func (*RGBA) Copy

func (c *RGBA) Copy(src AlphaColor)

func (RGBA) GoString

func (c RGBA) GoString() string

func (RGBA) Green

func (c RGBA) Green() float64

func (RGBA) RGBA

func (c1 RGBA) RGBA() (r, g, b, a uint32)

func (RGBA) Red

func (c RGBA) Red() float64

func (RGBA) String

func (c RGBA) String() string

Jump to

Keyboard shortcuts

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