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);Parameters
Section titled “Parameters”| Type | Description |
|---|---|
FiniteShell *shell | The FiniteShell where the window is. |
const char *path | The path to the png image. |
double x | The X position of the png. |
double y | The Y position of the png. |
double width | The width (in pixels) of the png. |
double height | The height (in pixels) of the png. |
bool fillOnFail | Whether the image should be replaced by a colored box if it cant be loaded. |
Code Example
Section titled “Code Example”#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);Standard Usage
Section titled “Standard Usage”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.