Documentation
¶
Overview ¶
Package appearance provides value objects related to appearance information.
Package appearance provides value objects related to appearance information.
This package contains value objects that represent visual appearance attributes such as colors, styles, and other visual properties. These value objects are immutable and follow the Value Object pattern from Domain-Driven Design.
Key value objects in this package:
- Color: Represents a color in hexadecimal format (#RRGGBB)
The Color value object provides methods for:
- Creating and validating colors in hexadecimal format
- Converting between different color formats
- Extracting RGB components
- Adding alpha channel information
- Determining if a color is dark or light
- Inverting colors
Example usage:
// Create a new color
color, err := appearance.NewColor("#FF5500")
if err != nil {
// Handle validation 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
invertedColor, err := color.Invert()
if err != nil {
// Handle error
}
All value objects in this package are designed to be immutable, so they cannot be changed after creation. To modify a value object, create a new instance with the desired values.
Index ¶
- type Color
- func (c Color) Equals(other Color) bool
- func (c Color) Invert() (Color, error)
- func (c Color) IsDark() (bool, error)
- func (c Color) IsEmpty() bool
- func (c Color) RGB() (r, g, b int, err error)
- func (c Color) String() string
- func (c Color) Validate() error
- func (c Color) WithAlpha(alpha int) (string, error)
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)