Remove internal.RGBA

This commit is contained in:
Hajime Hoshi 2015-01-24 01:45:46 +09:00
parent 28983e4e24
commit b57c675996
2 changed files with 8 additions and 16 deletions

View File

@ -23,6 +23,7 @@ import (
"github.com/hajimehoshi/ebiten/internal/ui" "github.com/hajimehoshi/ebiten/internal/ui"
"image" "image"
"image/color" "image/color"
"math"
) )
// Image represents an image. // Image represents an image.
@ -47,7 +48,13 @@ func (i *Image) Clear() (err error) {
// Fill fills the image with a solid color. // Fill fills the image with a solid color.
func (i *Image) Fill(clr color.Color) (err error) { func (i *Image) Fill(clr color.Color) (err error) {
i.pixels = nil 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) { ui.Use(func(c *opengl.Context) {
// TODO: Change to pass color.Color // TODO: Change to pass color.Color
err = i.framebuffer.Fill(c, r, g, b, a) err = i.framebuffer.Fill(c, r, g, b, a)

View File

@ -14,11 +14,6 @@
package internal package internal
import (
"image/color"
"math"
)
func NextPowerOf2Int(x int) int { func NextPowerOf2Int(x int) int {
x -= 1 x -= 1
x |= (x >> 1) x |= (x >> 1)
@ -28,13 +23,3 @@ func NextPowerOf2Int(x int) int {
x |= (x >> 16) x |= (x >> 16)
return x + 1 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
}