add Sprite.Matrix and Sprite.ColorMask getters
This commit is contained in:
parent
7454bf723e
commit
3cfa3a5395
16
sprite.go
16
sprite.go
|
@ -1,5 +1,7 @@
|
||||||
package pixel
|
package pixel
|
||||||
|
|
||||||
|
import "image/color"
|
||||||
|
|
||||||
// Sprite is a drawable Picture. It's anchored by the center of it's Picture.
|
// Sprite is a drawable Picture. It's anchored by the center of it's Picture.
|
||||||
//
|
//
|
||||||
// To achieve different anchoring, transformations and color masking, use SetMatrix and SetColorMask
|
// To achieve different anchoring, transformations and color masking, use SetMatrix and SetColorMask
|
||||||
|
@ -54,16 +56,26 @@ func (s *Sprite) SetMatrix(matrix Matrix) {
|
||||||
s.calcData()
|
s.calcData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Matrix returns the currently set Matrix.
|
||||||
|
func (s *Sprite) Matrix() Matrix {
|
||||||
|
return s.matrix
|
||||||
|
}
|
||||||
|
|
||||||
// SetColorMask sets a color that this Sprite will be multiplied by. This overrides any previously
|
// SetColorMask sets a color that this Sprite will be multiplied by. This overrides any previously
|
||||||
// set color mask.
|
// set color mask.
|
||||||
//
|
//
|
||||||
// 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 NRGBA) {
|
func (s *Sprite) SetColorMask(mask color.Color) {
|
||||||
s.mask = mask
|
s.mask = NRGBAModel.Convert(mask).(NRGBA)
|
||||||
s.calcData()
|
s.calcData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ColorMask returns the currently set color mask.
|
||||||
|
func (s *Sprite) ColorMask() NRGBA {
|
||||||
|
return s.mask
|
||||||
|
}
|
||||||
|
|
||||||
// Draw draws the Sprite onto the provided Target.
|
// Draw draws the Sprite onto the provided Target.
|
||||||
func (s *Sprite) Draw(t Target) {
|
func (s *Sprite) Draw(t Target) {
|
||||||
s.d.Draw(t)
|
s.d.Draw(t)
|
||||||
|
|
Loading…
Reference in New Issue