style

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ColorTransparent is a fully transparent color.
	ColorTransparent = Color{R: 255, G: 255, B: 255, A: 0}
	// ColorWhite is white.
	ColorWhite = Color{R: 255, G: 255, B: 255, A: 255}
	// ColorBlack is black.
	ColorBlack = Color{R: 0, G: 0, B: 0, A: 255}
	// ColorRed is red.
	ColorRed = Color{R: 255, G: 0, B: 0, A: 255}
	// ColorGreen is green.
	ColorGreen = Color{R: 0, G: 128, B: 0, A: 255}
	// ColorBlue is blue.
	ColorBlue = Color{R: 0, G: 0, B: 255, A: 255}
	// ColorSilver is a known color.
	ColorSilver = Color{R: 192, G: 192, B: 192, A: 255}
	// ColorMaroon is a known color.
	ColorMaroon = Color{R: 128, G: 0, B: 0, A: 255}
	// ColorPurple is a known color.
	ColorPurple = Color{R: 128, G: 0, B: 128, A: 255}
	// ColorFuchsia is a known color.
	ColorFuchsia = Color{R: 255, G: 0, B: 255, A: 255}
	// ColorLime is a known color.
	ColorLime = Color{R: 0, G: 255, B: 0, A: 255}
	// ColorOlive is a known color.
	ColorOlive = Color{R: 128, G: 128, B: 0, A: 255}
	// ColorYellow is a known color.
	ColorYellow = Color{R: 255, G: 255, B: 0, A: 255}
	// ColorNavy is a known color.
	ColorNavy = Color{R: 0, G: 0, B: 128, A: 255}
	// ColorTeal is a known color.
	ColorTeal = Color{R: 0, G: 128, B: 128, A: 255}
	// ColorAqua is a known color.
	ColorAqua = Color{R: 0, G: 255, B: 255, A: 255}
)

Basic Colors from: https://www.w3.org/wiki/CSS/Properties/color/keywords

Functions

func ColorChannelFromFloat

func ColorChannelFromFloat(v float64) uint8

ColorChannelFromFloat returns a normalized byte from a given float value.

Types

type Color

type Color struct {
	R, G, B, A uint8
}

Color is our internal color type because style.Color is bullshit.

func ColorFromAlphaMixedRGBA

func ColorFromAlphaMixedRGBA(r, g, b, a uint32) Color

ColorFromAlphaMixedRGBA returns the system alpha mixed rgba values.

func ColorFromHex

func ColorFromHex(hex string) Color

ColorFromHex returns a color from a css hex code.

NOTE: it will trim a leading '#' character if present.

func ColorFromKnown

func ColorFromKnown(known string) Color

ColorFromKnown returns an internal color from a known (basic) color name.

func ColorFromRGB

func ColorFromRGB(rgb string) (output Color)

ColorFromRGB returns a color from an `rgb()` css function.

func ColorFromRGBA

func ColorFromRGBA(rgba string) (output Color)

ColorFromRGBA returns a color from an `rgba()` css function.

func ParseColor

func ParseColor(rawColor string) Color

ParseColor parses a color from a string.

func (Color) AverageWith

func (c Color) AverageWith(other Color) Color

AverageWith averages two colors.

func (Color) Equals

func (c Color) Equals(other Color) bool

Equals returns true if the color equals another.

func (Color) IsTransparent

func (c Color) IsTransparent() bool

IsTransparent returns if the colors alpha channel is zero.

func (Color) IsZero

func (c Color) IsZero() bool

IsZero returns if the color has been set or not.

func (Color) RGBA

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

RGBA returns the color as a pre-alpha mixed color set.

func (Color) String

func (c Color) String() string

String returns a css string representation of the color in hexadecimal format (#RRGGBB).

func (Color) WithAlpha

func (c Color) WithAlpha(a uint8) Color

WithAlpha returns a copy of the color with a given alpha.

Jump to

Keyboard shortcuts

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