Graphics Struct Reference

Inheritance diagram for Graphics

Inheritance graph

Collaboration diagram for Graphics:

Collaboration graph


Public Methods

struct Graphics* Graphics_ctor (struct Graphics *ptr_gfx)
struct Graphics* Graphics_ctor_Ex (struct Graphics *ptr_gfx, struct Bitmap *bitmap)
void Graphics_dtor (struct Graphics *ptr_gfx, int memory_flag)
void Graphics_draw_bitmap (struct Graphics *ptr_gfx, struct Bitmap *bmp, int left, int top, short fm)
int Graphics_draw_char (struct Graphics *ptr_gfx, int x, int y, char fc)
void Graphics_draw_text (struct Graphics *ptr_gfx, char *text, int left, int top)
void Graphics_draw_text_Ex (struct Graphics *ptr_gfx, char *str, int left, int top, int len)
struct BitmapGraphics_get_bitmap (struct Graphics *ptr_gfx)
int Graphics_get_char_height (struct Graphics *ptr_gfx)
int Graphics_get_char_width (struct Graphics *ptr_gfx, char chr)
struct FontGraphics_get_font (struct Graphics *ptr_gfx)
int Graphics_string_width (struct Graphics *ptr_gfx, char *str)
int Graphics_string_width_Ex (struct Graphics *ptr_gfx, char *str, int len)
void Graphics_set_bitmap (struct Graphics *ptr_gfx, struct Bitmap *bmp)
void Graphics_set_font (struct Graphics *ptr_gfx, struct Font *font)
void Graphics_scroll (struct Graphics *ptr_gfx, struct rect_t *ptr_rectangle, int dx, int dy)
void Graphics_draw_hline (struct Graphics *ptr_gfx, int x, int y, int xx)
void Graphics_draw_vline (struct Graphics *ptr_gfx, int x, int y, int yy)
void Graphics_draw_line (struct Graphics *ptr_gfx, int x, int y, int xx, int yy)
void Graphics_draw_rect (struct Graphics *ptr_gfx, int fx, int fy, int fw, int fh)
void Graphics_draw_rect_Ex (struct Graphics *ptr_gfx, struct rect_t *ptr_rectangle)
void Graphics_fill_rect (struct Graphics *ptr_gfx, int fx,int fy, int fw, int fh)
void Graphics_fill_rect_Ex (struct Graphics *ptr_gfx, struct rect_t *ptr_rectangle)
void Graphics_fill_screen (struct Graphics *ptr_gfx, color_t fc)
int Graphics_get_bytes_total (struct Graphics *ptr_gfx)
void Graphics_set_clip (struct Graphics *ptr_gfx, int fx, int fy, int fw, int fh)
void Graphics_get_clip (struct Graphics *ptr_gfx, struct rect_t *ptr_rectangle)
void Graphics_set_clip_Ex (struct Graphics *ptr_gfx, struct rect_t *ptr_rectangle)
color_t Graphics_get_color (struct Graphics *ptr_gfx)
void Graphics_set_color (struct Graphics *ptr_gfx, color_t fc)
drawmode_t Graphics_get_draw_mode (struct Graphics *ptr_gfx)
void Graphics_set_draw_mode (struct Graphics *ptr_gfx, drawmode_t dm)
void Graphics_put_background (struct Graphics *ptr_gfx, char *fp)
color_t Graphics_get_pixel (struct Graphics *ptr_gfx, int fx, int fy)
void Graphics_set_pixel (struct Graphics *ptr_gfx, int fx, int fy, color_t fc)
char* Graphics_get_buf_addr (struct Graphics *ptr_gfx)
void Graphics_set_bkcolor (struct Graphics *ptr_gfx, color_t fc)


Detailed Description

The Graphics structure uses bitmaps to maintain many operations. The DisplayGraphics structure allows you to draw operations directly on the screen. You can draw graphics primitives,as well as text with the current font.

Because TGraph is its parent structure, the Graphics structure's functions are defined in TGraph structure. For example, manipulations of graphics primitives are implemented in TGraph structure.

To use some Graphics functions, you must obtain the Display Graphics Context from the init_module function. This context has only one parameter (the main application module parameter) and it must be obtained from the module_t structure.

See examples for related functions.

See also:
Drawing Primitives and Screen Manipulation


Member Function Documentation

struct Graphics * Graphics_ctor ( struct Graphics * ptr_gfx )
 

Simple Graphics constructor.
Creates an empty Graphics object.

Parameters:
ptr_gfx   A pointer to the Graphics structure
Returns:
A pointer to the initialized Graphics object
   #include <cybiko.h>
     ...
     struct Graphics gfx;
     Graphics_ctor( &gfx );
     ...
     Graphics_dtor( &gfx, LEAVE_MEMORY );
See also:
Graphics_ctor_Ex.

struct Graphics * Graphics_ctor_Ex ( struct Graphics * ptr_gfx,
struct Bitmap * bitmap )
 

The extended version of the Graphics_ctor function.
Creates a Graphics object that is associated with a Bitmap object.

Parameters:
ptr_gfx   A pointer to a Graphics object
bitmap   A pointer to a Bitmap object
Returns:
A pointer to the initialized Graphics object
   #include <cybiko.h>
     ...
     struct Bitmap  bitmap;
     struct Graphics gfx;
     ...
     Bitmap_ctor_Ex1( &bitmap, "screen.pic" );
     Graphics_ctor_Ex( &gfx, &bitmap );
     ...
     Graphics_dtor( &gfx, LEAVE_MEMORY );
     Bitmap_dtor( &bitmap, LEAVE_MEMORY );
See also:
Graphics_ctor.

void Graphics_draw_bitmap ( struct Graphics * ptr_gfx,
struct Bitmap * bmp,
int left,
int top,
short fm )
 

Allows the bitmap 'bmp' to be drawn in a specified position (left, top) in 'fm' mode.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
bmp   A pointer to the initialized Bitmap object
left   x-coordinate of the point where bitmap will be placed
top   y-coordinate of the point where bitmap will be placed
fm   Drawing mode
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct Bitmap bitmap;
     ...
     init_module( &main_module );
     Bitmap_ctor_Ex1( &bitmap, "screen.pic" );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_draw_bitmap( main_module.m_gfx, &bitmap, 30, 40, BM_NORMAL );
     ...
See also:
BM_NORMAL, BM_INVERSE, BM_FLIP_X, BM_FLIP_Y.

int Graphics_draw_char ( struct Graphics * ptr_gfx,
int x,
int y,
char fc )
 

Allows the character 'fc' to be drawn in the current font in specified position (x, y).

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
x   x-coordinate of the point where the char will be places
y   y-coordinate of the point where the char will be places
fc   A char to be drawn
Returns:
The position of the next pixel after the 'fc' character
   #include <cybiko.h>
     ...
     int pos;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     pos = Graphics_draw_char( main_module.m_gfx, 10, 10, 'c' );
     ...
See also:
Graphics_draw_text.

void Graphics_draw_hline ( struct Graphics * ptr_gfx,
int x,
int y,
int xx )
 

Draws a horizontal line from point (x , y) to point (xx , y).

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
x   x-coordinate of the horizontal line's starting point
y   y-coordinate of the horizontal line's starting point
xx   x-coordinate of the horizontal line's finishing point
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     TGraph_set_color( main_module.m_gfx, CLR_LTGRAY );
     Graphics_draw_hline( main_module.m_gfx, 10, 10, 60 );
     ...
See also:
Graphics_draw_line, Graphics_draw_vline.

void Graphics_draw_line ( struct Graphics * ptr_gfx,
int x,
int y,
int xx,
int yy )
 

Draws a solid line from point ( x , y ) to point ( xx , yy ).

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
x   x-coordinate of the line's starting point
y   y-coordinate of the line's starting point
xx   x-coordinate of the line's finishing point
yy   y-coordinate of the line's finishing point
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     int pos;
     ...
     init_module( &main_module );
     TGraph_set_color( main_module.m_gfx, CLR_LTGRAY );
     Graphics_draw_line( main_module.m_gfx, 10, 10, 20, 20);
     ...
See also:
Graphics_draw_vline, Graphics_draw_hline.

void Graphics_draw_rect ( struct Graphics * ptr_gfx,
int fx,
int fy,
int fw,
int fh )
 

Draws a rectangular frame in the current color.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
fx   The rectangle's left coordinate
fy   The rectangle's top coordinate
fw   The rectangle's width
fh   The rectangle's height
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     int pos;
     ...
     init_module( &main_module );
     TGraph_set_color( main_module.m_gfx, CLR_LTGRAY );
     Graphics_draw_rect( main_module.m_gfx, 10, 10, 20, 20);
     ...
See also:
Graphics_draw_rect_Ex.

void Graphics_draw_rect_Ex ( struct Graphics * ptr_gfx,
struct rect_t * ptr_rectangle )
 

Duplicates the Graphics_draw_rect function.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
ptr_rectangle   A pointer to a tect_t object
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct rect_t rectangle={0,0,100,100};
     ...
     init_module( &main_module );
     TGraph_set_color( main_module.m_gfx, CLR_LTGRAY );
     Graphics_draw_rect_Ex( main_module.m_gfx, &rectangle );
     ...
See also:
Graphics_draw_rect.

void Graphics_draw_text ( struct Graphics * ptr_gfx,
char * text,
int left,
int top )
 

Allows 'text' to be drawn in the current font, in the specified position (left , top).

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
text   A pointer to the string to be drawn
left   x-coordinate of the string to be drawn
top   y-coordinate of the string to be drawn
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     Graphics_draw_text( main_module.m_gfx, "Any text", 10, 10 );
     ...
See also:
Graphics_draw_text_Ex, Graphics_draw_char.

void Graphics_draw_text_Ex ( struct Graphics * ptr_gfx,
char * str,
int left,
int top,
int len )
 

Duplicates the Graphics_draw_text function.
If the length of the string exceeds the number of 'flen' pixels, the string will be truncated.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
str   A pointer to the string to be drawn
left   x-coordinate of the place where the string to be drawn
top   y-coordinate of the place where the string to be drawn
len   A maximum number of chars to draw
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     Graphics_draw_text_Ex( main_module.m_gfx, "Any Text", 10, 10, 20 );
     ...
See also:
Graphics_draw_text.

void Graphics_draw_vline ( struct Graphics * ptr_gfx,
int x,
int y,
int yy )
 

Draws a vertical line from point (x , y) to point (x , yy).

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
x   x-coordinate of the vertical line's starting point
y   y-coordinate of the vertical line's starting point
yy   y-coordinate of the vertical line's finishing point
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     TGraph_set_color( main_module.m_gfx, CLR_LTGRAY );
     Graphics_draw_vline( main_module.m_gfx, 10, 10, 20);
     ...
See also:
Graphics_draw_line, Graphics_draw_hline.

void Graphics_dtor ( struct Graphics * ptr_gfx,
int memory_flag )
 

Deletes a Graphics object.

Parameters:
ptr_gfx   A pointer to the Graphics structure
memory_flag   Can be FREE_MEMORY or LEAVE_MEMORY. If the memory was allocated for the object by malloc(), use FREE_MEMORY to free it. Use LEAVE_MEMORY If the object was static or allocated in a stack
Returns:
None
   #include <cybiko.h>
     ...
     struct Graphics gfx;
     Graphics_ctor( &gfx );
     ...
     Graphics_dtor( &gfx, LEAVE_MEMORY );
See also:
FREE_MEMORY, LEAVE_MEMORY.

void Graphics_fill_rect ( struct Graphics * ptr_gfx,
int fx,
int fy,
int fw,
int fh )
 

Fills a rectangle with the current color.
The rectangle is defined by fx, fy, fw, and fh parameters.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
fx   The rectangle's left coordinate
fy   The rectangle's top coordinate
fw   The rectangle's width
fh   The rectangle's height
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     int pos;
     ...
     init_module( &main_module );
     TGraph_set_color( main_module.m_gfx, CLR_LTGRAY );
     Graphics_fill_rect( main_module.m_gfx, 10, 10, 20, 20);
     ...
See also:
Graphics_fill_rect_Ex.

void Graphics_fill_rect_Ex ( struct Graphics * ptr_gfx,
struct rect_t * ptr_rectangle )
 

Duplicates the Graphics_fill_rect function.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
ptr_rectangle   A pointer to a tect_t object
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct rect_t rectangle={0,0,100,100};
     ...
     init_module( &main_module );
     TGraph_set_color( main_module.m_gfx, CLR_LTGRAY );
     Graphics_fill_rect_Ex( main_module.m_gfx, &rectangle );
     ...
See also:
Graphics_fill_rect.

void Graphics_fill_screen ( struct Graphics * ptr_gfx,
color_t fc )
 

Fills the screen with the 'fc' color.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
fc   A value of the color
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     Graphics_fill_screen( main_module.m_gfx, CLR_LTGRAY);
     ...
See also:
CLR_WHITE, CLR_LTGRAY, CLR_DKGRAY, CLR_BLACK.

struct Bitmap * Graphics_get_bitmap ( struct Graphics * ptr_gfx )
 

Returns the current Bitmap context for drawing.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
Returns:
A pointer to the current Graphics page's Bitmap object
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct Bitmap * bitmap;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     bitmap = Graphics_get_bitmap( main_module.m_gfx );
     ...
See also:
Graphics_set_bitmap.

char * Graphics_get_buf_addr ( struct Graphics * ptr_gfx )
 

Returns a pointer to the Graphics object's associated image.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
Returns:
A pointer to the Graphics object's associated image.
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct Graphics gfx_fp;
     ...
     Graphics_put_background( main_module.m_gfx,
       Graphics_get_buf_addr( &gfx_fp )) ;
     ...

int Graphics_get_bytes_total ( struct Graphics * ptr_gfx )
 

Returns the total number of bytes in the screen buffer.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
Returns:
The total number of bytes in the screen buffer
   #include <cybiko.h>
     ...
     struct module_t main_module;
     char* ptr_display_buffer;
     ...
     init_module( &main_module );
     ptr_display_buffer = (char* ) malloc( Graphics_get_bytes_total( main_module.m_gfx ) );
     ...

int Graphics_get_char_height ( struct Graphics * ptr_gfx )
 

Returns the current font's height.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
Returns:
The current font's height
   #include <cybiko.h>
     ...
     int font_height;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     font_height = Graphics_get_char_height( main_module.m_gfx );
     ...
See also:
Graphics_get_char_width, Graphics_get_font.

int Graphics_get_char_width ( struct Graphics * ptr_gfx,
char chr )
 

Returns the current font's character width.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
chr   A character
Returns:
The current font's character width
   #include <cybiko.h>
     ...
     int char_width;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     char_width = Graphics_get_char_width( main_module.m_gfx, 'g' );
     ...
See also:
Graphics_get_char_height, Graphics_get_font.

void Graphics_get_clip ( struct Graphics * ptr_gfx,
struct rect_t * ptr_rectangle )
 

Returns a clip region.
It is defined by coordinates that are stored in a rect_t object.

Parameters:
ptr_gfx   A pointer to a Graphics object
ptr_rectangle   A pointer to a rect_t object
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct rect_t clip_region;
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_clip_Ex( main_module.m_gfx, &clip_region );
     if ( (clip_region.x != 0) || ( clip_region.y != 0) ||
          ( clip_region.w != SCREEN_WIDTH) ||( clip_region.h != SCREEN_HEIGHT) )
           Graphics_set_clip( main_module.m_gfx, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
     ...
See also:
Graphics_set_clip.

color_t Graphics_get_color ( struct Graphics * ptr_gfx )
 

Returns the current foreground color.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
Returns:
The current foreground color
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     if ( Graphics_get_color( main_module.m_gfx ) != CLR_LTGRAY )
     Graphics_set_color( main_module.m_gfx, CLR_LTGRAY);
     ...
See also:
Graphics_set_color.

drawmode_t Graphics_get_draw_mode ( struct Graphics * ptr_gfx )
 

Returns the current draw mode.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
Returns:
The current draw mode
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     if ( Graphics_get_draw_mode( main_module.m_gfx ) != DM_PUT )
     Graphics_set_draw_mode( main_module.m_gfx, DM_PUT);
     ...
See also:
Graphics_set_draw_mode, DM_PUT, DM_OR, DM_XOR.

struct Font * Graphics_get_font ( struct Graphics * ptr_gfx )
 

Returns the current font.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
Returns:
A pointer to the current font
   #include <cybiko.h>
     ...
     struct Font * ptr_font;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     ...
     ptr_font = Graphics_get_font( main_module.m_gfx );
     ...
See also:
Graphics_set_font.

color_t Graphics_get_pixel ( struct Graphics * ptr_gfx,
int fx,
int fy )
 

Returns the color of the pixel with coordinate ( fx , fy ).

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
fx   An x-coordinate of the required pixel
fy   An y-coordinate of the required pixel
Returns:
The color of the pixel with coordinate ( fx , fy )
   #include <cybiko.h>
     ...
     struct module_t main_module;
     if ( Graphics_get_pixel( main_module.m_gfx, 10, 30 ) == CLR_BLACK )
          Graphics_set_pixel( main_module.m_gfx, 10, 30, CLR_WHITE );
     ...
See also:
Graphics_set_pixel.

void Graphics_put_background ( struct Graphics * ptr_gfx,
char * fp )
 

Treats fp as a pointer to a background image and sends the image to its destination.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
fp   A pointer to the background image
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct Graphics gfx_fp;
     ...
     Graphics_put_background( main_module.m_gfx,
                              Graphics_get_buf_addr( &gfx_fp )) ;
     ...

void Graphics_scroll ( struct Graphics * ptr_gfx,
struct rect_t * ptr_rectangle,
int dx,
int dy )
 

Scrolls a rectangle area that is defined by delta x, delta y in 'ptr_rectangle'.

Parameters:
ptr_gfx   A pointer to the Graphics structure
ptr_rectangle   A pointer to the rectangle to be scrolled
dx   A horizontal scroll shift value
dy   A vertical scroll shift value
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     init_module(&main_module);
     ...
     TGraph_fill_rect( main_module.m_gfx, 10, 10, 20, 40 );
     DisplayGraphics_show( main_module.m_gfx );
     ...
     // Make some graphic operation
     ...
     Graphics_scroll( main_module.m_gfx, 10, 10, 20, 40, 10, 10 );
     DisplayGraphics_show( main_module.m_gfx );
     ...

void Graphics_set_bitmap ( struct Graphics * ptr_gfx,
struct Bitmap * bmp )
 

Sets a bitmap 'bmp' as the destination for drawings.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
bmp   A pointer to the destination bitmap
Returns:
None
   #include <cybiko.h>
     ...
     struct Bitmap bitmap;
     struct Graphics vgfx;
     ...
     Graphics_ctor( &vgfx );
     // SCREEN_WIDTH and SCREEN_HEIGHT are described in the 'Defines' section.
     Bitmap_ctor_Ex2( &bitmap, SCREEN_WIDTH, SCREEN_HEIGHT, 2 );
     ...
     // Now all drawing operations in the 'vgfx' graphics context will be performed on the 'bitmap' object.
     Graphics_set_bitmap( &vgfx, &bitmap );
     ...
See also:
Graphics_get_bitmap.

void Graphics_set_bkcolor ( struct Graphics * ptr_gfx,
color_t fc )
 

Sets the current background color by calling TGraph_set_bkcolor.

Parameters:
ptr_gfx   A pointer to a TGraph object
fc   A color_t object
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct Bitmap bmp;
     ...
     init_module( &main_module );
     // Creates a bitmap from the file "root.ico".
     Bitmap_ctor_Ex1( &bmp, "root.ico" );
     ...
     // Set draw mode to mode OR.
     Graphics_set_draw_mode( main_module.m_gfx, DM_OR );
     // Set transparent color to CLR_BLACK
     Graphics_set_bkcolor( main_module.m_gfx, CLR_BLACK );
     // Draw all pixels of the bitmap except pixels with CLR_BLACK color.
     Graphics_draw_bitmap( main_module.m_gfx, &bmp, 30, 40, BM_NORMAL );
     ...
     Bitmap_dtor( &bmp, LEAVE_MEMORY );
     ...
See also:
TGraph_set_bkcolor, CLR_WHITE, CLR_LTGRAY, CLR_DKGRAY, CLR_BLACK.

void Graphics_set_clip ( struct Graphics * ptr_gfx,
int fx,
int fy,
int fw,
int fh )
 

Sets a clip region, defined by the coordinates stored in the fx, fy, fw, and fh parameters.

Parameters:
ptr_gfx   A pointer to a Graphics object
fx   x-coordinate of the upper-left corner of the area to be clipped
fy   y-coordinate of the upper-left corner of the area to be clipped
fw   Width of the area to be clipped
fh   Height of the area to be clipped
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_clip ( main_module.m_gfx, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
     ...
See also:
Graphics_set_clip_Ex, Graphics_get_clip.

void Graphics_set_clip_Ex ( struct Graphics * ptr_gfx,
struct rect_t * ptr_rectangle )
 

Duplicates the Graphics_set_clip function.
The region coordinates are stored in a rect_t object.

Parameters:
ptr_gfx   A pointer to a TGraph object
ptr_rectangle   A pointer to a rect_t object. By this structure we can define the region coordinates
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     struct rect_t clip_region;
     struct rect_t new_clip_reg;
     init_module( &main_module );
     ...
     new_clip_reg.x = 10;
     new_clip_reg.y = 10;
     new_clip_reg.h = 100;
     new_clip_reg.w = 100;
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     TGraph_get_clip ( main_module.m_gfx, &clip_region );
     if ( (clip_region.x != 0) || ( clip_region.y != 0) ||
          ( clip_region.w != SCREEN_WIDTH) ||( clip_region.h != SCREEN_HEIGHT) )
           TGraph_set_clip_Ex( main_module.m_gfx, &new_clip_reg );
     ...
See also:
Graphics_set_clip.

void Graphics_set_color ( struct Graphics * ptr_gfx,
color_t fc )
 

Sets the current foreground color.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
fc   A color value
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     if ( Graphics_get_color( main_module.m_gfx ) != CLR_LTGRAY )
     Graphics_set_color( main_module.m_gfx, CLR_LTGRAY);
     ...
See also:
Graphics_get_color, CLR_WHITE, CLR_LTGRAY, CLR_DKGRAY, CLR_BLACK.

void Graphics_set_draw_mode ( struct Graphics * ptr_gfx,
drawmode_t dm )
 

Sets the current draw mode.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
dm   A draw mode
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     if ( Graphics_get_draw_mode( main_module.m_gfx ) != DM_PUT )
     Graphics_set_draw_mode( main_module.m_gfx, DM_PUT);
     ...
See also:
Graphics_get_draw_mode, DM_PUT, DM_OR, DM_XOR.

void Graphics_set_font ( struct Graphics * ptr_gfx,
struct Font * font )
 

Sets the current font.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
font   A pointer to the initialized Font object
Returns:
None
   #include <cybiko.h>
     ...
     int str_plen;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     ...
See also:
Graphics_get_font.

void Graphics_set_pixel ( struct Graphics * ptr_gfx,
int fx,
int fy,
color_t fc )
 

The color, defined by the 'fc' parameter.
Sets the color of the pixel at coordinates ( fx , fy ).

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
fx   x-coordinate of the required pixel
fy   y-coordinate of the required pixel
fc   A color value
Returns:
None
   #include <cybiko.h>
     ...
     struct module_t main_module;
     if ( Graphics_get_pixel( main_module.m_gfx, 10, 30 ) == CLR_BLACK )
          Graphics_set_pixel( main_module.m_gfx, 10, 30, CLR_WHITE );
     ...
See also:
Graphics_get_pixel, CLR_WHITE, CLR_LTGRAY, CLR_DKGRAY, CLR_BLACK.

int Graphics_string_width ( struct Graphics * ptr_gfx,
char * str )
 

Returns the width (in pixels) of a string 'str' for the current font.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
str   A pointer to the string
Returns:
The width (in pixels) of a string for the current font
   #include <cybiko.h>
     ...
     int str_plen;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     ...
     str_plen = Graphics_string_width( main_module.m_gfx, "Any string" );
     ...
See also:
Graphics_string_width_Ex.

int Graphics_string_width_Ex ( struct Graphics * ptr_gfx,
char * str,
int len )
 

The extended version of the Graphics_string_width function.
Returns the width (in pixels) of the first 'len' symbols of a string 'str'.

Parameters:
ptr_gfx   A pointer to the initialized Graphics object
str   A pointer to the string
len   A maximum possible length of the drawn string
Returns:
The width (in pixels) of the first 'len' symbols of a string
   #include <cybiko.h>
     ...
     int str_plen;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // main_module.m_gfx is a pointer to the Cybiko graphics context.
     Graphics_set_font( main_module.m_gfx, cool_normal_font );
     ...
     str_plen = Graphics_string_width_Ex( main_module.m_gfx, "Any string", 20 );
     ...
See also:
Graphics_string_width.