diff --git a/image.go b/image.go index ee3c63d18..93fbf9619 100644 --- a/image.go +++ b/image.go @@ -23,6 +23,7 @@ import ( "github.com/hajimehoshi/ebiten/internal/ui" "image" "image/color" + "math" ) // Image represents an image. @@ -47,7 +48,13 @@ func (i *Image) Clear() (err error) { // Fill fills the image with a solid color. func (i *Image) Fill(clr color.Color) (err error) { i.pixels = nil - r, g, b, a := internal.RGBA(clr) + //r, g, b, a := internal.RGBA(clr) + cr, cg, cb, ca := clr.RGBA() + const max = math.MaxUint16 + r := float64(cr) / max + g := float64(cg) / max + b := float64(cb) / max + a := float64(ca) / max ui.Use(func(c *opengl.Context) { // TODO: Change to pass color.Color err = i.framebuffer.Fill(c, r, g, b, a) diff --git a/internal/math.go b/internal/math.go index 8e71578a4..8dbcd4cf9 100644 --- a/internal/math.go +++ b/internal/math.go @@ -14,11 +14,6 @@ package internal -import ( - "image/color" - "math" -) - func NextPowerOf2Int(x int) int { x -= 1 x |= (x >> 1) @@ -28,13 +23,3 @@ func NextPowerOf2Int(x int) int { x |= (x >> 16) return x + 1 } - -func RGBA(clr color.Color) (r, g, b, a float64) { - cr, cg, cb, ca := clr.RGBA() - const max = math.MaxUint16 - r = float64(cr) / max - g = float64(cg) / max - b = float64(cb) / max - a = float64(ca) / max - return -}