mirror of
https://github.com/taigrr/simplecolorpalettes.git
synced 2026-04-01 20:49:11 -07:00
Properly apply modulus to input ints
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const TotalHexColorspace = 0xffffff
|
||||||
|
|
||||||
type (
|
type (
|
||||||
SimpleColor int
|
SimpleColor int
|
||||||
NamedPalette map[string]SimpleColor
|
NamedPalette map[string]SimpleColor
|
||||||
@@ -93,13 +95,13 @@ func (p SimplePalette) ToAnsi16() (sp SimplePalette) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New(color int) SimpleColor {
|
func New(color int) SimpleColor {
|
||||||
return SimpleColor(color)
|
return SimpleColor(color % TotalHexColorspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromRGBA(r, g, b, _ uint32) SimpleColor {
|
func FromRGBA(r, g, b, _ uint32) SimpleColor {
|
||||||
c := r
|
c := r % TotalHexColorspace
|
||||||
c = c<<8 + g
|
c = c<<8 + (g % TotalHexColorspace)
|
||||||
c = c<<8 + b
|
c = c<<8 + (b % TotalHexColorspace)
|
||||||
return SimpleColor(c)
|
return SimpleColor(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user