From 3cfa3a53953a3e6f00069f42af48f31cfabe12be Mon Sep 17 00:00:00 2001 From: faiface <faiface@ksp.sk> Date: Thu, 23 Mar 2017 23:00:42 +0100 Subject: [PATCH] add Sprite.Matrix and Sprite.ColorMask getters --- sprite.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sprite.go b/sprite.go index 8d57f59..dee7e37 100644 --- a/sprite.go +++ b/sprite.go @@ -1,5 +1,7 @@ package pixel +import "image/color" + // 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 @@ -54,16 +56,26 @@ func (s *Sprite) SetMatrix(matrix Matrix) { 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 // set color mask. // // 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 NRGBA) { - s.mask = mask +func (s *Sprite) SetColorMask(mask color.Color) { + s.mask = NRGBAModel.Convert(mask).(NRGBA) 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. func (s *Sprite) Draw(t Target) { s.d.Draw(t) -- GitLab