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 ¶
- Variables
- func Energy(c Color) float64
- func IsBlack(c Color) bool
- type Alpha
- type AlphaColor
- func AddAlpha(c1, c2 AlphaColor) AlphaColor
- func MixAlpha(a, b AlphaColor, point float64) AlphaColor
- func MulAlpha(c1, c2 AlphaColor) AlphaColor
- func ScalarDivAlpha(c AlphaColor, f float64) AlphaColor
- func ScalarMulAlpha(c AlphaColor, f float64) AlphaColor
- func SubAlpha(c1, c2 AlphaColor) AlphaColor
- type Color
- type Gray
- type RGB
- type RGBA
Constants ¶
This section is empty.
Variables ¶
var Model color.Model = color.ModelFunc(toGorayColor)
Model is the color model for the renderer.
Functions ¶
Types ¶
type Alpha ¶
type Alpha interface {
Alpha() float64
}
Alpha defines anything that has an alpha channel.
type AlphaColor ¶
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 ¶
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 Add ¶
Add creates a new color that is equivalent to the sum of the colors given to it, disregarding alpha information.
func Mix ¶
Mix creates a new color that is the additive mix of the two colors, disregarding alpha information.
func Mul ¶
Mul creates a new color that is equivalent to the product of the colors given to it, disregarding alpha information.
func ScalarDiv ¶
ScalarDiv creates a new color that is equivalent to the color divided by a constant factor, disregarding alpha information.
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 ¶
DiscardAlpha returns a new RGB with the red, green, and blue components of another color.
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 ¶
NewRGBAFromColor creates an RGBA value from a color and an alpha value.
func (RGBA) AlphaPremultiply ¶
AlphaPremultiply multiplies the color channels by the alpha channel and then returns the resulting color.
func (*RGBA) Copy ¶
func (c *RGBA) Copy(src AlphaColor)