-
-
Notifications
You must be signed in to change notification settings - Fork 257
NeoVerticalSpriteSheet object API
NeoVerticalSpriteSheet represents an image container object that stores the data in a NeoPixel native format for faster rendering. The primary use of this class is to contain a vertical series of sprites as one image and have it rendered to a NeoPixelBus.
NeoVerticalSpriteSheet<METHOD>(uint16_t width, uint16_t height, uint16_t spriteHeight, PGM_VOID_P pixels)
This will define the object with the given Method, construct it to the width and height, and define the sprite height.
Valid Method objects are the NeoBufferMethod and NeoBufferProgmemMethod.
The optional pixels will either be copied into the Ram buffer (for NeoBufferMethod) or become the referenced data (NeoBufferProgmemMethod).
NeoVerticalSpriteSheet<NeoBufferProgmemMethod<NeoGrbFeature>> spriteSheet(myImageWidth, myImageHeight, mySpriteHeight, myImage);
This will return the number of sprites in the sheet.
This will return the width in pixels of a single sprite.
This will return the height in pixels of a single sprite.
This will set the color of the given pixel on the given sprite
- indexSprite - the sprite to write to.
- x - the horizontal pixel position.
- y - the vertical pixel position.
- color - a color object to use, RgbColor, HslColor, and HsbColor will all work and if the NeoPixelBus object was created with the NeoRgbwFeature the RgbwColor will also work.
This will return the color of the given pixel from the given sprite
- indexSprite - the sprite to read from.
- x - the horizontal pixel position.
- y - the vertical pixel position.
- <return>, a color object, RgbColor or RgbwColor.
This will clear all pixels on all sprites to the given color.
- color - a color object to use, RgbColor, HslColor, and HsbColor will all work and if the NeoPixelBus object was created with the NeoRgbwFeature the RgbwColor will also work.
This will render the sprite to the destBuffer at indexPixel. This is a linear rendering, not a 2D image rendering.
- destBuffer - Another NeoBuffer or NeoPixelBus.
- indexPixel - the location to start the render at.
- indexSprite - the sprite to Blt from.
void Blt(NeoBufferContext destBuffer, int16_t xDest, int16_t yDest, uint16_t indexSprite, LayoutMapCallback layoutMap)
This will render all of a sprite to the destBuffer at a given location. This is a 2d image rendering.
- destBuffer - Another NeoBuffer or NeoPixelBus.
- xDest - the upper left location in the destination to render to.
- yDest - the upper left location in the destination to render to.
- indexSprite - the sprite to Blt from.
- layoutMap - a layoutMap callback that implements the destinations mapping routine (see below).
As the consumer of certain methods, you will need to implement this and pass it into those methods. You are expected to translate the x,y location of the destination to a linear index value. If you have implemented NeoTopology
, NeoTiles
, or NeoMosaic
; you can just call the MapProbe()
method on them and return what they provide.
NeoTopology<RowMajorLayout> topo(16,16); // 16x16 matrix panel
uint16_t MyLayoutMap(int16_t x, int16_t y)
{
return topo.MapProbe(x, y);
}
If you implement your own, make sure to handle out of range values beyond your edges including negative values and return PixelIndex_OutOfBounds
for these cases.