use Color from image/color
This commit is contained in:
parent
58e2d01435
commit
5e909b3f88
|
@ -0,0 +1,13 @@
|
||||||
|
package pixel
|
||||||
|
|
||||||
|
import "image/color"
|
||||||
|
|
||||||
|
// colorToRGBA converts a color from image/color to RGBA components in interval [0, 1)
|
||||||
|
func colorToRGBA(c color.Color) (r, g, b, a float64) {
|
||||||
|
ri, gi, bi, ai := c.RGBA()
|
||||||
|
r = float64(ri) / 0xffff
|
||||||
|
g = float64(gi) / 0xffff
|
||||||
|
b = float64(bi) / 0xffff
|
||||||
|
a = float64(ai) / 0xffff
|
||||||
|
return
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package pixel
|
package pixel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"image/color"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/faiface/pixel/pixelgl"
|
"github.com/faiface/pixel/pixelgl"
|
||||||
|
@ -73,9 +74,9 @@ func NewWindow(config WindowConfig) (*Window, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear clears the window with a color.
|
// Clear clears the window with a color.
|
||||||
func (w *Window) Clear(r, g, b, a float64) {
|
func (w *Window) Clear(c color.Color) {
|
||||||
w.Begin()
|
w.Begin()
|
||||||
pixelgl.Clear(r, g, b, a)
|
pixelgl.Clear(colorToRGBA(c))
|
||||||
w.End()
|
w.End()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue