|
TinyGPU
|
#include <SpriteInfo.h>
Public Member Functions | |
| SpriteInfo (size_t startX, size_t startY, const ISurface< RGB_T > &sourceSprite, RGB_T transparentColor, IFont< RGB_T > &font) | |
| virtual | ~SpriteInfo () |
| Rect | getRect () const |
| Rect | clampedSize (size_t rawWidth, size_t rawHeight) const |
| const ISurface< RGB_T > & | currentSprite () const |
| Returns the sprite image currently used for drawing. | |
| virtual void | saveOriginalPixels (ISurface< RGB_T > &framebuffer) |
| Saves the background pixels currently covered by the sprite. | |
| void | onTouch (Point point) |
| void | setMaxSize (size_t maxX, size_t maxY) |
| Set the maximum buffer size for transformedSprite and allocate buffer. | |
| void | setTransformedSprite (SurfaceT &&newSprite) |
Public Attributes | |
| size_t | x = 0 |
| size_t | y = 0 |
| size_t | maxWidth = 0 |
| size_t | maxHeight = 0 |
| RGB_T | invisibleColor = RGB_T(0) |
| const ISurface< RGB_T > * | sprite = nullptr |
| bool | isSurfaceAutoDelete = false |
| std::unique_ptr< SurfaceT > | transformedSprite |
| bool | hasTransformedContent = false |
| float | currentScale = 1.0f |
| float | currentAngleDegrees = 0.0f |
| SurfaceT | originalPixels |
| IFont< RGB_T > & | fontRef |
| void(* | onTouchCallback )(SpriteInfo &, Point) = nullptr |
Tracks a sprite instance together with its saved background pixels.
Each SpriteInfo stores the sprite position, transparent color, current sprite image, and a snapshot of the framebuffer region covered by it.
|
inline |
|
inlinevirtual |
|
inline |
Returns the size a transformed image of (rawWidth, rawHeight) will actually end up stored/drawn at by setTransformedSprite() below. Once a fixed buffer exists (from setMaxSize() or an earlier setTransformedSprite() call), the drawn size is ALWAYS exactly maxWidth x maxHeight - never the raw image's own size - because setTransformedSprite() pads a smaller image with invisibleColor rather than shrinking the buffer to fit it (e.g. scaling down) and crops a larger one down to the buffer (e.g. rotating a square grows its bounding box). Only when no fixed buffer exists yet does the drawn size match the raw image exactly (setTransformedSprite() allocates the very first buffer to fit it precisely).
Callers computing where to anchor/redraw a transformed sprite (see FrameBuffer::applyTransformedSprite(), SpriteDisplay:: applyTransformedSprite()) must use this size, not the raw transformed image's own size, or their background restore/capture bounds won't match the region setTransformedSprite() + drawSprite() actually touch - leaving stale, un-restored pixels on screen (visible as a second, "ghost" copy of the sprite trailing the real one).
|
inline |
Returns the sprite image currently used for drawing.
|
inline |
|
inline |
|
inlinevirtual |
Saves the background pixels currently covered by the sprite.
Reimplemented in SpriteInfoWithoutBackground< RGB_T, SurfaceT >.
|
inline |
Set the maximum buffer size for transformedSprite and allocate buffer.
|
inline |
Replaces the current transformed sprite image, using only the allocated buffer.
| float currentAngleDegrees = 0.0f |
| float currentScale = 1.0f |
| IFont<RGB_T>& fontRef |
| bool hasTransformedContent = false |
| RGB_T invisibleColor = RGB_T(0) |
| bool isSurfaceAutoDelete = false |
| size_t maxHeight = 0 |
| size_t maxWidth = 0 |
| void(* onTouchCallback) (SpriteInfo &, Point) = nullptr |
| SurfaceT originalPixels |
| const ISurface<RGB_T>* sprite = nullptr |
| std::unique_ptr<SurfaceT> transformedSprite |
| size_t x = 0 |
| size_t y = 0 |