Drawing Primitives and Screen Manipulation


Defines

#define SCREEN_WIDTH   160
#define SCREEN_HEIGHT   100
#define CLR_WHITE   0
#define CLR_LTGRAY   85
#define CLR_DKGRAY   171
#define CLR_BLACK   255
#define DM_PUT   0
#define DM_OR   1
#define DM_XOR   2
#define ARROW_UP   0x01
#define ARROW_DOWN   0x02

Typedefs

typedef int color_t
typedef int drawmode_t

Enumerations

enum  {
  RR_NONE = 0,
  RR_ARROWUP = ARROW_UP,
  RR_ARROWDOWN = ARROW_DOWN,
  RR_ROUND = 4,
  RR_ERASE = 8
}

Functions

void draw_roundrect (struct Graphics *ptr_graphics, struct rect_t *ptr_rectangle, int style, char *sz_caption)
void draw_bar (int x, int y, int width, int height, color_t color, bool xor_mode)
void rect (int x, int y, int width, int height, color_t color)
bool in_rect (int x, int y, struct rect_t *ptr_rectangle)


Compounds

     struct   DisplayGraphicsThis structure is designated to execute any draw operation on the cybiko computer's display. This structure is designated to execute any draw operation on the Cybiko computer's display. If you want to make draw operations on a bitmap object, it's best to use the Graphics structure. The Cybiko computer features two displays; one of them virtual. We refer to these displays as 'graphics pages.' The draw operations are performed on the virtual graphics page, and then shown as the Cybiko screen's graphics page
     struct   GraphicsThis structure allows draw operations to be applied to Bitmap objects
     struct   rect_tA rectangle
     struct   TGraphThe implementation of raster and 2D-graphics. It is designated for work with primitive graphics such as rectangles, lines and pixels


Detailed Description

These structures and functions are used for drawing various graphical primitives and displaying them onscreen. Please pay special attention to the DisplayGraphics and Graphics structures.


Define Documentation

#define ARROW_DOWN   0x02
 

Arrow down.

#define ARROW_UP   0x01
 

Arrow up.

#define CLR_BLACK   255
 

Make the object black.

#define CLR_DKGRAY   171
 

Make the object dark gray.

#define CLR_LTGRAY   85
 

Make the object light gray.

#define CLR_WHITE   0
 

Make the object white.

#define DM_OR   1
 

Make the image opaque; do not allow background color to show through the object.
See set_bckcolor().

#define DM_PUT   0
 

Place the image as is.

#define DM_XOR   2
 

XOR pixels overlay bitmap pixels.

#define SCREEN_HEIGHT   100
 

Cybiko computer's screen height.

#define SCREEN_WIDTH   160
 

Cybiko computer's screen width.


Typedef Documentation

typedef int color_t
 

Display color.
Must be one of the following: CLR_WHITE, CLR_LTGRAY, CLR_DKGRAY or CLR_BLACK.

See also:
CLR_WHITE, CLR_LTGRAY, CLR_DKGRAY, CLR_BLACK.

typedef int drawmode_t
 

Drawing mode.
Must be one of the following: DM_PUT, DM_OR or DM_XOR.

See also:
DM_PUT, DM_OR, DM_XOR.


Enumeration Type Documentation

anonymous enum
 

Custom rectangle styles.

See also:
ARROW_UP, ARROW_DOWN.
Enumeration values:
RR_NONE   Simple rectangle.
RR_ARROWUP   Rectangle with an arrow at the top pointing up.
RR_ARROWDOWN   Rectangle with an arrow at the top pointing down.
RR_ROUND   Rectangle with rounded corners.
RR_ERASE   Clear background.


Function Documentation

void draw_bar ( int x,
int y,
int width,
int height,
color_t color,
bool xor_mode )
 

Fills a rectangle with a specified color, to form a color bar.

Parameters:
x   the x-coordinate of the upper-left corner
y   the y-coordinate of the upper-left corner
width   the bar's width
height   the bar's height
color   the bar's color
xor   if TRUE xor operation will be performed
Returns:
None.
        #include <cywin.h>
        ...
        draw_bar( 10, 10, 100, 100, CLR_DKGRAY, FALSE );
        ...

void draw_roundrect ( struct Graphics * ptr_graphics,
struct rect_t * ptr_rectangle,
int style,
char * sz_caption )
 

Draws a custom rectangle with caption.
There are five rectangle styles: RR_NONE, RR_ARROWUP, RR_ARROWDOWN, RR_ROUND and RR_ERASE.

Parameters:
ptr_graphics   a pointer to an initialized Graphics object.
ptr_rectangle   a pointer to the bounding rectangle.
style   the rectangle's style.
sz_caption   the rectangle's caption.
Returns:
None.
        #include <cywin.h>
        ...
        struct rect_t rect;
        struct module_t main_module;
        ...
        init_module( &main_module );
        rect_set( &rect, 10, 10, 100, 100 );
        ...
        draw_roundrect( main_module.m_gfx, &rect, RR_ROUND, "Rect caption" );
        ...

bool in_rect ( int x,
int y,
struct rect_t * ptr_rectangle )
 

Returns TRUE if the point is in the rectangle area.

Parameters:
x   the point's x-coordinate.
y   the point's y-coordinate.
ptr_rectangle   the pointer to the rectangle.
Returns:
TRUE if the point is in the rectangle.
        #include <cywin.h>
        ...
        int x;
        int y;
        struct rect_t rect_screen;
        ...
        rect_set( &rect_screen, 0, 0, 160, 100 );
        ...
        if ( !in_rect( x, y, &rect_screen ) )
        {
          TRACE( "Warning: Object is out of screen.");
        }
        ...

void rect ( int x,
int y,
int width,
int height,
color_t color )
 

Draws a rectangle with the specified color.

Parameters:
x   the x-coordinate of the upper-left corner.
y   the y-coordinate of the upper-left corner.
width   the rectangle's width.
height   the rectangle's height.
color   the rectangle's color.
Returns:
None.
        #include <cywin.h>
        ...
        rect( 10, 10, 100, 100, CLR_DKGRAY );
        ...