colorutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGradient

func DefaultGradient() render.Gradient

DefaultGradient returns a horizontal black→white gradient.

func FormatGradientString

func FormatGradientString(g render.Gradient) string

FormatGradientString returns the theme-compatible JSON fill string for g, using the most compact form: gradientH/gradientV when applicable, else gradient.

func FormatHex

func FormatHex(c sg.Color) string

FormatHex returns "#RRGGBB" (alpha ignored).

func FormatHexA

func FormatHexA(c sg.Color) string

FormatHexA returns "#RRGGBBAA".

func FromHSL

func FromHSL(h, s, l, a float64) sg.Color

FromHSL converts HSL (all [0,1]) plus alpha to a sg.Color.

func FromHSV

func FromHSV(h, s, v, a float64) sg.Color

FromHSV wraps sg.ColorFromHSV and adds alpha support. All inputs in [0,1].

func FromRGB255

func FromRGB255(r, g, b, a int) sg.Color

FromRGB255 converts 0–255 integers to a sg.Color.

func NormalizeRGB

func NormalizeRGB(c sg.Color) sg.Color

NormalizeRGB clamps R, G, B to [0, 1] for use with standard color-space conversions. Alpha is passed through unchanged. This preserves the hue and saturation ratio of overbright tint colors.

func ParseHex

func ParseHex(s string) (sg.Color, bool)

ParseHex parses "#RRGGBB" or "#RRGGBBAA". Returns ok=false on invalid input.

func SampleBilinear

func SampleBilinear(g render.GradientColors, u, v float64) sg.Color

SampleBilinear returns the bilinearly interpolated color at normalized (u, v) where (0,0)=TopLeft, (1,1)=BottomRight.

func ToHSL

func ToHSL(c sg.Color) (h, s, l, a float64)

ToHSL converts a sg.Color to HSL. All return values are in [0,1].

func ToHSV

func ToHSV(c sg.Color) (h, s, v, a float64)

ToHSV converts a sg.Color to HSV. All return values are in [0,1].

func ToRGB255

func ToRGB255(c sg.Color) (r, g, b, a int)

ToRGB255 converts a sg.Color to 0–255 integer components. Values are clamped to [0, 255].

Types

This section is empty.

Jump to

Keyboard shortcuts

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