Go to the source code of this file.
Defines | |
#define | HPG_MODE_PAINT 0 |
A drawing mode for painting on the screen. | |
#define | HPG_MODE_XOR 1 |
A drawing mode to XOR bits reversibly onto the screen. | |
#define | HPG_COLOR_WHITE 0x00 |
The color white. | |
#define | HPG_COLOR_GRAY_1 0x11 |
The 1st shade of gray. | |
#define | HPG_COLOR_GRAY_2 0x22 |
The 2nd shade of gray. | |
#define | HPG_COLOR_GRAY_3 0x33 |
The 3rd shade of gray. | |
#define | HPG_COLOR_GRAY_4 0x44 |
The 4th shade of gray. | |
#define | HPG_COLOR_GRAY_5 0x55 |
The 5th shade of gray. | |
#define | HPG_COLOR_GRAY_6 0x66 |
The 6th shade of gray. | |
#define | HPG_COLOR_GRAY_7 0x77 |
The 7th shade of gray. | |
#define | HPG_COLOR_GRAY_8 0x88 |
The 8th shade of gray. | |
#define | HPG_COLOR_GRAY_9 0x99 |
The 9th shade of gray. | |
#define | HPG_COLOR_GRAY_10 0xAA |
The 10th shade of gray. | |
#define | HPG_COLOR_GRAY_11 0xBB |
The 11th shade of gray. | |
#define | HPG_COLOR_GRAY_12 0xCC |
The 12th shade of gray. | |
#define | HPG_COLOR_GRAY_13 0xDD |
The 13th shade of gray. | |
#define | HPG_COLOR_GRAY_14 0xEE |
The 14th shade of gray. | |
#define | HPG_COLOR_BLACK 0xFF |
The color black. | |
#define | HPG_INDICATOR_REMOTE 0 |
The remote indicator at the right side of the screen. | |
#define | HPG_INDICATOR_LSHIFT 1 |
The left shift indicator. | |
#define | HPG_INDICATOR_RSHIFT 2 |
The right shift indicator. | |
#define | HPG_INDICATOR_ALPHA 3 |
The alpha indicator. | |
#define | HPG_INDICATOR_BATTERY 4 |
The low battery indicator. | |
#define | HPG_INDICATOR_WAIT 5 |
The wait/hourglass indicator. | |
Typedefs | |
typedef hpg_graphics | hpg_t |
A graphics context for a surface that can be used for drawing. | |
typedef hpg_font | hpg_font_t |
A font for drawing text. | |
typedef hpg_pattern | hpg_pattern_t |
A pattern for filling shapes. | |
Functions | |
void | hpg_init (void) |
Initializes the hpg module. | |
void | hpg_cleanup (void) |
Restores the graphics hardware to the default state. | |
void | hpg_set_mode_mono (int dbuf) |
Sets the screen to monochrome mode. | |
void | hpg_set_mode_gray4 (int dbuf) |
Sets the screen to 4-color grayscale mode. | |
void | hpg_set_mode_gray16 (int dbuf) |
Sets the screen to 16-color grayscale mode. | |
int | hpg_get_width (hpg_t *g) |
Retrieves the width of a surface. | |
int | hpg_get_height (hpg_t *g) |
Retrieves the height of a surface. | |
void | hpg_set_indicator (unsigned char indicator, unsigned char color) |
Sets the state of an LCD indicator. | |
void | hpg_flip (void) |
Swaps buffers on a double-buffered screen. | |
void | hpg_clip_reset (hpg_t *g) |
Resets the clipping region to the entire screen. | |
void | hpg_clip_set (hpg_t *g, int x1, int y1, int x2, int y2) |
Sets the clipping region to an absolute value. | |
void | hpg_clip (hpg_t *g, int x1, int y1, int x2, int y2) |
Clips the display to a specified region. | |
void | hpg_clear_on (hpg_t *g) |
Clears the given buffer. | |
void | hpg_clear (void) |
Clears the screen. | |
void | hpg_draw_pixel_on (hpg_t *g, int x, int y) |
Draws a pixel onto a buffer. | |
void | hpg_draw_pixel (int x, int y) |
Draws a pixel onto the screen. | |
void | hpg_draw_line_on (hpg_t *g, int x1, int y1, int x2, int y2) |
Draws a line onto a buffer. | |
void | hpg_draw_line (int x1, int y1, int x2, int y2) |
Draws a line onto the screen. | |
void | hpg_draw_rect_on (hpg_t *g, int x1, int y1, int x2, int y2) |
Draws a rectangle onto a buffer. | |
void | hpg_draw_rect (int x1, int y1, int x2, int y2) |
Draws a rectangle onto the screen. | |
void | hpg_fill_rect_on (hpg_t *g, int x1, int y1, int x2, int y2) |
Fills a rectangle on a buffer. | |
void | hpg_fill_rect (int x1, int y1, int x2, int y2) |
Fills a rectangle on the screen. | |
void | hpg_draw_circle_on (hpg_t *g, int cx, int cy, int r) |
Draws a circle onto a buffer. | |
void | hpg_draw_circle (int cx, int cy, int r) |
Draws a circle onto the screen. | |
void | hpg_fill_circle_on (hpg_t *g, int cx, int cy, int r) |
Fills a circle on a buffer. | |
void | hpg_fill_circle (int cx, int cy, int r) |
Fills a circle on the screen. | |
void | hpg_draw_polygon_on (hpg_t *g, int vx[], int vy[], int len) |
Draws a polygon onto a buffer. | |
void | hpg_draw_polygon (int vx[], int vy[], int len) |
Draws a polygon onto the screen. | |
void | hpg_fill_polygon_on (hpg_t *g, int vx[], int vy[], int len) |
Fills a polygon on a buffer. | |
void | hpg_fill_polygon (int vx[], int vy[], int len) |
Fills a polygon on the screen. | |
hpg_font_t * | hpg_get_minifont (void) |
Retrieves the minifont. | |
hpg_font_t * | hpg_get_bigfont (void) |
Retrieves the bigfont. | |
int | hpg_font_get_height (hpg_font_t *font) |
Returns the height of the given font. | |
int | hpg_font_get_advance (hpg_font_t *font) |
Returns the advance of the given font. | |
void | hpg_draw_letter_on (hpg_t *g, char a, int x, int y) |
Draws a character onto a buffer. | |
void | hpg_draw_letter (char a, int x, int y) |
Draws a character onto the screen. | |
void | hpg_draw_text_on (hpg_t *g, char *s, int x, int y) |
Draws a text string onto a buffer. | |
void | hpg_draw_text (char *s, int x, int y) |
Draws a text string onto the screen. | |
unsigned char | hpg_get_color (hpg_t *g) |
Retrieves the current color. | |
void | hpg_set_color (hpg_t *g, unsigned char color) |
Sets the current color. | |
unsigned char | hpg_get_mode (hpg_t *g) |
Retrieves the current drawing mode. | |
void | hpg_set_mode (hpg_t *g, unsigned char mode) |
Sets the current drawing mode. | |
hpg_pattern_t * | hpg_get_pattern (hpg_t *g) |
Retrieves the current fill pattern. | |
void | hpg_set_pattern (hpg_t *g, hpg_pattern_t *pattern) |
Sets the current fill pattern. | |
hpg_font_t * | hpg_get_font (hpg_t *g) |
Retrieves the current font. | |
void | hpg_set_font (hpg_t *g, hpg_font_t *font) |
Sets the current font. | |
hpg_pattern_t * | hpg_alloc_pattern (char *buffer, int height, int fixed) |
Allocates a new fill pattern. | |
void | hpg_free_pattern (hpg_pattern_t *pattern) |
Releases memory used by a fill pattern after it is no longer in use. | |
hpg_font_t * | hpg_alloc_font (char *buffer, int count, int height, int advance) |
Allocates a new font. | |
void | hpg_free_font (hpg_font_t *font) |
Releases memory used by a font after it is no longer in use. | |
unsigned char | hpg_get_pixel (hpg_t *g, int x, int y) |
Retrieves the color of a pixel. | |
hpg_t * | hpg_alloc_mono_image (int width, int height) |
Allocates a off-screen image for drawing in monochrome. | |
hpg_t * | hpg_alloc_gray4_image (int width, int height) |
Allocates a off-screen image for drawing in 4-color gray. | |
hpg_t * | hpg_alloc_gray16_image (int width, int height) |
Allocates a off-screen image for drawing in 16-color gray. | |
void | hpg_free_image (hpg_t *img) |
Frees the memory used by an off-screen image. | |
void | hpg_blit (hpg_t *src, int sx, int sy, int w, int h, hpg_t *dst, int dx, int dy) |
Copy a region of one buffer to another. | |
hpg_t * | hpg_load_xpm_mono (char *xpm[]) |
Loads a Xpm file to a monochrome image. | |
hpg_t * | hpg_load_xpm_gray4 (char *xpm[]) |
Loads a Xpm file to a 4-color grayscale image. | |
hpg_t * | hpg_load_xpm_gray16 (char *xpm[]) |
Loads a Xpm file to a 16-color grayscale image. | |
Variables | |
hpg_t * | hpg_stdscreen |
A graphics context representing the physical screen. |
Definition in file hpgraphics.h.
#define HPG_COLOR_BLACK 0xFF |
The color black.
Definition at line 552 of file hpgraphics.h.
#define HPG_COLOR_GRAY_1 0x11 |
The 1st shade of gray.
Definition at line 420 of file hpgraphics.h.
#define HPG_COLOR_GRAY_10 0xAA |
The 10th shade of gray.
Definition at line 507 of file hpgraphics.h.
#define HPG_COLOR_GRAY_11 0xBB |
The 11th shade of gray.
Definition at line 516 of file hpgraphics.h.
#define HPG_COLOR_GRAY_12 0xCC |
The 12th shade of gray.
Definition at line 525 of file hpgraphics.h.
#define HPG_COLOR_GRAY_13 0xDD |
The 13th shade of gray.
Definition at line 534 of file hpgraphics.h.
#define HPG_COLOR_GRAY_14 0xEE |
The 14th shade of gray.
Definition at line 543 of file hpgraphics.h.
#define HPG_COLOR_GRAY_2 0x22 |
The 2nd shade of gray.
Definition at line 429 of file hpgraphics.h.
#define HPG_COLOR_GRAY_3 0x33 |
The 3rd shade of gray.
Definition at line 438 of file hpgraphics.h.
#define HPG_COLOR_GRAY_4 0x44 |
The 4th shade of gray.
Definition at line 447 of file hpgraphics.h.
#define HPG_COLOR_GRAY_5 0x55 |
The 5th shade of gray.
Definition at line 456 of file hpgraphics.h.
#define HPG_COLOR_GRAY_6 0x66 |
The 6th shade of gray.
Definition at line 468 of file hpgraphics.h.
#define HPG_COLOR_GRAY_7 0x77 |
The 7th shade of gray.
Definition at line 477 of file hpgraphics.h.
#define HPG_COLOR_GRAY_8 0x88 |
The 8th shade of gray.
Definition at line 489 of file hpgraphics.h.
#define HPG_COLOR_GRAY_9 0x99 |
The 9th shade of gray.
Definition at line 498 of file hpgraphics.h.
#define HPG_COLOR_WHITE 0x00 |
The color white.
Definition at line 411 of file hpgraphics.h.
#define HPG_MODE_PAINT 0 |
A drawing mode for painting on the screen.
In paint mode, any pixel drawn to the screen will replace the current pixel at that location. The value of the current pixel has no effect on the result of drawing. This is the default drawing mode.
Definition at line 379 of file hpgraphics.h.
#define HPG_MODE_XOR 1 |
A drawing mode to XOR bits reversibly onto the screen.
In XOR drawing mode, drawing to the screen will perform a bitwise XOR between the old color of the pixel at that location and the most significant bits of the new screen color. For example, in 16-color grayscale (4 bits per pixel), the 4 most significant bits of the current color are combined with the current pixel in an XOR operation. In monochrome (1 bit per pixel) only the most significant bit is used.
Drawing a second time to the same pixel with the same color will return it to its normal state. It is this property which makes XOR drawing mode particularly interesting.
XOR mode acts exactly like paint mode when drawing to a white screen. Drawing in XOR mode with white as the current color has no effect at all. Generally speaking, darker colors will cause the colors on the screen to change more than lighter colors -- however, this is not always the case; the above mathematical description of the result of drawing operations should be considered authoritative.
Definition at line 402 of file hpgraphics.h.
typedef struct hpg_font hpg_font_t |
A font for drawing text.
The hpg_font_t type represents a font for drawing text. The font defines glyphs, as well as an advance and height. Every hpg_t has a current font that it uses for all drawing operations.
The functions hpg_get_minifont and hpg_get_bigfont retrieve pointers to the two standard fonts bundled with HPG. Custom fonts can be created with hpg_alloc_font, and should be released with hpg_free_font when they are no longer in use.
The current font affects the behavior of hpg_draw_letter, hpg_draw_text, hpg_draw_letter_on, and hpg_draw_text_on.
Definition at line 334 of file hpgraphics.h.
typedef struct hpg_pattern hpg_pattern_t |
A pattern for filling shapes.
Setting a fill pattern causes shape fill operations (hpg_fill_*
) to become partially transparent. Patterns may also be used for drawing predefined single-color images to the screen with transparency.
Patterns are currently limited to be exactly eight pixels in width. They may either be fixed (so they repeat over the entire screen beginning from the top-left corner) or relative (so they begin at a reference location, which is generally the top-left corner of a shape that's being drawn).
Patterns can be created with hpg_alloc_pattern. When no longer in use, they should be released using hpg_free_pattern.
The current fill pattern affects the behavior of hpg_fill_rect, hpg_fill_circle, and hpg_fill_polygon.
Definition at line 354 of file hpgraphics.h.
typedef struct hpg_graphics hpg_t |
A graphics context for a surface that can be used for drawing.
The hpg_t type represents a surface that can be drawn upon. It might represent the physical screen, or an off-screen image. An hpg_t may contain a visible frame buffer (which is shown) and an effective frame buffer (which is drawn upon), and the two may be swapped via the hpg_flip method.
Each hpg_t maintains its own state, including the current color, fill pattern, font, and clipping region.
Most applications will primarily use one instance of hpg_t, which is accessed through hpg_stdscreen. Additional instances of hpg_t may be created to draw to off-screen images, by using the functions hpg_alloc_mono_image, hpg_alloc_gray4_image, and hpg_alloc_gray16_image. Off-screen images should later be released by a call to hpg_free_image.
Definition at line 317 of file hpgraphics.h.
hpg_font_t* hpg_alloc_font | ( | char * | buffer, | |
int | count, | |||
int | height, | |||
int | advance | |||
) |
Allocates a new font.
The font data is the concatenation of a fill pattern for each character of the font, and should be at least as long as (count * height) bytes. The advance should be less than or equal to eight pixels.
Fonts allocated via this method should be deallocated by calling hpg_free_font when they are no longer in use.
buffer | The pixel data for characters | |
count | The number of characters | |
height | The number of pixels of height for characters | |
advance | The number of horizontal pixels between the beginning of one character in this font and the beginning of the next |
NULL
if there was not enough memory to allocate the font hpg_t* hpg_alloc_gray16_image | ( | int | width, | |
int | height | |||
) |
Allocates a off-screen image for drawing in 16-color gray.
width | The width of the image | |
height | The height of the image |
hpg_t* hpg_alloc_gray4_image | ( | int | width, | |
int | height | |||
) |
Allocates a off-screen image for drawing in 4-color gray.
width | The width of the image | |
height | The height of the image |
hpg_t* hpg_alloc_mono_image | ( | int | width, | |
int | height | |||
) |
Allocates a off-screen image for drawing in monochrome.
width | The width of the image | |
height | The height of the image |
hpg_pattern_t* hpg_alloc_pattern | ( | char * | buffer, | |
int | height, | |||
int | fixed | |||
) |
Allocates a new fill pattern.
The pattern data is passed as a pointer, and should point to a valid buffer at least as long as height, in bytes. Height specifies the number of rows of the pattern, and fixed is zero for a floating pattern (which is drawn relative to a reference location on the shape being drawn) or non-zero for a fixed pattern, which is drawn relative to the upper-left corner of the screen.
The data in buffer is a bitmask of opaque pixels in the pattern, with one byte per line. At the current time, all patterns are eight pixels wide. The least significant bit represents the left-most pixel, and the most significant bit represents the right-most pixel. This bit order is contrary to many expectations, and should be noted.
Patterns allocated via this method should be deallocated by calling hpg_free_pattern when they are no longer in use.
buffer | The buffer containing the pattern's pixel data | |
height | The number of pixels of height for the pattern | |
fixed | Non-zero if the pattern should be fixed, zero if floating |
NULL
if there was not enough memory to complete this operation Copy a region of one buffer to another.
This function is used to copy any arbitrary region of a buffer to any arbitrary location on the destination buffer. The image may not be resized or stretched during the blit operation. The clipping region of the target screen is effective for this operation.
src | The graphics context to copy from | |
sx | The left x coordinate of the area to copy on the source | |
sy | The top y coordinate of the area to copy on the source | |
w | The width of the area to copy, in pixels | |
h | The height of the area to copy, in pixels | |
dst | The graphics context to copy to | |
dx | The left x coordinate of the area to copy to the destination | |
dy | The top y coordinate of the area to copy to the destination |
void hpg_cleanup | ( | void | ) |
Restores the graphics hardware to the default state.
This function is no longer required
void hpg_clear | ( | void | ) |
Clears the screen.
The entire screen will be set to white following the completion of this function. Note that the current clipping region is not respected, nor is current color and fill pattern used. To set the screen to arbitrary colors, use the current clipping region, or specify a fill pattern, you should use hpg_fill_rect instead.
void hpg_clear_on | ( | hpg_t * | g | ) |
Clears the given buffer.
The entire buffer will be set to white following the completion of this function. Note that the current clipping region is not respected, nor is current color and fill pattern used. To set the buffer to arbitrary colors, use the current clipping region, or specify a fill pattern, you should use hpg_fill_rect_on instead.
g | The graphics context to which this function applies |
void hpg_clip | ( | hpg_t * | g, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Clips the display to a specified region.
This function sets the clipping region to the geometric intersection of the current clipping region and the rectangle given. Therefore, any existing clipping continues to take effect. If this is not what you want, see hpg_clip_set instead.
g | The graphics context to which this function applies | |
x1 | The left-most x coordinate of the new clipping region | |
y1 | The top-most y coordinate of the new clipping region | |
x2 | The right-most x coordinate of the new clipping region | |
y2 | The bottom-most y coordinate of the new clipping region |
void hpg_clip_reset | ( | hpg_t * | g | ) |
Resets the clipping region to the entire screen.
This function may be used to undo any clipping performed by earlier operations.
g | The graphics context to which this function applies |
void hpg_clip_set | ( | hpg_t * | g, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Sets the clipping region to an absolute value.
Sets the clipping region for a given graphics context. Use of this function is discouraged in general-purpose graphics code, in favor of hpg_clip which preserves existing clipping regions as well. An attempt to set the clipping region larger than the size of the graphics context will cause the clipping region to shrink in order to fit on the screen.
This function is equivalent to calling hpg_clip_reset, followed by hpg_clip.
g | The graphics context to which this function applies | |
x1 | The left-most x coordinate of the new clipping region | |
y1 | The top-most y coordinate of the new clipping region | |
x2 | The right-most x coordinate of the new clipping region | |
y2 | The bottom-most y coordinate of the new clipping region |
void hpg_draw_circle | ( | int | cx, | |
int | cy, | |||
int | r | |||
) |
Draws a circle onto the screen.
cx | The x coordinate of the center of the circle | |
cy | The y coordinate of the center of the circle | |
r | The radius of the circle |
void hpg_draw_circle_on | ( | hpg_t * | g, | |
int | cx, | |||
int | cy, | |||
int | r | |||
) |
Draws a circle onto a buffer.
g | The graphics context to which this function applies | |
cx | The x coordinate of the center of the circle | |
cy | The y coordinate of the center of the circle | |
r | The radius of the circle |
void hpg_draw_letter | ( | char | a, | |
int | x, | |||
int | y | |||
) |
Draws a character onto the screen.
The top-left corner of the character is at point (x, y), and the character extends to the right and bottom of that point by the font's advance and height, respectively.
a | The character to draw | |
x | The x coordinate of the left side of the character block | |
y | The y coordinate of the top edge of the character block |
void hpg_draw_letter_on | ( | hpg_t * | g, | |
char | a, | |||
int | x, | |||
int | y | |||
) |
Draws a character onto a buffer.
The top-left corner of the character is at point (x, y), and the character extends to the right and bottom of that point by the font's advance and height, respectively.
g | The graphics context to which this function applies | |
a | The character to draw | |
x | The x coordinate of the left side of the character block | |
y | The y coordinate of the top edge of the character block |
void hpg_draw_line | ( | int | x1, | |
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Draws a line onto the screen.
x1 | The x coordinate of the starting point of the line | |
y1 | The y coordinate of the starting point of the line | |
x2 | The x coordinate of the ending point of the line | |
y2 | The y coordinate of the ending point of the line |
void hpg_draw_line_on | ( | hpg_t * | g, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Draws a line onto a buffer.
g | The graphics context to which this function applies | |
x1 | The x coordinate of the starting point of the line | |
y1 | The y coordinate of the starting point of the line | |
x2 | The x coordinate of the ending point of the line | |
y2 | The y coordinate of the ending point of the line |
void hpg_draw_pixel | ( | int | x, | |
int | y | |||
) |
Draws a pixel onto the screen.
x | The x coordinate of the pixel to draw | |
y | The y coordinate of the pixel to draw |
void hpg_draw_pixel_on | ( | hpg_t * | g, | |
int | x, | |||
int | y | |||
) |
Draws a pixel onto a buffer.
g | The graphics context to which this function applies | |
x | The x coordinate of the pixel to draw | |
y | The y coordinate of the pixel to draw |
void hpg_draw_polygon | ( | int | vx[], | |
int | vy[], | |||
int | len | |||
) |
Draws a polygon onto the screen.
Draws a closed polygon with the vertices from the given arrays. Edges are drawn between each pair of consecutive vertices, and between the first and last vertices to close the shape.
vx | The x coordinates of the vertices of the polygon | |
vy | The y coordinates of the vertices of the polygon | |
len | The number of vertices in the polygon |
void hpg_draw_polygon_on | ( | hpg_t * | g, | |
int | vx[], | |||
int | vy[], | |||
int | len | |||
) |
Draws a polygon onto a buffer.
Draws a closed polygon with the vertices from the given arrays. Edges are drawn between each pair of consecutive vertices, and between the first and last vertices to close the shape.
g | The graphics context to which this function applies | |
vx | The x coordinates of the vertices of the polygon | |
vy | The y coordinates of the vertices of the polygon | |
len | The number of vertices in the polygon |
void hpg_draw_rect | ( | int | x1, | |
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Draws a rectangle onto the screen.
The result is an axis-aligned rectangle spanning between opposite corners at (x1, y1) and (x2, y2). To draw an arbitrary rectangle at angles to the coordinate axes, use hpg_draw_polygon instead.
x1 | The x coordinate of one corner of the rectangle | |
y1 | The y coordinate of one corner of the rectangle | |
x2 | The x coordinate of the opposite corner of the rectangle | |
y2 | The y coordinate of the opposite corner of the rectangle |
void hpg_draw_rect_on | ( | hpg_t * | g, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Draws a rectangle onto a buffer.
The result is an axis-aligned rectangle spanning between opposite corners at (x1, y1) and (x2, y2). To draw an arbitrary rectangle at angles to the coordinate axes, use hpg_draw_polygon_on instead.
g | The graphics context to which this function applies | |
x1 | The x coordinate of one corner of the rectangle | |
y1 | The y coordinate of one corner of the rectangle | |
x2 | The x coordinate of the opposite corner of the rectangle | |
y2 | The y coordinate of the opposite corner of the rectangle |
void hpg_draw_text | ( | char * | s, | |
int | x, | |||
int | y | |||
) |
Draws a text string onto the screen.
The top-left corner of the string is at point (x, y), and the character extends to the right and bottom of that point by the number of lines and columns of the string, respectively. The string may contain newline characters, which will move the insertion point to the next line, and to the original x coordinate for the block.
s | A null-terminated string, containing the text to draw | |
x | The x coordinate of the left side of the text block | |
y | The y coordinate of the top edge of the text block |
void hpg_draw_text_on | ( | hpg_t * | g, | |
char * | s, | |||
int | x, | |||
int | y | |||
) |
Draws a text string onto a buffer.
The top-left corner of the string is at point (x, y), and the character extends to the right and bottom of that point by the number of lines and columns of the string, respectively. The string may contain newline characters, which will move the insertion point to the next line, and to the original x coordinate for the block.
g | The graphics context to which this function applies | |
s | A null-terminated string, containing the text to draw | |
x | The x coordinate of the left side of the text block | |
y | The y coordinate of the top edge of the text block |
void hpg_fill_circle | ( | int | cx, | |
int | cy, | |||
int | r | |||
) |
Fills a circle on the screen.
cx | The x coordinate of the center of the circle | |
cy | The y coordinate of the center of the circle | |
r | The radius of the circle |
void hpg_fill_circle_on | ( | hpg_t * | g, | |
int | cx, | |||
int | cy, | |||
int | r | |||
) |
Fills a circle on a buffer.
g | The graphics context to which this function applies | |
cx | The x coordinate of the center of the circle | |
cy | The y coordinate of the center of the circle | |
r | The radius of the circle |
void hpg_fill_polygon | ( | int | vx[], | |
int | vy[], | |||
int | len | |||
) |
Fills a polygon on the screen.
Fills in a closed polygon with the vertices from the given arrays. Edges are assumed between each pair of consecutive vertices, and between the first and last vertices to close the shape.
vx | The x coordinates of the vertices of the polygon | |
vy | The y coordinates of the vertices of the polygon | |
len | The number of vertices in the polygon |
void hpg_fill_polygon_on | ( | hpg_t * | g, | |
int | vx[], | |||
int | vy[], | |||
int | len | |||
) |
Fills a polygon on a buffer.
Fills in a closed polygon with the vertices from the given arrays. Edges are assumed between each pair of consecutive vertices, and between the first and last vertices to close the shape.
g | The graphics context to which this function applies | |
vx | The x coordinates of the vertices of the polygon | |
vy | The y coordinates of the vertices of the polygon | |
len | The number of vertices in the polygon |
void hpg_fill_rect | ( | int | x1, | |
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Fills a rectangle on the screen.
The result is an axis-aligned rectangle spanning between opposite corners at (x1, y1) and (x2, y2). To fill an arbitrary rectangle at angles to the coordinate axes, use hpg_fill_polygon instead.
x1 | The x coordinate of one corner of the rectangle | |
y1 | The y coordinate of one corner of the rectangle | |
x2 | The x coordinate of the opposite corner of the rectangle | |
y2 | The y coordinate of the opposite corner of the rectangle |
void hpg_fill_rect_on | ( | hpg_t * | g, | |
int | x1, | |||
int | y1, | |||
int | x2, | |||
int | y2 | |||
) |
Fills a rectangle on a buffer.
The result is an axis-aligned rectangle spanning between opposite corners at (x1, y1) and (x2, y2). To fill an arbitrary rectangle at angles to the coordinate axes, use hpg_fill_polygon_on instead.
g | The graphics context to which this function applies | |
x1 | The x coordinate of one corner of the rectangle | |
y1 | The y coordinate of one corner of the rectangle | |
x2 | The x coordinate of the opposite corner of the rectangle | |
y2 | The y coordinate of the opposite corner of the rectangle |
void hpg_flip | ( | void | ) |
Swaps buffers on a double-buffered screen.
If hardware page flipping is not being used, this function has no effect.
After this method is complete, the contents of the back buffer are undefined. The application must either clear the back buffer prior to drawing onto it (with hpg_clear, for example) or otherwise guarantee this it has overwritten every pixel of the screen in order to avoid undefined behavior.
int hpg_font_get_advance | ( | hpg_font_t * | font | ) |
Returns the advance of the given font.
The advance of a font is the number of horizontal pixels in the font. This includes space inter-character spacing if applicable. It is the number of pixels between the left side of a glyph and the left side of the next glyph in the line.
font | The font |
int hpg_font_get_height | ( | hpg_font_t * | font | ) |
Returns the height of the given font.
The height of the font is the number of vertical pixels in the font. This includes space for tails (a.k.a. the "descent") and inter-line spacing if applicable. It is the number of pixels between the top of a glyph on one line and the top of the glyph on the next line.
font | The font |
void hpg_free_font | ( | hpg_font_t * | font | ) |
Releases memory used by a font after it is no longer in use.
The font data buffer is not released, since it is owned by the client code. If it is allocated dynamically, then it should be freed separately.
font | The font to be freed |
void hpg_free_image | ( | hpg_t * | img | ) |
Frees the memory used by an off-screen image.
img | The image to be freed |
void hpg_free_pattern | ( | hpg_pattern_t * | pattern | ) |
Releases memory used by a fill pattern after it is no longer in use.
The pattern data buffer is not released, since it is owned by the client code. If the data buffer is allocated dynamically, then it should be freed separately.
pattern | The pattern to be freed. |
hpg_font_t* hpg_get_bigfont | ( | void | ) |
Retrieves the bigfont.
The bigfont is a font with a height of 8 pixels and an advance of 6 pixels. It is the standard font for the HP49G+ calculator environment, and is both larger and easier to read than the minifont, but results in less text fitting on the screen.
unsigned char hpg_get_color | ( | hpg_t * | g | ) |
Retrieves the current color.
g | The graphics context to which this function applies |
hpg_font_t* hpg_get_font | ( | hpg_t * | g | ) |
Retrieves the current font.
g | The graphics context to which this function applies |
int hpg_get_height | ( | hpg_t * | g | ) |
Retrieves the height of a surface.
g | A drawing surface. |
hpg_font_t* hpg_get_minifont | ( | void | ) |
Retrieves the minifont.
The minifont is a font with a height of 6 pixels and an advance of 4 pixels, and is the smallest font that is reasonably useful on the calculator display. This is the default font for the HPG library.
unsigned char hpg_get_mode | ( | hpg_t * | g | ) |
Retrieves the current drawing mode.
g | The graphics context to which this function applies |
hpg_pattern_t* hpg_get_pattern | ( | hpg_t * | g | ) |
Retrieves the current fill pattern.
g | The graphics context to which this function applies |
NULL
if there is no fill pattern unsigned char hpg_get_pixel | ( | hpg_t * | g, | |
int | x, | |||
int | y | |||
) |
Retrieves the color of a pixel.
g | The graphics context to which this function applies | |
x | The x coordinate of the pixel to read | |
y | The y coordinate of the pixel to read |
int hpg_get_width | ( | hpg_t * | g | ) |
Retrieves the width of a surface.
g | A drawing surface. |
void hpg_init | ( | void | ) |
Initializes the hpg module.
This function is no longer required
hpg_t* hpg_load_xpm_gray16 | ( | char * | xpm[] | ) |
Loads a Xpm file to a 16-color grayscale image.
The resulting image will be the same size as the original pixmap, but will be converted to 16-color gray. Grays will be stored as the nearest shade Non-gray colors are mapped to grayscale according to an approach very similar to ITU Recommendation 709, which uses a model of typical human perception of color to convert color images to grays.
hpg_free_image should be called when the application is no longer using the image.
xpm | The result of compiling an Xpm image as C code |
hpg_t* hpg_load_xpm_gray4 | ( | char * | xpm[] | ) |
Loads a Xpm file to a 4-color grayscale image.
The resulting image will be the same size as the original pixmap, but will be converted to 4-color gray. Grays will be stored as the nearest shade Non-gray colors are mapped to grayscale according to an approach very similar to ITU Recommendation 709, which uses a model of typical human perception of color to convert color images to grays.
hpg_free_image should be called when the application is no longer using the image.
xpm | The result of compiling an Xpm image as C code |
hpg_t* hpg_load_xpm_mono | ( | char * | xpm[] | ) |
Loads a Xpm file to a monochrome image.
The resulting image will be the same size as the original pixmap, but will be converted to monochrome. Colors that appear lighter than a medium gray will appear white, while colors darker than a medium gray will appear black. Non-gray colors are mapped to grayscale according to an approach very similar to ITU Recommendation 709, which uses a model of typical human perception of color to convert color images to grays.
hpg_free_image should be called when the application is no longer using the image.
xpm | The result of compiling an Xpm image as C code |
void hpg_set_color | ( | hpg_t * | g, | |
unsigned char | color | |||
) |
Sets the current color.
The new color will take effect until it is changed with another call to hpg_set_color.
g | The graphics context to which this function applies | |
color | The new color to set for the context |
void hpg_set_font | ( | hpg_t * | g, | |
hpg_font_t * | font | |||
) |
Sets the current font.
Fonts can be retrieved via the hpg_get_minifont and hpg_get_bigfont functions, or they can be created by the user. User fonts should be allocated with hpg_alloc_font, and disposed of with hpg_free_font when they are no longer in use.
g | The graphics context to which this function applies | |
font | The new text font to use for the context |
void hpg_set_indicator | ( | unsigned char | indicator, | |
unsigned char | color | |||
) |
Sets the state of an LCD indicator.
indicator | The indicator to set. This may be any of HPG_INDICATOR_REMOTE, HPG_INDICATOR_LSHIFT, HPG_INDICATOR_RSHIFT, HPG_INDICATOR_ALPHA, HPG_INDICATOR_BATTERY, or HPG_INDICATOR_WAIT. | |
color | The target color for the indicator. Typically, white indicates off and black indicates on. However, other colors may be used. |
void hpg_set_mode | ( | hpg_t * | g, | |
unsigned char | mode | |||
) |
Sets the current drawing mode.
g | The graphics context to which this function applies | |
mode | The new drawing mode to set for the context; either HPG_MODE_PAINT or HPG_MODE_XOR. See the descriptions of those constants for more information about the drawing modes they describe. |
void hpg_set_mode_gray16 | ( | int | dbuf | ) |
Sets the screen to 16-color grayscale mode.
dbuf | If non-zero, sets up two buffers and draws to the unseen buffer; hpg_flip can be used to switch to the other buffer at any time. |
void hpg_set_mode_gray4 | ( | int | dbuf | ) |
Sets the screen to 4-color grayscale mode.
4-color grayscale is a palette mode, and a palette of reasonable colors is set by calling this function. Gray levels 0, 7, 10, and 15 are used, based on a visual comparison of the grays for the most stable values.
dbuf | If non-zero, sets up two buffers and draws to the unseen buffer; hpg_flip can be used to switch to the other buffer at any time. |
void hpg_set_mode_mono | ( | int | dbuf | ) |
Sets the screen to monochrome mode.
Monochrome is the default mode for the screen. Generally, this function is only used if you wish to change to a double-buffered monochrome mode.
dbuf | If non-zero, sets up two buffers and draws to the unseen buffer; hpg_flip can be used to switch to the other buffer at any time. |
void hpg_set_pattern | ( | hpg_t * | g, | |
hpg_pattern_t * | pattern | |||
) |
Sets the current fill pattern.
Patterns used with this function should be allocated with hpg_alloc_pattern, and disposed of with hpg_free_pattern when they are no longer in use.
To remove all fill patterns from the context, pass NULL
for the fill pattern.
g | The graphics context to which this function applies | |
pattern | The new fill pattern to use for the context; or NULL for no pattern |
A graphics context representing the physical screen.
This variable points to the graphics context for the physical screen. It is initialized by a call to hpg_init, which must be called before any drawing to the screen.
_on
prefix. Other functions can only validly operate on hpg_stdscreen, including hpg_flip, and hpg_set_mode_mono and its kin. These functions do not accept a parameter, but nevertheless operate on hpg_stdscreen.