adopt RGB and Alpha
This commit is contained in:
parent
5d82c3cdb9
commit
3e65588e00
4
batch.go
4
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)
|
||||
|
|
2
data.go
2
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() {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue