Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

GCanvas Class Reference

Simple 2D graphics canvas. More...

List of all members.

Public Member Functions

void GCanvas (Integer width, Integer height, Integer bgcolor)
 Constructs a 2D image drawing canvas.

void polyline (Array x, Array y, Integer color)
 Draws a polyline.

void draw (Integer x, Integer y, Integer color)
 Puts a pixel of the defined color in the position x,y.

void circle (Integer xc, Integer yc, Integer r, Integer color)
 Draws a circle (Bresenham's algorithm).

void clear ()
 Clears the whole canvas using default background color.

Integer getcolor (void x, void y)
 Gets a color of a pixel in the position x,y.

void fill (Integer x, Integer y, Integer color)
 Fills a closed area (using stack).

void ellipse (Integer xc, Integer yc, Integer a, Integer b, Integer color)
 Draws an ellipse (Bresenham's algorithm).

void polygon (Array x, Array y, Integer color)
 Draws a polygon (automatically closed if last points are not identical.

void line (Integer x1, Integer y1, Integer x2, Integer y2, Integer color)
 Draws a line (Bresenham's algorithm).


Public Attributes

Integer width
 The width of the canvas.

Integer height
 The height of the canvas.

Array image
 Internal array representing the image canvas.

String bgcolor
 The background color of the canvas (HTML format string).


Detailed Description

Simple 2D graphics canvas.

x=0,y=0 - top left corner of the canvas. x=width-1,y=height-1 - bottom right corner of the canvas.


Constructor & Destructor Documentation

void GCanvas::GCanvas Integer  width,
Integer  height,
Integer  bgcolor
[inline]
 

Constructs a 2D image drawing canvas.

Parameters:
width The width of the canvas.
height The height of the canvas.
bgcolor The background color of the canvas.


Member Function Documentation

void GCanvas::circle Integer  xc,
Integer  yc,
Integer  r,
Integer  color
[inline]
 

Draws a circle (Bresenham's algorithm).

Parameters:
xc X coordinate of the center of the circle.
yc Y coordinate of the center of the circle.
r The radius of the circle.
color The color of the circle.

void GCanvas::draw Integer  x,
Integer  y,
Integer  color
[inline]
 

Puts a pixel of the defined color in the position x,y.

Parameters:
x X coordinate of the pixel.
y Y coordinate of the pixel.
color The color of the pixel.

void GCanvas::ellipse Integer  xc,
Integer  yc,
Integer  a,
Integer  b,
Integer  color
[inline]
 

Draws an ellipse (Bresenham's algorithm).

Parameters:
xc X coordinate of the center of the circle.
yc Y coordinate of the center of the circle.
a The semi-axis of the ellipse.
b The semi-axis of the ellipse.
color The color of the ellipse.

void GCanvas::fill Integer  x,
Integer  y,
Integer  color
[inline]
 

Fills a closed area (using stack).

Parameters:
x X coordinate of the point inside the area to be filled-in.
y Y coordinate of the point inside the area to be filled-in.
color Fill color.

Integer GCanvas::getcolor void  x,
void  y
[inline]
 

Gets a color of a pixel in the position x,y.

Returns:
Color of the pixel.

void GCanvas::line Integer  x1,
Integer  y1,
Integer  x2,
Integer  y2,
Integer  color
[inline]
 

Draws a line (Bresenham's algorithm).

Parameters:
x1 X coordinate of the start pixel.
y1 Y coordinate of the start pixel.
x2 X coordinate of the ending pixel.
y2 Y coordinate of the ending pixel.
color The color of the line.

void GCanvas::polygon Array  x,
Array  y,
Integer  color
[inline]
 

Draws a polygon (automatically closed if last points are not identical.

Parameters:
x x1,x2, ..., xn.
y y1,y2, ..., yn.
color Polygon color.

void GCanvas::polyline Array  x,
Array  y,
Integer  color
[inline]
 

Draws a polyline.

Parameters:
x x1,x2, ..., xn.
y y1,y2, ..., yn.
color Polyline color.


The documentation for this class was generated from the following file:
This is a documentation for JSGraphics, a powerfull JavaScript graphics library
© 2003 by Kitya Karlson
Produced using DoxyGen.