libg15render - Render text and graphics to a buffer usable by libg15(3) or g15daemon(1).
#include <libg15render.h>
struct g15canvas
This structure holds the data need to render objects to the LCD screen.
#define BYTE_SIZE 8
#define G15_BUFFER_LEN 1048
#define G15_COLOR_BLACK 1
#define G15_COLOR_WHITE 0
#define G15_LCD_HEIGHT 43
#define G15_LCD_OFFSET 32
#define G15_LCD_WIDTH 160
#define G15_MAX_FACE 5
#define G15_PIXEL_FILL 1
#define G15_PIXEL_NOFILL 0
#define G15_TEXT_LARGE 2
#define G15_TEXT_MED 1
#define G15_TEXT_SMALL 0
void g15r_clearScreen (g15canvas *canvas, int color)
Fills the screen with pixels of color.
void g15r_drawBar (g15canvas *canvas, int x1, int y1, int x2, int y2, int color, int num, int max, int type)
Draws a completion bar.
void g15r_drawBigNum (g15canvas *canvas, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int num)
Draw a large number.
void g15r_drawCircle (g15canvas *canvas, int x, int y, int r, int fill, int color)
Draws a circle centered at (x, y) with a radius of r.
void g15r_drawIcon (g15canvas *canvas, char *buf, int my_x, int my_y, int width, int height)
Draw an icon to the screen from a wbmp buffer.
void g15r_drawLine (g15canvas *canvas, int px1, int py1, int px2, int py2, const int color)
Draws a line from (px1, py1) to (px2, py2).
void g15r_drawRoundBox (g15canvas *canvas, int x1, int y1, int x2, int y2, int fill, int color)
Draws a box with rounded corners bounded by (x1, y1) and (x2, y2).
void g15r_drawSprite (g15canvas *canvas, char *buf, int my_x, int my_y, int width, int height, int start_x, int start_y, int total_width)
Draw a sprite to the screen from a wbmp buffer.
int g15r_getPixel (g15canvas *canvas, unsigned int x, unsigned int y)
Gets the value of the pixel at (x, y).
void g15r_initCanvas (g15canvas *canvas)
Clears the canvas and resets the mode switches.
int g15r_loadWbmpSplash (g15canvas *canvas, char *filename)
Draw a splash screen from 160x43 wbmp file.
int g15r_loadWbmpToBuf (char *buf, char *filename, int *img_width, int *img_height, int maxlen)
Load a wbmp file into a buffer.
void g15r_pixelBox (g15canvas *canvas, int x1, int y1, int x2, int y2, int color, int thick, int fill)
Draws a box bounded by (x1, y1) and (x2, y2).
void g15r_pixelOverlay (g15canvas *canvas, int x1, int y1, int width, int height, short colormap[])
Overlays a bitmap of size width x height starting at (x1, y1).
void g15r_pixelReverseFill (g15canvas *canvas, int x1, int y1, int x2, int y2, int fill, int color)
Fills an area bounded by (x1, y1) and (x2, y2).
void g15r_renderCharacterLarge (g15canvas *canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)
Renders a character in the large font at (x, y).
void g15r_renderCharacterMedium (g15canvas *canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)
Renders a character in the meduim font at (x, y).
void g15r_renderCharacterSmall (g15canvas *canvas, int x, int y, unsigned char character, unsigned int sx, unsigned int sy)
Renders a character in the small font at (x, y).
void g15r_renderString (g15canvas *canvas, unsigned char stringOut[], int row, int size, unsigned int sx, unsigned int sy)
Renders a string with font size in row.
void g15r_setPixel (g15canvas *canvas, unsigned int x, unsigned int y, int val)
Sets the value of the pixel at (x, y).
void g15r_ttfLoad (g15canvas *canvas, char *fontname, int fontsize, int face_num)
Loads a font through the FreeType2 library.
void g15r_ttfPrint (g15canvas *canvas, int x, int y, int fontsize, int face_num, int color, int center, char *print_string)
Prints a string in a given font.
unsigned char fontdata_6x4 []
Font data for the small (6x4) font.
unsigned char fontdata_7x5 []
Font data for the medium (7x5) font.
unsigned char fontdata_8x8 []
Font data for the large (8x8) font.
Definition at line 21 of file libg15render.h.
Referenced by g15r_drawIcon(), g15r_drawSprite(), g15r_getPixel(), g15r_loadWbmpToBuf(), and g15r_setPixel().
Definition at line 22 of file libg15render.h.
Referenced by g15r_clearScreen(), g15r_initCanvas(), and g15r_loadWbmpSplash().
Definition at line 27 of file libg15render.h.
Referenced by g15r_drawBigNum(), g15r_drawRoundBox(), g15r_pixelOverlay(), g15r_renderCharacterLarge(), g15r_renderCharacterMedium(), and g15r_renderCharacterSmall().
Definition at line 26 of file libg15render.h.
Referenced by g15r_drawBigNum(), g15r_drawRoundBox(), g15r_pixelOverlay(), g15r_renderCharacterLarge(), g15r_renderCharacterMedium(), and g15r_renderCharacterSmall().
Definition at line 24 of file libg15render.h.
Referenced by g15r_getPixel(), and g15r_setPixel().
Definition at line 23 of file libg15render.h.
Definition at line 25 of file libg15render.h.
Referenced by g15r_getPixel(), and g15r_setPixel().
Definition at line 33 of file libg15render.h.
Referenced by g15r_ttfLoad().
Definition at line 32 of file libg15render.h.
Definition at line 31 of file libg15render.h.
Definition at line 30 of file libg15render.h.
Referenced by g15r_renderString().
Definition at line 29 of file libg15render.h.
Referenced by g15r_renderString().
Definition at line 28 of file libg15render.h.
Referenced by g15r_renderString().
Fills the screen with pixels of color.
Clears the screen and fills it with pixels of color
Parameters:
Definition at line 80 of file screen.c.
References g15canvas::buffer, and G15_BUFFER_LEN.
Draws a completion bar.
Given a maximum value, and a value between 0 and that maximum value, calculate and draw a bar showing that percentage.
Parameters:
Definition at line 337 of file pixel.c.
References g15r_drawLine(), and g15r_pixelBox().
Draw a large number.
Draw a large number to a canvas
Parameters:
Definition at line 542 of file pixel.c.
References G15_COLOR_BLACK, G15_COLOR_WHITE, and g15r_pixelBox().
Draws a circle centered at (x, y) with a radius of r.
Draws a circle centered at (x, y) with a radius of r.
The circle will be filled if fill != 0.
Parameters:
Definition at line 203 of file pixel.c.
References g15r_drawLine(), and g15r_setPixel().
Draw an icon to the screen from a wbmp buffer.
Draw an icon to a canvas
Parameters:
Definition at line 408 of file pixel.c.
References BYTE_SIZE, and g15r_setPixel().
Draws a line from (px1, py1) to (px2, py2).
A line of color is drawn from (px1, py1) to (px2, py2).
Parameters:
Definition at line 99 of file pixel.c.
References g15r_setPixel(), and swap().
Referenced by g15r_drawBar(), g15r_drawCircle(), g15r_drawRoundBox(), and g15r_pixelBox().
Draws a box with rounded corners bounded by (x1, y1) and (x2, y2).
Draws a rounded box around the area bounded by (x1, y1) and (x2, y2).
The box will be filled if fill != 0.
Parameters:
Definition at line 252 of file pixel.c.
References G15_COLOR_BLACK, G15_COLOR_WHITE, g15r_drawLine(), and g15r_setPixel().
Draw a sprite to the screen from a wbmp buffer.
Draw a sprite to a canvas
Parameters:
Definition at line 440 of file pixel.c.
References BYTE_SIZE, and g15r_setPixel().
Gets the value of the pixel at (x, y).
Retrieves the value of the pixel at (x, y)
Parameters:
Definition at line 29 of file screen.c.
References g15canvas::buffer, BYTE_SIZE, G15_LCD_HEIGHT, and G15_LCD_WIDTH.
Referenced by g15r_pixelReverseFill(), and g15r_setPixel().
Clears the canvas and resets the mode switches.
Clears the screen and resets the mode values for a canvas
Parameters:
Definition at line 91 of file screen.c.
References g15canvas::buffer, g15canvas::ftLib, G15_BUFFER_LEN, g15canvas::mode_cache, g15canvas::mode_reverse, and g15canvas::mode_xor.
Draw a splash screen from 160x43 wbmp file.
wbmp splash screen loader - assumes image is 160x43
Parameters:
Definition at line 385 of file pixel.c.
References g15canvas::buffer, G15_BUFFER_LEN, and g15r_loadWbmpToBuf().
Load a wbmp file into a buffer.
basic wbmp loader - loads wbmp into pre-prepared buf.
Parameters:
Definition at line 468 of file pixel.c.
References BYTE_SIZE.
Referenced by g15r_loadWbmpSplash().
Draws a box bounded by (x1, y1) and (x2, y2).
Draws a box around the area bounded by (x1, y1) and (x2, y2).
The box will be filled if fill != 0 and the sides will be thick pixels wide.
Parameters:
Definition at line 163 of file pixel.c.
References g15r_drawLine(), and g15r_setPixel().
Referenced by g15r_drawBar(), and g15r_drawBigNum().
Overlays a bitmap of size width x height starting at (x1, y1).
A 1-bit bitmap defined in colormap[] is drawn to the canvas with an upper left corner at (x1, y1) and a lower right corner at (x1+width, y1+height).
Parameters:
Definition at line 74 of file pixel.c.
References G15_COLOR_BLACK, G15_COLOR_WHITE, and g15r_setPixel().
Fills an area bounded by (x1, y1) and (x2, y2).
The area with an upper left corner at (x1, y1) and lower right corner at (x2, y2) will be filled with color if fill>0 or the current contents of the area will be reversed if fill==0.
Parameters:
Definition at line 45 of file pixel.c.
References g15r_getPixel(), and g15r_setPixel().
Renders a character in the large font at (x, y).
Definition at line 22 of file text.c.
References fontdata_8x8, G15_COLOR_BLACK, G15_COLOR_WHITE, and g15r_setPixel().
Referenced by g15r_renderString().
Renders a character in the meduim font at (x, y).
Definition at line 50 of file text.c.
References fontdata_7x5, G15_COLOR_BLACK, G15_COLOR_WHITE, and g15r_setPixel().
Referenced by g15r_renderString().
Renders a character in the small font at (x, y).
Definition at line 77 of file text.c.
References fontdata_6x4, G15_COLOR_BLACK, G15_COLOR_WHITE, and g15r_setPixel().
Referenced by g15r_renderString().
Renders a string with font size in row.
Definition at line 104 of file text.c.
References G15_TEXT_LARGE, G15_TEXT_MED, G15_TEXT_SMALL, g15r_renderCharacterLarge(), g15r_renderCharacterMedium(), and g15r_renderCharacterSmall().
Sets the value of the pixel at (x, y).
Sets the value of the pixel at (x, y)
Parameters:
Definition at line 50 of file screen.c.
References g15canvas::buffer, BYTE_SIZE, G15_LCD_HEIGHT, G15_LCD_WIDTH, g15r_getPixel(), g15canvas::mode_reverse, and g15canvas::mode_xor.
Referenced by draw_ttf_char(), g15r_drawCircle(), g15r_drawIcon(), g15r_drawLine(), g15r_drawRoundBox(), g15r_drawSprite(), g15r_pixelBox(), g15r_pixelOverlay(), g15r_pixelReverseFill(), g15r_renderCharacterLarge(), g15r_renderCharacterMedium(), and g15r_renderCharacterSmall().
Loads a font through the FreeType2 library.
Load a font for use with FreeType2 font support
Parameters:
Definition at line 145 of file text.c.
References g15canvas::ftLib, G15_MAX_FACE, g15canvas::ttf_face, and g15canvas::ttf_fontsize.
Prints a string in a given font.
Render a string with a FreeType2 font
Parameters:
Definition at line 283 of file text.c.
References calc_ttf_centering(), calc_ttf_right_justify(), calc_ttf_true_ypos(), draw_ttf_str(), g15canvas::ttf_face, and g15canvas::ttf_fontsize.
Font data for the small (6x4) font.
Referenced by g15r_renderCharacterSmall().
Font data for the medium (7x5) font.
Referenced by g15r_renderCharacterMedium().
Font data for the large (8x8) font.
Referenced by g15r_renderCharacterLarge().
Anthony J. Mirabella <mirabeaj@gmail.com>
Generated automatically by Doxygen for libg15render from the source code.
Recent comments
3 weeks 1 day ago
3 weeks 3 days ago
4 weeks 6 days ago
6 weeks 2 days ago
7 weeks 4 days ago
7 weeks 6 days ago
7 weeks 6 days ago
8 weeks 3 days ago
9 weeks 3 days ago
9 weeks 3 days ago