Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Graphics Class Reference

#include <Graphics.h>

List of all members.


Detailed Description

Provides basic graphics capabilities for drawing into any bitmap, particularly FilterBankGenerators.

Wherever possible, this should try to emulate the graphics API of Java 1 to minimize learning curve. For instance, the pen hangs down and to the right.

Definition at line 10 of file Graphics.h.

Public Member Functions

 Graphics (FilterBankGenerator &fbg, unsigned int layer, unsigned int channel)
 constructor, pass a FilterBankGenerator and layer/channel to draw into
 Graphics (unsigned char *base, unsigned int width, unsigned int height, unsigned int interval, unsigned int stride)
 constructor, directly specify an image buffer
void updateFBG ()
 If you want to reuse a graphics object across multiple frames from a FilterBankGenerator, call this after each new frame, but before you do any drawing.
void drawRect (int x, int y, int width, int height)
 Draws a rectange, upper left at x,y and extending right and down by width and height.
void drawRect (float x, float y, float width, float height)
 Draws a rectange, upper left at x,y and extending right and down by width and height.
void drawLine (int x1, int y1, int x2, int y2)
 Draws a line from (x1, y1) to (x2, y2).
void drawLine (float x1, float y1, float x2, float y2)
 Draws a line from (x1, y1) to (x2, y2).
void drawPoint (int x, int y)
 Draws a single point at (x1, y1).
void drawPoint (float x, float y)
 Draws a single point at (x1, y1).
void setColor (char color)
 Sets the "color" of the pen.
char getColor () const
 returns the "color" of the pen
void getPixelCoordinates (unsigned int &px, unsigned int &py, float x, float y) const
 sets the pixel-coordinate px and py parameters to the corresponding value of x and y
void getRealCoordinates (float &x, float &y, unsigned int px, unsigned int py) const
 sets the x and y parameters from the pixel-coordinates px and py

Protected Attributes

FilterBankGeneratorgen
 the filter bank generator we are drawing into, or NULL
unsigned int genLayer
 the layer within gen we are drawing into
unsigned int genChan
 the channel within gen we are drawing into
unsigned char * img
 the image we are currently drawing into (may need to be updated if gen is non-NULL, see updateFBG())
unsigned int w
 the width of img
unsigned int h
 the height of img
unsigned int xInc
 the number of bytes to skip to move horizontally one pixel in img
unsigned int yInc
 the number of bytes to skip to move vertically one pixel in img
unsigned char c
 the current pen color

Private Member Functions

 Graphics (const Graphics &)
 don't call (copy constructor)
Graphicsoperator= (const Graphics &)
 don't call (assignment operator)


Member Function Documentation

void Graphics::drawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)

Draws a line from (x1, y1) to (x2, y2).

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Definition at line 118 of file Graphics.cc.

Referenced by drawLine().

void Graphics::drawPoint ( int  x,
int  y 
) [inline]

Draws a single point at (x1, y1).

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Definition at line 44 of file Graphics.h.

Referenced by drawPoint().

void Graphics::drawRect ( int  x,
int  y,
int  width,
int  height 
)

Draws a rectange, upper left at x,y and extending right and down by width and height.

This expects direct-pixel coordinates, so make sure you check the width and height of the layer you are drawing into

Definition at line 39 of file Graphics.cc.

Referenced by drawRect().

char Graphics::getColor (  )  const [inline]

returns the "color" of the pen

Currently we don't support multi-channel drawing, so you have to draw into each channel separately to do real color based drawing, but maybe someday we'll add a color class.
In the mean time, this is just the byte that's going to be used to fill in wherever the pen traces

Definition at line 71 of file Graphics.h.

void Graphics::getPixelCoordinates ( unsigned int &  px,
unsigned int &  py,
float  x,
float  y 
) const

sets the pixel-coordinate px and py parameters to the corresponding value of x and y

Parameters:
[out] px the pixel position, relative to left edge, positive right, ranges 0 through width-1
[out] py the pixel position, relative to top edge, positive down, ranges 0 through height-1
[in] x the horizontal position, relative to center of the image, left edge is -1 and right edge is 1; no boundary checking is done
[in] y the vertical pixel position, relative to center of the image, top edge is the negative aspect ratio, bottom edge is positive aspect ratio; no boundary checking is done
To keep the coordinate system square, the x is defined to range -1,1, but y's range depends on the aspect ratio of the image, height/width. Thus typically y will approx. -.75,.75

Definition at line 216 of file Graphics.cc.

Referenced by drawLine(), drawPoint(), and drawRect().

void Graphics::getRealCoordinates ( float &  x,
float &  y,
unsigned int  px,
unsigned int  py 
) const

sets the x and y parameters from the pixel-coordinates px and py

Parameters:
[out] x the horizontal position, relative to center of the image, left edge is -1 and right edge is 1; no boundary checking is done
[out] y the vertical pixel position, relative to center of the image, top edge is the negative aspect ratio, bottom edge is positive aspect ratio; no boundary checking is done
[in] px the pixel position, relative to left edge, positive right, ranges 0 through width-1
[in] py the pixel position, relative to top edge, positive down, ranges 0 through height-1
To keep the coordinate system square, the x is defined to range -1,1, but y's range depends on the aspect ratio of the image, height/width. Thus typically y will approx. -.75,.75

Definition at line 227 of file Graphics.cc.

void Graphics::setColor ( char  color  )  [inline]

Sets the "color" of the pen.

Currently we don't support multi-channel drawing, so you have to draw into each channel separately to do real color based drawing, but maybe someday we'll add a color class.
In the mean time, this is just the byte that's going to be used to fill in wherever the pen traces

Definition at line 64 of file Graphics.h.

void Graphics::updateFBG (  ) 

If you want to reuse a graphics object across multiple frames from a FilterBankGenerator, call this after each new frame, but before you do any drawing.

This is automatically called by the constructor, so you don't need to do it if you constructor a fresh Graphics object for each frame. But otherwise you'll need this to update img, w, h, xInc, and yInc from the current frame available in gen

Definition at line 29 of file Graphics.cc.

Referenced by Graphics().


The documentation for this class was generated from the following files:

Tekkotsu v3.0
Generated Fri May 11 20:08:11 2007 by Doxygen 1.4.7