Design Philosophy
WSG is a simple image format developed for Swadge sprites. Each pixel in a WSG is from the web-safe palette of colors, with one extra value indicating transparent (paletteColor_t). The pixels are then compressed with heatshrink compression.
WSGs are handled individually, not in a sheet. The assets_preprocessor
program will take PNG files and convert them to WSG. The cmake build will take the generated WSG files and generate cnfs_image.c
which is included in the firmware Swadge. See assets_preprocessor
in CMakeLists.txt
.
WSG files can be loaded from the filesystem with helper functions in fs_wsg.h. Once loaded from the filesystem WSGs can be drawn to the display.
Usage
There are five ways to draw a WSG to the display each with varying complexity and speed
- drawWsg(): Draw a WSG to the display with transparency, rotation, and flipping over horizontal or vertical axes. This is the slowest option.
- drawWsgSimple(): Draw a WSG to the display with transparency. This is the medium speed option and should be used if the WSG is not rotated or flipped.
- drawWsgTile(): Draw a WSG to the display without transparency. Any transparent pixels will be an indeterminate color. This is the fastest option, and best for background tiles or images.
- drawWsgSimpleScaled(): Draw a WSG to the display with transparency at a specified scale. Scales are integer values, so 2x, 3x, 4x... are the valid options.
- drawWsgSimpleHalf(): Draw a WSG to the display with transparency at half the original resolution.
Example
loadWsg(
"kid0.wsg", &king_donut,
true);
drawWsg(&king_donut, 100, 100,
false,
false, 0);
bool loadWsg(const char *name, wsg_t *wsg, bool spiRam)
Load a WSG from ROM to RAM. WSGs placed in the assets_image folder before compilation will be automat...
Definition fs_wsg.c:34
void freeWsg(wsg_t *wsg)
Free the memory for a loaded WSG.
Definition fs_wsg.c:167
void drawWsg(const wsg_t *wsg, int16_t xOff, int16_t yOff, bool flipLR, bool flipUD, int16_t rotateDeg)
Draw a WSG to the display.
Definition wsg.c:105
A sprite using paletteColor_t colors that can be drawn to the display.
Definition wsg.h:57
|
void | rotatePixel (int16_t *x, int16_t *y, int16_t rotateDeg, int16_t width, int16_t height) |
|
void | drawWsg (const wsg_t *wsg, int16_t xOff, int16_t yOff, bool flipLR, bool flipUD, int16_t rotateDeg) |
| Draw a WSG to the display.
|
|
void | drawWsgSimple (const wsg_t *wsg, int16_t xOff, int16_t yOff) |
| Draw a WSG to the display without flipping or rotation.
|
|
void | drawWsgSimpleScaled (const wsg_t *wsg, int16_t xOff, int16_t yOff, int16_t xScale, int16_t yScale) |
| Draw a WSG to the display without flipping or rotation.
|
|
void | drawWsgTile (const wsg_t *wsg, int32_t xOff, int32_t yOff) |
| Quickly copy a WSG to the display without flipping or rotation or transparency.
|
|
void | drawWsgSimpleHalf (const wsg_t *wsg, int16_t xOff, int16_t yOff) |
| Draw a WSG to the display without flipping or rotation at half size.
|
|