From 3e65588e0030b9f7ad3e8c29de5d75c2807dd7d5 Mon Sep 17 00:00:00 2001 From: faiface Date: Mon, 10 Apr 2017 17:25:56 +0200 Subject: [PATCH] adopt RGB and Alpha --- batch.go | 4 ++-- data.go | 2 +- imdraw/imdraw.go | 4 ++-- interface.go | 2 +- pixelgl/canvas.go | 2 +- pixelgl/glframe.go | 2 +- pixelgl/glpicture.go | 2 +- sprite.go | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/batch.go b/batch.go index 452f17e..9618df0 100644 --- a/batch.go +++ b/batch.go @@ -28,7 +28,7 @@ var _ BasicTarget = (*Batch)(nil) func NewBatch(container Triangles, pic Picture) *Batch { b := &Batch{cont: Drawer{Triangles: container, Picture: pic}} b.SetMatrix(IM) - b.SetColorMask(RGBA{1, 1, 1, 1}) + b.SetColorMask(Alpha(1)) 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. func (b *Batch) SetColorMask(c color.Color) { if c == nil { - b.col = RGBA{1, 1, 1, 1} + b.col = Alpha(1) return } b.col = ToRGBA(c) diff --git a/data.go b/data.go index 7d21d49..186ee35 100644 --- a/data.go +++ b/data.go @@ -45,7 +45,7 @@ func (td *TrianglesData) SetLen(len int) { Color RGBA Picture Vec 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() { diff --git a/imdraw/imdraw.go b/imdraw/imdraw.go index 98e9325..c464aab 100644 --- a/imdraw/imdraw.go +++ b/imdraw/imdraw.go @@ -23,7 +23,7 @@ import ( // // 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.Circle(400, 0) // @@ -87,7 +87,7 @@ func New(pic pixel.Picture) *IMDraw { batch: pixel.NewBatch(tri, pic), } im.SetMatrix(pixel.IM) - im.SetColorMask(pixel.RGBA{R: 1, G: 1, B: 1, A: 1}) + im.SetColorMask(pixel.Alpha(1)) im.Reset() return im } diff --git a/interface.go b/interface.go index d92d460..c5cb597 100644 --- a/interface.go +++ b/interface.go @@ -153,7 +153,7 @@ type TargetPicture interface { // PictureColor specifies Picture with Color property, so that every position inside the Picture's // 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 { Picture Color(at Vec) RGBA diff --git a/pixelgl/canvas.go b/pixelgl/canvas.go index df71f6d..89521ca 100644 --- a/pixelgl/canvas.go +++ b/pixelgl/canvas.go @@ -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. 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 { rgba = pixel.ToRGBA(col) } diff --git a/pixelgl/glframe.go b/pixelgl/glframe.go index a525b81..790fe5c 100644 --- a/pixelgl/glframe.go +++ b/pixelgl/glframe.go @@ -67,7 +67,7 @@ func (gf *GLFrame) Color(at pixel.Vec) pixel.RGBA { gf.dirty = false } if !gf.bounds.Contains(at) { - return pixel.RGBA{} + return pixel.Alpha(0) } bx, by, bw, _ := intBounds(gf.bounds) x, y := int(at.X())-bx, int(at.Y())-by diff --git a/pixelgl/glpicture.go b/pixelgl/glpicture.go index b5793ec..c249b60 100644 --- a/pixelgl/glpicture.go +++ b/pixelgl/glpicture.go @@ -84,7 +84,7 @@ func (gp *glPicture) Texture() *glhf.Texture { func (gp *glPicture) Color(at pixel.Vec) pixel.RGBA { if !gp.bounds.Contains(at) { - return pixel.RGBA{} + return pixel.Alpha(0) } bx, by, bw, _ := intBounds(gp.bounds) x, y := int(at.X())-bx, int(at.Y())-by diff --git a/sprite.go b/sprite.go index c438663..37305a8 100644 --- a/sprite.go +++ b/sprite.go @@ -28,7 +28,7 @@ func NewSprite(pic Picture, frame Rect) *Sprite { d: Drawer{Triangles: tri}, } s.matrix = IM - s.mask = RGBA{1, 1, 1, 1} + s.mask = Alpha(1) s.Set(pic, frame) return s }