appearance

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 6 Imported by: 0

README

Appearance Value Objects

This package contains value objects related to visual appearance and styling.

Value Objects

Color

The Color value object represents a color in hexadecimal format (#RRGGBB). It provides methods for:

  • Converting to RGB components
  • Adding an alpha channel
  • Determining if a color is dark
  • Inverting a color

Usage

// Create a new color
color, err := appearance.NewColor("#FF5733")
if err != nil {
    // Handle error
}

// Get RGB components
r, g, b, err := color.RGB()
if err != nil {
    // Handle error
}

// Check if color is dark
isDark, err := color.IsDark()
if err != nil {
    // Handle error
}

// Invert the color
inverted, err := color.Invert()
if err != nil {
    // Handle error
}

// Add alpha channel
colorWithAlpha, err := color.WithAlpha(128) // 50% opacity
if err != nil {
    // Handle error
}

Documentation

Overview

Package appearance provides value objects related to appearance information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color string

Color represents a color value object in hexadecimal format (#RRGGBB)

func NewColor

func NewColor(hexColor string) (Color, error)

NewColor creates a new Color with validation

func (Color) Equals

func (c Color) Equals(other Color) bool

Equals checks if two Colors are equal (case insensitive)

func (Color) Invert

func (c Color) Invert() (Color, error)

Invert returns the inverted color

func (Color) IsDark

func (c Color) IsDark() (bool, error)

IsDark returns true if the color is considered dark

func (Color) IsEmpty

func (c Color) IsEmpty() bool

IsEmpty checks if the Color is empty

func (Color) RGB

func (c Color) RGB() (r, g, b int, err error)

RGB returns the RGB components of the color

func (Color) String

func (c Color) String() string

String returns the string representation of the Color

func (Color) Validate

func (c Color) Validate() error

Validate checks if the Color is valid

func (Color) WithAlpha

func (c Color) WithAlpha(alpha int) (string, error)

WithAlpha returns a new color with the specified alpha component (0-255)

Jump to

Keyboard shortcuts

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