adopt new ToNRGBA function
This commit is contained in:
parent
6eeff66728
commit
379b4df667
2
batch.go
2
batch.go
|
@ -66,7 +66,7 @@ func (b *Batch) SetColorMask(c color.Color) {
|
|||
b.col = NRGBA{1, 1, 1, 1}
|
||||
return
|
||||
}
|
||||
b.col = NRGBAModel.Convert(c).(NRGBA)
|
||||
b.col = ToNRGBA(c)
|
||||
}
|
||||
|
||||
// MakeTriangles returns a specialized copy of the provided Triangles that draws onto this Batch.
|
||||
|
|
10
data.go
10
data.go
|
@ -284,7 +284,7 @@ func (pd *PictureData) Color(at Vec) NRGBA {
|
|||
if !pd.Rect.Contains(at) {
|
||||
return NRGBA{0, 0, 0, 0}
|
||||
}
|
||||
return NRGBAModel.Convert(pd.Pix[pd.Index(at)]).(NRGBA)
|
||||
return ToNRGBA(pd.Pix[pd.Index(at)])
|
||||
}
|
||||
|
||||
// SetColor changes the color located at the given position.
|
||||
|
@ -292,5 +292,11 @@ func (pd *PictureData) SetColor(at Vec, col color.Color) {
|
|||
if !pd.Rect.Contains(at) {
|
||||
return
|
||||
}
|
||||
pd.Pix[pd.Index(at)] = color.NRGBAModel.Convert(col).(color.NRGBA)
|
||||
nrgba := ToNRGBA(col)
|
||||
pd.Pix[pd.Index(at)] = color.NRGBA{
|
||||
R: uint8(nrgba.R * 255),
|
||||
G: uint8(nrgba.G * 255),
|
||||
B: uint8(nrgba.B * 255),
|
||||
A: uint8(nrgba.A * 255),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ func (imd *IMDraw) pushPt(pos pixel.Vec, pt point) {
|
|||
|
||||
// Color sets the color of the next Pushed points.
|
||||
func (imd *IMDraw) Color(color color.Color) {
|
||||
imd.opts.col = pixel.NRGBAModel.Convert(color).(pixel.NRGBA)
|
||||
imd.opts.col = pixel.ToNRGBA(color)
|
||||
}
|
||||
|
||||
// Picture sets the Picture coordinates of the next Pushed points.
|
||||
|
@ -160,7 +160,7 @@ func (imd *IMDraw) SetMatrix(m pixel.Matrix) {
|
|||
|
||||
// SetColorMask sets a color that all further point's color will be multiplied by.
|
||||
func (imd *IMDraw) SetColorMask(color color.Color) {
|
||||
imd.mask = pixel.NRGBAModel.Convert(color).(pixel.NRGBA)
|
||||
imd.mask = pixel.ToNRGBA(color)
|
||||
imd.batch.SetColorMask(imd.mask)
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ func (c *Canvas) SetMatrix(m pixel.Matrix) {
|
|||
func (c *Canvas) SetColorMask(col color.Color) {
|
||||
nrgba := pixel.NRGBA{R: 1, G: 1, B: 1, A: 1}
|
||||
if col != nil {
|
||||
nrgba = pixel.NRGBAModel.Convert(col).(pixel.NRGBA)
|
||||
nrgba = pixel.ToNRGBA(col)
|
||||
}
|
||||
c.col = mgl32.Vec4{
|
||||
float32(nrgba.R),
|
||||
|
@ -238,7 +238,7 @@ func (c *Canvas) setGlhfBounds() {
|
|||
func (c *Canvas) Clear(color color.Color) {
|
||||
c.orig.dirty = true
|
||||
|
||||
nrgba := pixel.NRGBAModel.Convert(color).(pixel.NRGBA)
|
||||
nrgba := pixel.ToNRGBA(color)
|
||||
|
||||
// color masking
|
||||
nrgba = nrgba.Mul(pixel.NRGBA{
|
||||
|
|
|
@ -67,7 +67,7 @@ func (s *Sprite) Matrix() Matrix {
|
|||
// Note, that this has nothing to do with BasicTarget's SetColorMask method. This only affects this
|
||||
// Sprite and is usable with any Target.
|
||||
func (s *Sprite) SetColorMask(mask color.Color) {
|
||||
s.mask = NRGBAModel.Convert(mask).(NRGBA)
|
||||
s.mask = ToNRGBA(mask)
|
||||
s.calcData()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue