minor optimization in Sprite
This commit is contained in:
parent
3276c4e4a1
commit
14a01a5522
13
sprite.go
13
sprite.go
|
@ -58,8 +58,10 @@ func (s *Sprite) Frame() Rect {
|
||||||
// Note, that this has nothing to do with BasicTarget's SetMatrix method. This only affects this
|
// Note, that this has nothing to do with BasicTarget's SetMatrix method. This only affects this
|
||||||
// Sprite and is usable with any Target.
|
// Sprite and is usable with any Target.
|
||||||
func (s *Sprite) SetMatrix(matrix Matrix) {
|
func (s *Sprite) SetMatrix(matrix Matrix) {
|
||||||
s.matrix = matrix
|
if s.matrix != matrix {
|
||||||
s.calcData()
|
s.matrix = matrix
|
||||||
|
s.calcData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Matrix returns the currently set Matrix.
|
// Matrix returns the currently set Matrix.
|
||||||
|
@ -73,8 +75,11 @@ func (s *Sprite) Matrix() Matrix {
|
||||||
// Note, that this has nothing to do with BasicTarget's SetColorMask method. This only affects this
|
// Note, that this has nothing to do with BasicTarget's SetColorMask method. This only affects this
|
||||||
// Sprite and is usable with any Target.
|
// Sprite and is usable with any Target.
|
||||||
func (s *Sprite) SetColorMask(mask color.Color) {
|
func (s *Sprite) SetColorMask(mask color.Color) {
|
||||||
s.mask = ToRGBA(mask)
|
rgba := ToRGBA(mask)
|
||||||
s.calcData()
|
if s.mask != rgba {
|
||||||
|
s.mask = ToRGBA(mask)
|
||||||
|
s.calcData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ColorMask returns the currently set color mask.
|
// ColorMask returns the currently set color mask.
|
||||||
|
|
Loading…
Reference in New Issue