Skip to content

finite_draw_png

The finite_draw_png function attempt to draw a png image to screen at a given size and position.

void finite_draw_png(FiniteShell *shell, const char *path, double x, double y, double width, double height, bool fillOnFail);
TypeDescription
FiniteShell *shellThe FiniteShell where the window is.
const char *pathThe path to the png image.
double xThe X position of the png.
double yThe Y position of the png.
double widthThe width (in pixels) of the png.
double heightThe height (in pixels) of the png.
bool fillOnFailWhether the image should be replaced by a colored box if it cant be loaded.
#include <finite/draw.h>
const char basePath[] = "/console/icons/input/"; // at some point we'll make an official icon set
char fullPath[PATH_MAX];
strcpy(fullPath, basePath);
if (finite_gamepad_key_down(0, myShell, FINITE_BTN_DOWN)) {
strcat(fullPath, finite_gamepad_key_string_from_key(FINITE_BTN_DOWN));
strcat(fullPath, ".png");
} else if (finite_gamepad_key_down(0, myShell, FINITE_BTN_UP)) {
strcat(fullPath, finite_gamepad_key_string_from_key(FINITE_BTN_UP));
strcat(fullPath, ".png");
} else if (finite_gamepad_key_down(0, myShell, FINITE_BTN_LEFT)) {
strcat(fullPath, finite_gamepad_key_string_from_key(FINITE_BTN_LEFT));
strcat(fullPath, ".png");
} else if (finite_gamepad_key_down(0, myShell, FINITE_BTN_RIGHT)) {
strcat(fullPath, finite_gamepad_key_string_from_key(FINITE_BTN_RIGHT));
strcat(fullPath, ".png");
} else {
strcat(fullPath, "Dpad.png");
}
finite_draw_png(myShell, fullPath, x, y, image_width, image_height, true);

This function only supports pngs.

This function must have a valid FiniteShell

This function uses Cairo which requires a valid cairo_surface_t in FiniteShell.cairo_surface beforehand.