libkipr  1.0.0
Graphics

Typedefs

typedef enum Encoding Encoding
 An enumerate with encoding types RGB and BGR. More...
 

Enumerations

enum  Encoding { RGB , BGR }
 An enumerate with encoding types RGB and BGR. More...
 

Functions

EXPORT_SYM int graphics_open (int width, int height)
 
EXPORT_SYM void graphics_close ()
 
EXPORT_SYM void graphics_update ()
 
EXPORT_SYM void graphics_clear ()
 
EXPORT_SYM void graphics_blit_enc (const unsigned char *data, Encoding enc, int x, int y, int width, int height)
 
EXPORT_SYM void graphics_blit_region_enc (const unsigned char *data, Encoding enc, int sx, int sy, int ex, int ey, int width, int height, int dx, int dy)
 
EXPORT_SYM void graphics_fill (int r, int g, int b)
 
EXPORT_SYM void graphics_pixel (int x, int y, int r, int g, int b)
 
EXPORT_SYM void graphics_line (int x1, int y1, int x2, int y2, int r, int g, int b)
 
EXPORT_SYM void graphics_circle (int cx, int cy, int radius, int r, int g, int b)
 
EXPORT_SYM void graphics_circle_fill (int cx, int cy, int radius, int r, int g, int b)
 
EXPORT_SYM void graphics_rectangle (int x1, int y1, int x2, int y2, int r, int g, int b)
 
EXPORT_SYM void graphics_rectangle_fill (int x1, int y1, int x2, int y2, int r, int g, int b)
 
EXPORT_SYM void graphics_triangle (int x1, int y1, int x2, int y2, int x3, int y3, int r, int g, int b)
 
EXPORT_SYM void graphics_triangle_fill (int x1, int y1, int x2, int y2, int x3, int y3, int r, int g, int b)
 
EXPORT_SYM int get_key_state (enum KeyCode key)
 
EXPORT_SYM void get_mouse_position (int *x, int *y)
 
EXPORT_SYM int get_mouse_middle_button ()
 
EXPORT_SYM int get_mouse_left_button ()
 
EXPORT_SYM int get_mouse_right_button ()
 
void graphics_segment_display (int s[], int x, int y, int r, int g, int b, float size)
 
void graphics_print_character (int n, int x, int y, int r, int g, int b, float size)
 
void graphics_print_string (char s[], int x, int y, int r, int g, int b, float size)
 
int graphics_print_int (int n, int minNumDigits, int x, int y, int r, int g, int b, float size)
 
void graphics_print_float (float n, int numDigits, int x, int y, int r, int g, int b, float size)
 

Detailed Description

Typedef Documentation

◆ Encoding

typedef enum Encoding Encoding

An enumerate with encoding types RGB and BGR.

Enumeration Type Documentation

◆ Encoding

enum Encoding

An enumerate with encoding types RGB and BGR.

Enumerator
RGB 

the enum used to represent RGB encoding

BGR 

the enum used to represent BGR encoding

Function Documentation

◆ get_key_state()

EXPORT_SYM int get_key_state ( enum KeyCode  key)

Gets the current state of a keyboard key.

Note
A KISS Graphics Window must be open for input functions to work.
Parameters
keyAn ASCII key code or a Key value from the KeyCode enum.
Returns
1 for pressed, 0 for not pressed

◆ get_mouse_left_button()

EXPORT_SYM int get_mouse_left_button ( )

Returns the state of the mouse's left button.

Returns
1 for pressed, 0 for not pressed

◆ get_mouse_middle_button()

EXPORT_SYM int get_mouse_middle_button ( )

Returns the state of the mouse's middle button.

Returns
1 for pressed, 0 for not pressed

◆ get_mouse_position()

EXPORT_SYM void get_mouse_position ( int *  x,
int *  y 
)

Returns the mouse's current position relative to the top left corner of the graphics window.

◆ get_mouse_right_button()

EXPORT_SYM int get_mouse_right_button ( )

Returns the state of the mouse's right button.

Returns
1 for pressed, 0 for not pressed

◆ graphics_blit_enc()

EXPORT_SYM void graphics_blit_enc ( const unsigned char *  data,
Encoding  enc,
int  x,
int  y,
int  width,
int  height 
)

Blits a pixel array onto the graphics context

Parameters
datathe 1D array of pixel data to blit
encRGB for a Red-Green-Blue encoding or BGR for a Blue-Green-Red encoding
xThe destination x coordinate of the blit (target)
yThe destination y coordinate of the blit (target)
widthThe width of the area to blit
heightThe height of the area to blit

◆ graphics_blit_region_enc()

EXPORT_SYM void graphics_blit_region_enc ( const unsigned char *  data,
Encoding  enc,
int  sx,
int  sy,
int  ex,
int  ey,
int  width,
int  height,
int  dx,
int  dy 
)

Blits a pixel array region onto the graphics context

Parameters
datathe 1D array of pixel data to blit
encRGB for a Red-Green-Blue encoding or BGR for a Blue-Green-Red encoding
sxThe start x coordinate of the blit (source)
syThe start y coordinate of the blit (source)
exThe end x coordinate of the blit (source)
eyThe end y coordinate of the blit (source)
widthThe width of the area to blit
heightThe height of the area to blit
dxThe destination x coordinate of the blit (target)
dyThe destination y coordinate of the blit (target)

◆ graphics_circle()

EXPORT_SYM void graphics_circle ( int  cx,
int  cy,
int  radius,
int  r,
int  g,
int  b 
)

Draw an unfilled circle to the graphics window at the given coordinates and with the given radius.

Parameters
cxthe X coordinate of the center of the circle
cythe Y cordinate of the center of the circle
radiusthe radius of the circle to be drawn
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_circle_fill()

EXPORT_SYM void graphics_circle_fill ( int  cx,
int  cy,
int  radius,
int  r,
int  g,
int  b 
)

Draw a filled circle to the graphics window at the given coordinates and with the given radius.

Parameters
cxthe X coordinate of the center of the circle
cythe Y cordinate of the center of the circle
radiusthe radius of the circle to be drawn
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_clear()

EXPORT_SYM void graphics_clear ( )

Fills the entire window with the color black

◆ graphics_close()

EXPORT_SYM void graphics_close ( )

Closes the previously opened KISS Graphics Window

◆ graphics_fill()

EXPORT_SYM void graphics_fill ( int  r,
int  g,
int  b 
)

Fill the graphics context with a color.

Parameters
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_line()

EXPORT_SYM void graphics_line ( int  x1,
int  y1,
int  x2,
int  y2,
int  r,
int  g,
int  b 
)

Draw a line from the point (x1, y1) to (x2, y2)

Parameters
x1the X coordinate of the first point
y1the Y coordinate of the first point
x2the X coordinate of the second point
y2the Y coordinate of the second point
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_open()

EXPORT_SYM int graphics_open ( int  width,
int  height 
)

Opens a KISS Graphics Window for drawing and input functions.

Parameters
widthThe width of the graphics window
heightThe height of the graphics window

◆ graphics_pixel()

EXPORT_SYM void graphics_pixel ( int  x,
int  y,
int  r,
int  g,
int  b 
)

Draw a pixel at (x, y)

Parameters
xthe X coordinate of the pixel
ythe Y coordinate of the pixel
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_print_character()

void graphics_print_character ( int  n,
int  x,
int  y,
int  r,
int  g,
int  b,
float  size 
)

Prints out a character in 16 segment characters

Parameters
nThe character to display
xThe X coordinate of the character's top-left corner
yThe Y coordinate of the character's top-left corner
rThe red component of the drawing, from 0 to 255
gThe green component of the drawing, from 0 to 255
bThe blue component of the drawing, from 0 to 255
sizeThe character's size

◆ graphics_print_float()

void graphics_print_float ( float  n,
int  numDigits,
int  x,
int  y,
int  r,
int  g,
int  b,
float  size 
)

Prints out a float in 16 segment characters

Parameters
nThe float to display
numDigitsnumDigits is the number of digits to right of decimal to be printed
xThe X coordinate of the first character's top-left corner
yThe Y coordinate of the first character's top-left corner
rThe red component of the drawing, from 0 to 255
gThe green component of the drawing, from 0 to 255
bThe blue component of the drawing, from 0 to 255
sizeThe strings's size

◆ graphics_print_int()

int graphics_print_int ( int  n,
int  minNumDigits,
int  x,
int  y,
int  r,
int  g,
int  b,
float  size 
)

Prints out an integer in 16 segment characters

Parameters
nThe integer to display
minNumDigitsminNumDigits is normally 0, but can be larger if leading 0's are desired
xThe X coordinate of the first character's top-left corner
yThe Y coordinate of the first character's top-left corner
rThe red component of the drawing, from 0 to 255
gThe green component of the drawing, from 0 to 255
bThe blue component of the drawing, from 0 to 255
sizeThe strings's size

◆ graphics_print_string()

void graphics_print_string ( char  s[],
int  x,
int  y,
int  r,
int  g,
int  b,
float  size 
)

Prints out a text string in 16 segment characters

Parameters
sThe string to display
xThe X coordinate of the first character's top-left corner
yThe Y coordinate of the first character's top-left corner
rThe red component of the drawing, from 0 to 255
gThe green component of the drawing, from 0 to 255
bThe blue component of the drawing, from 0 to 255
sizeThe strings's size

◆ graphics_rectangle()

EXPORT_SYM void graphics_rectangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  r,
int  g,
int  b 
)

Draw an unfilled rectangle to the graphics window at the given coordinates.

Parameters
x1the X coordinate of the rectangle's top-left corner
y1the Y coordinate of the rectangle's top-left corner
x2the X coordinate of the rectangle's bottom-right corner
y2the Y coordinate of the rectangle's bottom-right corner
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_rectangle_fill()

EXPORT_SYM void graphics_rectangle_fill ( int  x1,
int  y1,
int  x2,
int  y2,
int  r,
int  g,
int  b 
)

Draw a filled rectangle to the graphics window at the given coordinates.

Parameters
x1the X coordinate of the rectangle's top-left corner
y1the Y coordinate of the rectangle's top-left corner
x2the X coordinate of the rectangle's bottom-right corner
y2the Y coordinate of the rectangle's bottom-right corner
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_segment_display()

void graphics_segment_display ( int  s[],
int  x,
int  y,
int  r,
int  g,
int  b,
float  size 
)

Draw a 16 segment character (alphameric - caps only)

Parameters
sThe segments to display
xThe X coordinate of the first segment's top-left corner
yThe Y coordinate of the first segment's top-left corner
rThe red component of the drawing, from 0 to 255
gThe green component of the drawing, from 0 to 255
bThe blue component of the drawing, from 0 to 255
sizeThe segment's size

◆ graphics_triangle()

EXPORT_SYM void graphics_triangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  r,
int  g,
int  b 
)

Draw an unfilled triangle to the graphics window at the given coordinates. The order of the corners does not matter when drawing a triangle.

Parameters
x1the X coordinate of the triangle's first corner
y1the Y coordinate of the triangle's first corner
x2the X coordinate of the triangle's second corner
y2the Y coordinate of the triangle's second corner
x3the X coordinate of the triangle's third corner
y3the Y coordinate of the triangle's third corner
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_triangle_fill()

EXPORT_SYM void graphics_triangle_fill ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  r,
int  g,
int  b 
)

Draw a filled triangle to the graphics window at the given coordinates. The order of the corners does not matter when drawing a triangle.

Parameters
x1the X coordinate of the triangle's first corner
y1the Y coordinate of the triangle's first corner
x2the X coordinate of the triangle's second corner
y2the Y coordinate of the triangle's second corner
x3the X coordinate of the triangle's third corner
y3the Y coordinate of the triangle's third corner
rthe red component of the drawing, from 0 to 255
gthe green component of the drawing, from 0 to 255
bthe blue component of the drawing, from 0 to 255

◆ graphics_update()

EXPORT_SYM void graphics_update ( )

Update must be called after drawing to the window for changes to be visible. This function also must be called regularly for input to work.