Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

gfxcore.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <assert.h>
#include "gfxcore.h"
#include "ztimer.h"
#include "misc.h"
#include "sysfont.cpp"

Go to the source code of this file.

Functions

void GFX_Init (Graphics *gfx, Bitmap *bm)
 Initialize a graphics structure.

void GFX_Init (Graphics *gfx, Graphics *gfx2)
 Copy a graphics context structure.

void GFX_SetFont (Graphics *gfx, Font *font)
 Set the current font.

void GFX_SetFillStyle (Graphics *gfx, char *style)
 Set the current fillStyle.

void GFX_SetColor (Graphics *gfx, int color)
void GFX_SetBlitMode (Graphics *gfx, int mode)
void GFX_MoveTo (Graphics *gfx, int x, int y)
 Set the current position to (x,y).

void GFX_MoveRel (Graphics *gfx, int dx, int dy)
 Move the current position by (dx,dy).

void GFX_HLine (Graphics *gfx, int x, int y, int w)
 Draw a horizontal line.

void GFX_VLine (Graphics *gfx, int x, int y, int h)
 Draw a vertical line.

void GFX_Line (Graphics *gfx, int x1, int y1, int x2, int y2)
 Draw a line using the bresenham algorithm.

void GFX_LineRel (Graphics *gfx, int dx, int dy)
 Draw a line relative from the current position.

void GFX_LineTo (Graphics *gfx, int x, int y)
 Draw a line from the current position to (x,y) and set (x,y) to be the new current position.

void GFX_Rectangle (Graphics *gfx, int x, int y, int w, int h)
 Draws a rectangle with upper left corner at (x,y) and with width w and height h.

void GFX_Circle (Graphics *gfx, int xc, int yc, int r)
 Draw a circle.

void GFX_FillRect (Graphics *gfx, int x, int y, int w, int h)
 Draw a filled rectangle.


Variables

struct {
   Bitmap   bitmap
   char   bmBits [GFX_SCRATCH_SIZE]
scratch
Bitmap_gfx_scratch = (Bitmap*)&scratch
Font_gfx_defaultFont = NULL
char emptyFill [] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
 fillStyles

char solidFill [] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
char lineFill [] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }
char ltSlashFill [] = { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }
char slashFill [] = { 0x99, 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33 }
char bkSlashFill [] = { 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc, 0x99 }
char ltBkSlashFill [] = { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }
char hatchFill [] = { 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55 }
char xHatchFill [] = { 0x55, 0x22, 0x55, 0x88, 0x55, 0x22, 0x55, 0x88 }
char xLeaveFill [] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }
char wDotFill [] = { 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44 }
char cDotFill [] = { 0x11, 0x44, 0x88, 0x22, 0x11, 0x44, 0x88, 0x22 }


Function Documentation

void GFX_Circle Graphics   gfx,
int    xc,
int    yc,
int    r
 

Draw a circle.

Parameters:
gfx  Graphics context to use.
xc,yc  coordinates of center point.
r  radius (in pixels)

Definition at line 416 of file gfxcore.cpp.

References Graphics::bitmap, BM_PutPixel(), and Graphics::color.

void GFX_FillRect Graphics   gfx,
int    x,
int    y,
int    w,
int    h
 

Draw a filled rectangle.

Parameters:
gfx  Graphics context to use.
x, y  coordinates for top-left corner
w, h  width and height
Bug:
the fillpattern does not move correctly, when clipped at the left or top border.

Definition at line 449 of file gfxcore.cpp.

References Graphics::bitmap, Graphics::blitMode, BM_FastBlit(), Bitmap::bmBits, Graphics::fillStyle, Bitmap::height, src, and Bitmap::width.

Referenced by GFX_ProgressBar().

void GFX_HLine Graphics   gfx,
int    x,
int    y,
int    w
 

Draw a horizontal line.

Note:
use this function directly instead of calling line whenever possible!

Definition at line 150 of file gfxcore.cpp.

References Graphics::bitmap, Bitmap::bmBits, Graphics::color, Bitmap::height, and Bitmap::width.

Referenced by GFX_Line(), GFX_Rectangle(), and GFX_RoundRect().

void GFX_Init Graphics   gfx,
Graphics   gfx2
 

Copy a graphics context structure.

This function is quite useful for creating a temporary context inside a drawing function. So You can change drawing modes without modifying the original context.

Parameters:
gfx  Pointer to Graphics structure.
bm  Pointer to Bitmap to work on.

Definition at line 81 of file gfxcore.cpp.

Referenced by GFX_ProgressBar(), and gfxTest().

void GFX_Init Graphics   gfx,
Bitmap   bm
 

Initialize a graphics structure.

All settings of the graphics contexts are reset to their default values.

Parameters:
gfx  Pointer to Graphics structure.
bm  Pointer to Bitmap to work on.

Definition at line 61 of file gfxcore.cpp.

References _font_sysfont, Graphics::bitmap, Graphics::blitMode, BLT_OR, Graphics::color, Graphics::fillStyle, Graphics::font, and solidFill.

void GFX_Line Graphics   gfx,
int    x1,
int    y1,
int    x2,
int    y2
 

Draw a line using the bresenham algorithm.

Parameters:
gfx  Graphics context to use.
x1, y1, x2, y2  line coordinates.
Note:
this function is quite slow, and optimizing it would take a somewhat great effort. (subpixel-accurate cohen- sutherland clipping should be implemented, assembler versions for 4 octants * 2 drawing colors..) If you really need a faster line implementation, drop a mail to thomas.kindler@gmx.de (a nice crate of beer might be helpful ;)

Definition at line 318 of file gfxcore.cpp.

References Graphics::bitmap, BM_PutPixel(), Graphics::color, GFX_HLine(), and GFX_VLine().

Referenced by GFX_LineRel(), GFX_LineTo(), and GFX_RoundRect().

void GFX_LineRel Graphics   gfx,
int    dx,
int    dy
 

Draw a line relative from the current position.

Parameters:
gfx  Graphics context to use.
dx, dy  distance from current position.

Definition at line 366 of file gfxcore.cpp.

References GFX_Line(), Graphics::x, and Graphics::y.

void GFX_LineTo Graphics   gfx,
int    x,
int    y
 

Draw a line from the current position to (x,y) and set (x,y) to be the new current position.

Parameters:
gfx  Graphics context to use.
x, y  end coordinates.

Definition at line 381 of file gfxcore.cpp.

References GFX_Line(), Graphics::x, and Graphics::y.

void GFX_MoveRel Graphics   gfx,
int    dx,
int    dy
 

Move the current position by (dx,dy).

Definition at line 137 of file gfxcore.cpp.

References Graphics::x, and Graphics::y.

void GFX_MoveTo Graphics   gfx,
int    x,
int    y
 

Set the current position to (x,y).

Definition at line 126 of file gfxcore.cpp.

References Graphics::x, and Graphics::y.

void GFX_Rectangle Graphics   gfx,
int    x,
int    y,
int    w,
int    h
 

Draws a rectangle with upper left corner at (x,y) and with width w and height h.

Parameters:
gfx  Graphics context to use.
x, y  coordinates for top-left corner
w, h  width and height

Definition at line 398 of file gfxcore.cpp.

References GFX_HLine(), and GFX_VLine().

Referenced by GFX_ProgressBar().

void GFX_SetBlitMode Graphics   gfx,
int    mode
 

Definition at line 116 of file gfxcore.cpp.

References Graphics::blitMode.

Referenced by GFX_ProgressBar().

void GFX_SetColor Graphics   gfx,
int    color
 

Definition at line 110 of file gfxcore.cpp.

References Graphics::color.

void GFX_SetFillStyle Graphics   gfx,
char *    style
 

Set the current fillStyle.

Definition at line 104 of file gfxcore.cpp.

References Graphics::fillStyle.

Referenced by GFX_ProgressBar().

void GFX_SetFont Graphics   gfx,
Font   font
 

Set the current font.

If font is NULL, the default font is set.

Definition at line 92 of file gfxcore.cpp.

References _font_sysfont, font, and Graphics::font.

Referenced by gfxTest().

void GFX_VLine Graphics   gfx,
int    x,
int    y,
int    h
 

Draw a vertical line.

Note:
use this function directly instead of calling line whenever possible!

Definition at line 227 of file gfxcore.cpp.

References Graphics::bitmap, Bitmap::bmBits, Graphics::color, fbm, Bitmap::height, lbm, pages, and Bitmap::width.

Referenced by GFX_Line(), GFX_Rectangle(), and GFX_RoundRect().


Variable Documentation

Font* _gfx_defaultFont = NULL
 

Definition at line 35 of file gfxcore.cpp.

Bitmap* _gfx_scratch = (Bitmap*)&scratch
 

Definition at line 34 of file gfxcore.cpp.

Bitmap bitmap
 

Definition at line 30 of file gfxcore.cpp.

char bkSlashFill[] = { 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc, 0x99 }
 

Definition at line 44 of file gfxcore.cpp.

char bmBits[GFX_SCRATCH_SIZE]
 

Definition at line 31 of file gfxcore.cpp.

Referenced by printScratch().

char cDotFill[] = { 0x11, 0x44, 0x88, 0x22, 0x11, 0x44, 0x88, 0x22 }
 

Definition at line 50 of file gfxcore.cpp.

char emptyFill[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
 

fillStyles

Definition at line 39 of file gfxcore.cpp.

char hatchFill[] = { 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55 }
 

Definition at line 46 of file gfxcore.cpp.

char lineFill[] = { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }
 

Definition at line 41 of file gfxcore.cpp.

char ltBkSlashFill[] = { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 }
 

Definition at line 45 of file gfxcore.cpp.

char ltSlashFill[] = { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 }
 

Definition at line 42 of file gfxcore.cpp.

struct { ... } scratch [static]
 

char slashFill[] = { 0x99, 0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33 }
 

Definition at line 43 of file gfxcore.cpp.

char solidFill[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
 

Definition at line 40 of file gfxcore.cpp.

Referenced by GFX_Init().

char wDotFill[] = { 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44 }
 

Definition at line 49 of file gfxcore.cpp.

char xHatchFill[] = { 0x55, 0x22, 0x55, 0x88, 0x55, 0x22, 0x55, 0x88 }
 

Definition at line 47 of file gfxcore.cpp.

char xLeaveFill[] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }
 

Definition at line 48 of file gfxcore.cpp.


Generated on Sun Aug 4 21:47:37 2002 for k/os mp3v2 by doxygen1.2.16