color

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Erweiterung des Packages 'image/color' um neue Farbtypen.

Dieses Package versteht sich als Erweiterung von 'image/color' in Zusammenhang mit dem Package 'gg'.

Im Wesentlichen Die bestehende Implementation von Farben in 'image/color' bietet keine Methoden, um Farben heller, resp. dunkler zu schattieren oder um zwischen zwei beliebigen Farben eine lineare Interpolation durchzuführen. Die in diesem Package definierten Farben implementieren alle das Interface 'Color' aus 'image/color'. Der Name des Packages und die

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Black       = RGBAF{0.0, 0.0, 0.0, 1.0}
	White       = RGBAF{1.0, 1.0, 1.0, 1.0}
	Transparent = RGBAF{0.0, 0.0, 0.0, 0.0}
	Opaque      = RGBAF{1.0, 1.0, 1.0, 1.0}
)

Da dieses Package anstelle von 'image/color' verwendet werden kann, sind einige Standardfarben auch hier definiert.

View Source
var (
	HSIModel color.Model = color.ModelFunc(hsiModel)
)

Modell fuer den neuen Farbtyp, d.h. fuer die Konvertierung von einer beliebigen Farbe nach HSI.

View Source
var (
	HSLModel color.Model = color.ModelFunc(hslModel)
)

Modell fuer den neuen Farbtyp, d.h. fuer die Konvertierung von einer beliebigen Farbe nach HSL.

View Source
var (
	HSPModel color.Model = color.ModelFunc(hspModel)
)

Modell fuer den neuen Farbtyp, d.h. fuer die Konvertierung von einer beliebigen Farbe nach HSP.

View Source
var (
	HSVModel color.Model = color.ModelFunc(hsvModel)
)

Modell fuer den neuen Farbtyp, d.h. fuer die Konvertierung von einer beliebigen Farbe nach HSV.

View Source
var (
	RGBAFModel color.Model = color.ModelFunc(rgbafModel)
)

Modell fuer den neuen Farbtyp, d.h. fuer die Konvertierung von einer beliebigen Farbe nach RGBAF.

Functions

This section is empty.

Types

type Color

type Color interface {
	color.Color
	Bright(t float64) Color
	Dark(t float64) Color
	Alpha(a float64) Color
	Interpolate(c2 Color, t float64) Color
}

Das Interface Color basiert auf dem gleichnamigen Interface der Standard-Bibliothek, verlangt jedoch Methoden, um eine Farbe aufzuhellen, resp. abzudunkeln, den Alpha-Wert als Fliesskommazahl in [0,1] direkt anzugeben und um zwischen zwei Farben eine lineare Interpolation durchzuführen.

type HSI

type HSI struct {
	H, S, I, A float64
}

Der Typ HSI enthaelt die Werte fuer Hue, Saturation und Intensity gespeichert.

Example
h1, s1, i1 := 0.0, 0.5, 0.1
c1 := HSI{h1, s1, i1, 1.0}
fmt.Printf("%v", c1)
Output:

{0 0.5 0.1 1}

func (HSI) Alpha

func (c HSI) Alpha(a float64) Color

func (HSI) Bright

func (c HSI) Bright(t float64) Color

func (HSI) Dark

func (c HSI) Dark(t float64) Color

func (HSI) Interpolate

func (c1 HSI) Interpolate(col Color, t float64) Color

func (HSI) Less

func (c1 HSI) Less(c2 HSI, key SortField) bool

func (HSI) RGBA

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

type HSL

type HSL struct {
	H, S, L, A float64
}

Der Typ HSL schliesslich enthaelt die Werte fuer Hue, Saturation und Lightness gespeichert.

Example
h1, s1, l1 := 0.0, 1.0, 0.5
c1 := HSL{h1, s1, l1, 1.0}
fmt.Printf("%v", c1)
Output:

{0 1 0.5 1}

func (HSL) Alpha

func (c HSL) Alpha(a float64) Color

func (HSL) Bright

func (c HSL) Bright(t float64) Color

func (HSL) Dark

func (c HSL) Dark(t float64) Color

func (HSL) Interpolate

func (c1 HSL) Interpolate(col Color, t float64) Color

func (HSL) Less

func (c1 HSL) Less(c2 HSL, key SortField) bool

func (HSL) RGBA

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

type HSP added in v1.1.0

type HSP struct {
	H, S, P, A float64
}
Example
h1, s1, p1 := 0.0, 1.0, 1.0
c1 := HSP{h1, s1, p1, 1.0}
fmt.Printf("%v", c1)
Output:

{0 1 1 1}

func (HSP) Alpha added in v1.1.0

func (c HSP) Alpha(a float64) Color

func (HSP) Bright added in v1.1.0

func (c HSP) Bright(t float64) Color

func (HSP) Dark added in v1.1.0

func (c HSP) Dark(t float64) Color

func (HSP) Interpolate added in v1.1.0

func (c1 HSP) Interpolate(col Color, t float64) Color

func (HSP) RGBA added in v1.1.0

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

type HSV

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

Beim Typ HSV werden die Werte fuer Hue, Saturation und Value gespeichert.

Example
h1, s1, v1 := 0.0, 1.0, 1.0
c1 := HSV{h1, s1, v1, 1.0}
fmt.Printf("%v", c1)
Output:

{0 1 1 1}

func (HSV) Alpha

func (c HSV) Alpha(a float64) Color

func (HSV) Bright

func (c HSV) Bright(t float64) Color

func (HSV) Dark

func (c HSV) Dark(t float64) Color

func (HSV) Interpolate

func (c1 HSV) Interpolate(col Color, t float64) Color

func (HSV) Less

func (c1 HSV) Less(c2 HSV, key SortField) bool

func (HSV) RGBA

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

type RGBAF

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

RGBAF entspricht dem NRGBA-Typ aus image/color, verwendet fuer die einzelnen Komponenten jedoch Fliesskommazahlen im Intervall [0,1]. Beachte: Der Typ in diesem Package heisst RGBA, die Werte R, G, B und A werden jedoch als _nicht_ normierte Werte interpretiert, meine praktischen Erfahrungen haben gezeigt, dass dies intuitiver ist.

Example
r1, g1, b1 := 1.0, 0.5, 0.25
c1 := RGBAF{r1, g1, b1, 1.0}
fmt.Printf("%v", c1)
Output:

{1 0.5 0.25 1}

func (RGBAF) Alpha

func (c RGBAF) Alpha(a float64) Color

func (RGBAF) Bright

func (c RGBAF) Bright(t float64) Color

func (RGBAF) Dark

func (c RGBAF) Dark(t float64) Color

func (RGBAF) Interpolate

func (c1 RGBAF) Interpolate(col Color, t float64) Color

func (RGBAF) Less

func (c1 RGBAF) Less(c2 RGBAF, key SortField) bool

func (RGBAF) RGBA

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

type SortField

type SortField int
const (
	SortByHue SortField = iota
	SortBySaturation
	SortByValue
	SortByLightness
	SortByIntensity
	SortByRed
	SortByGreen
	SortByBlue
)

func (SortField) String

func (f SortField) String() string

Jump to

Keyboard shortcuts

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