adopt RGB and Alpha

This commit is contained in:
faiface 2017-04-10 17:25:56 +02:00
parent 5d82c3cdb9
commit 3e65588e00
8 changed files with 10 additions and 10 deletions

View File

@ -28,7 +28,7 @@ var _ BasicTarget = (*Batch)(nil)
func NewBatch(container Triangles, pic Picture) *Batch { func NewBatch(container Triangles, pic Picture) *Batch {
b := &Batch{cont: Drawer{Triangles: container, Picture: pic}} b := &Batch{cont: Drawer{Triangles: container, Picture: pic}}
b.SetMatrix(IM) b.SetMatrix(IM)
b.SetColorMask(RGBA{1, 1, 1, 1}) b.SetColorMask(Alpha(1))
return b return b
} }
@ -62,7 +62,7 @@ func (b *Batch) SetMatrix(m Matrix) {
// SetColorMask sets a mask color used in the following draws onto the Batch. // SetColorMask sets a mask color used in the following draws onto the Batch.
func (b *Batch) SetColorMask(c color.Color) { func (b *Batch) SetColorMask(c color.Color) {
if c == nil { if c == nil {
b.col = RGBA{1, 1, 1, 1} b.col = Alpha(1)
return return
} }
b.col = ToRGBA(c) b.col = ToRGBA(c)

View File

@ -45,7 +45,7 @@ func (td *TrianglesData) SetLen(len int) {
Color RGBA Color RGBA
Picture Vec Picture Vec
Intensity float64 Intensity float64
}{V(0, 0), RGBA{1, 1, 1, 1}, V(0, 0), 0}) }{V(0, 0), Alpha(1), V(0, 0), 0})
} }
} }
if len < td.Len() { if len < td.Len() {

View File

@ -23,7 +23,7 @@ import (
// //
// Use various methods to change properties of Pushed points: // Use various methods to change properties of Pushed points:
// //
// imd.Color(pixel.RGBA{R: 1, G: 0, B: 0, A: 1}) // imd.Color(pixel.RGB(1, 0, 0))
// imd.Push(pixel.V(200, 200)) // imd.Push(pixel.V(200, 200))
// imd.Circle(400, 0) // imd.Circle(400, 0)
// //
@ -87,7 +87,7 @@ func New(pic pixel.Picture) *IMDraw {
batch: pixel.NewBatch(tri, pic), batch: pixel.NewBatch(tri, pic),
} }
im.SetMatrix(pixel.IM) im.SetMatrix(pixel.IM)
im.SetColorMask(pixel.RGBA{R: 1, G: 1, B: 1, A: 1}) im.SetColorMask(pixel.Alpha(1))
im.Reset() im.Reset()
return im return im
} }

View File

@ -153,7 +153,7 @@ type TargetPicture interface {
// PictureColor specifies Picture with Color property, so that every position inside the Picture's // PictureColor specifies Picture with Color property, so that every position inside the Picture's
// Bounds has a color. // Bounds has a color.
// //
// Positions outside the Picture's Bounds must return full transparent (RGBA{R: 0, G: 0, B: 0, A: 0}). // Positions outside the Picture's Bounds must return full transparent (Alpha(0)).
type PictureColor interface { type PictureColor interface {
Picture Picture
Color(at Vec) RGBA Color(at Vec) RGBA

View File

@ -96,7 +96,7 @@ func (c *Canvas) SetMatrix(m pixel.Matrix) {
// SetColorMask sets a color that every color in triangles or a picture will be multiplied by. // SetColorMask sets a color that every color in triangles or a picture will be multiplied by.
func (c *Canvas) SetColorMask(col color.Color) { func (c *Canvas) SetColorMask(col color.Color) {
rgba := pixel.RGBA{R: 1, G: 1, B: 1, A: 1} rgba := pixel.Alpha(1)
if col != nil { if col != nil {
rgba = pixel.ToRGBA(col) rgba = pixel.ToRGBA(col)
} }

View File

@ -67,7 +67,7 @@ func (gf *GLFrame) Color(at pixel.Vec) pixel.RGBA {
gf.dirty = false gf.dirty = false
} }
if !gf.bounds.Contains(at) { if !gf.bounds.Contains(at) {
return pixel.RGBA{} return pixel.Alpha(0)
} }
bx, by, bw, _ := intBounds(gf.bounds) bx, by, bw, _ := intBounds(gf.bounds)
x, y := int(at.X())-bx, int(at.Y())-by x, y := int(at.X())-bx, int(at.Y())-by

View File

@ -84,7 +84,7 @@ func (gp *glPicture) Texture() *glhf.Texture {
func (gp *glPicture) Color(at pixel.Vec) pixel.RGBA { func (gp *glPicture) Color(at pixel.Vec) pixel.RGBA {
if !gp.bounds.Contains(at) { if !gp.bounds.Contains(at) {
return pixel.RGBA{} return pixel.Alpha(0)
} }
bx, by, bw, _ := intBounds(gp.bounds) bx, by, bw, _ := intBounds(gp.bounds)
x, y := int(at.X())-bx, int(at.Y())-by x, y := int(at.X())-bx, int(at.Y())-by

View File

@ -28,7 +28,7 @@ func NewSprite(pic Picture, frame Rect) *Sprite {
d: Drawer{Triangles: tri}, d: Drawer{Triangles: tri},
} }
s.matrix = IM s.matrix = IM
s.mask = RGBA{1, 1, 1, 1} s.mask = Alpha(1)
s.Set(pic, frame) s.Set(pic, frame)
return s return s
} }