Skip to content

Commit

Permalink
feat(color): add helper methods for creating HSV and RGB colors
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Sep 21, 2024
1 parent 925bff2 commit 1488dc3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions exp/color/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ type Color struct {
v color.RGBA
}

// NewColorFromRGB creates a new color from RGB values.
func NewColorFromRGB(r, g, b uint8) Color {
return Color{color.RGBA{r, g, b, 255}}
}

func NewColorFromHSV(h, s, v float64) Color {
return Color{HSVToRGBA(h, s, v)}
}

// RGBA returns the RGBA values of the color.
func (c Color) RGBA() (r, g, b, a uint32) {
return c.v.RGBA()
Expand Down

0 comments on commit 1488dc3

Please sign in to comment.