Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
wsgCanvas.c File Reference

Detailed Description

Provides a canvas to paint with low memory requirements.

Author
Jeremy Stintzcum (jerem.nosp@m.y.st.nosp@m.intzc.nosp@m.um@g.nosp@m.mail..nosp@m.com)
Version
1.0
Date
2025-09-02

Functions

void canvasBlankInit (wsg_t *canvas, int width, int height, paletteColor_t startColor, bool spiRam)
 Initializes a blank canvas to the dimensions and color provided.
 
void canvasDrawSimple (wsg_t *canvas, cnfsFileIdx_t image, int startX, int startY)
 Draws a image to the canvas at the specified coordinates relative to the canvas.
 
void canvasDrawSimplePal (wsg_t *canvas, cnfsFileIdx_t image, int startX, int startY, wsgPalette_t *pal)
 Draws a image to the canvas at the specified coordinates relative to the canvas and applies a palette.
 
void canvasDraw (wsg_t *canvas, cnfsFileIdx_t image, int startX, int startY, bool flipX, bool flipY, int32_t rotateDeg)
 Draws an image to the canvas at a specified angle.
 
void canvasDrawPal (wsg_t *canvas, cnfsFileIdx_t image, int startX, int startY, bool flipX, bool flipY, int32_t rotateDeg, wsgPalette_t *pal)
 Draws an image to the canvas at a specified angle.
 

Function Documentation

◆ canvasBlankInit()

void canvasBlankInit ( wsg_t * canvas,
int width,
int height,
paletteColor_t startColor,
bool spiRam )

Initializes a blank canvas to the dimensions and color provided.

Parameters
canvasWSG to save the canvas too. Use a standard wsg_t and provide the pointer
widthWidth in pixels of the desired canvas
heightHeight in pixels of the desired canvas
startColorThe initial color. Can be any paletteColor_t including cTransparent
spiRamWhether or not to load the pixel data into SPIRAM.

◆ canvasDrawSimple()

void canvasDrawSimple ( wsg_t * canvas,
cnfsFileIdx_t image,
int startX,
int startY )

Draws a image to the canvas at the specified coordinates relative to the canvas.

Parameters
canvasWSG to save changes to. Will work with any WSG, cannot be reverted
imageNew cnfsFileIdx_t to apply to the canvas
startXX position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.
startYY position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.

◆ canvasDrawSimplePal()

void canvasDrawSimplePal ( wsg_t * canvas,
cnfsFileIdx_t image,
int startX,
int startY,
wsgPalette_t * pal )

Draws a image to the canvas at the specified coordinates relative to the canvas and applies a palette.

Parameters
canvasWSG to save changes to. Will work with any WSG, cannot be reverted
imageNew cnfsFileIdx_t to apply to the canvas
startXX position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.
startYY position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.
palPalette data to use to transform the image

◆ canvasDraw()

void canvasDraw ( wsg_t * canvas,
cnfsFileIdx_t image,
int startX,
int startY,
bool flipX,
bool flipY,
int32_t rotateDeg )

Draws an image to the canvas at a specified angle.

Parameters
canvasWSG to save changes to. Will work with any WSG, cannot be reverted
imageNew cnfsFileIdx_t to apply to the canvas
startXX position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.
startYY position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.
flipXFlips applied image in the x direction
flipYFlips applied image in the Y direction
rotateDegAngle to draw the image at

◆ canvasDrawPal()

void canvasDrawPal ( wsg_t * canvas,
cnfsFileIdx_t image,
int startX,
int startY,
bool flipX,
bool flipY,
int32_t rotateDeg,
wsgPalette_t * pal )

Draws an image to the canvas at a specified angle.

Parameters
canvasWSG to save changes to. Will work with any WSG, cannot be reverted
imageNew cnfsFileIdx_t to apply to the canvas
startXX position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.
startYY position on canvas. Negative moves left, positive moves right. Pixels not on canvas are cropped.
flipXFlips applied image in the x direction
flipYFlips applied image in the Y direction
rotateDegAngle to draw the image at
palPalette data to use to transform the image