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