wftk::Painter Class Reference

class that allows drawing graphics primitives onto a Surface More...

#include <painter.h>

List of all members.

Public Types

enum  Mode { OP_REPLACE, OP_AND, OP_OR, OP_XOR }
 behaviour of painting primtives More...

Public Member Functions

 Painter (Surface *surf=0)
 constructor - bind this Painter to the surf Surface
bool empty () const
void setColor (const Color &col)
 set the active (default) Color
void setFilling (bool flag)
 set fill mode for boxes, circles and other closed primitives on/off
void setMode (Mode mode)
 set drawing Mode for overlapping primitives
void setSurface (Surface *surf)
 set the target Surface.
void setPixel (const Point &pt, const Color &col)
 Set a pixel on the Surface to given Color.
Color getPixel (const Point &pt)
 fetch the Color of pixel
void hLine (const Point &p1, const Point &p2)
 Draw a horizontal line on the target Surface using the default Color.
void vLine (const Point &p1, const Point &p2)
 Draw a vertical line on the target Surface using the default Color.
void line (const Point &p1, const Point &p2)
 Draw a diagonal line on the target Surface using the default Color.
void hLine (const Point &p1, const Point &p2, const Color &col)
 Draw a horizontal line on the target Surface.
void vLine (const Point &p1, const Point &p2, const Color &col)
 Draw a vertical line on the target Surface.
void line (const Point &p1, const Point &p2, const Color &col)
 Draw a diagonal line on the target Surface.
void circle (const Point &c, unsigned int r, unsigned int t=1)
 Draw a circle on the target Surface, using the default Color.
void ellipse (const Point &c, unsigned int rx, unsigned int ry, unsigned int t=1)
 Draw an ellipse on the target Surface, using the default Color.
void box (const Point &p1, const Point &p2)
 Draw a box (rectangle) on the target Surface, using the default Color.
void trigon (const Point &p1, const Point &p2, const Point &p3)
 Draw a triangle on the target Surface, using the default Color.
void trigon (const Point &p1, const Point &p2, const Point &p3, const Color &c)
 Draw a triangle on the target Surface.
void shadedTrigon (const Point &d1, const Point &d2, const Point &d3, const Color &c1, const Color &c2, const Color &c3)
 Draw a filled triangle on the target Surface.
void texturedTrigon (const Point &d1, const Point &d2, const Point &d3, const Point &s1, const Point &s2, const Point &s3, Surface *texture)
 Draw a textured triangle to the target Surface.


Detailed Description

class that allows drawing graphics primitives onto a Surface


Member Enumeration Documentation

enum wftk::Painter::Mode

behaviour of painting primtives

Enumerator:
OP_REPLACE 
OP_AND 
OP_OR 
OP_XOR 


Member Function Documentation

void wftk::Painter::setPixel ( const Point pt,
const Color col 
) [inline]

Set a pixel on the Surface to given Color.

Parameters:
pt Point on the Surface to set
col Color to set the pixel

Color wftk::Painter::getPixel ( const Point pt  )  [inline]

fetch the Color of pixel

Parameters:
pt Point on the surface to fetch

void wftk::Painter::hLine ( const Point p1,
const Point p2 
)

Draw a horizontal line on the target Surface using the default Color.

Parameters:
p1 Begin point, used for vertical offset
p2 End point, used for horizontal offset while drawing

void wftk::Painter::vLine ( const Point p1,
const Point p2 
)

Draw a vertical line on the target Surface using the default Color.

Parameters:
p1 Begin point, used for horizontal offset
p2 End point, used for vertical offset while drawing

void wftk::Painter::line ( const Point p1,
const Point p2 
)

Draw a diagonal line on the target Surface using the default Color.

This method calls vLine or hLine if possible, or uses a bresenham calculation to rasterize the diagonal line if necessary.

Parameters:
p1 Begin point of the line
p2 End point of the line

void wftk::Painter::hLine ( const Point p1,
const Point p2,
const Color col 
)

Draw a horizontal line on the target Surface.

Parameters:
p1 Begin point, used for vertical offset
p2 End point, used for horizontal offset while drawing
col Color to draw the line with

void wftk::Painter::vLine ( const Point p1,
const Point p2,
const Color col 
)

Draw a vertical line on the target Surface.

Parameters:
p1 Begin point, used for horizontal offset
p2 End point, used for vertical offset while drawing
col Color to draw the line with

void wftk::Painter::line ( const Point p1,
const Point p2,
const Color col 
)

Draw a diagonal line on the target Surface.

This method calls vLine or hLine if possible, or uses a bresenham calculation to rasterize the diagonal line if necessary.

Parameters:
p1 Begin point of the line
p2 End point of the line
col Color to draw the line with

void wftk::Painter::circle ( const Point c,
unsigned int  r,
unsigned int  t = 1 
)

Draw a circle on the target Surface, using the default Color.

Parameters:
c Center of circle
r radius of circle, in pixels
t Border thickness of circle, in pixels (defaults to 1 pixel)

void wftk::Painter::ellipse ( const Point c,
unsigned int  rx,
unsigned int  ry,
unsigned int  t = 1 
)

Draw an ellipse on the target Surface, using the default Color.

Parameters:
c Center of ellipse (midpoint between foci)
rx maximum width of ellipse, in pixels (x-axis)
ry maximum height of ellipse, in pixels (y-axis)
t Border thickness of ellipse, in pixels (defaults to 1 pixel)

void wftk::Painter::box ( const Point p1,
const Point p2 
)

Draw a box (rectangle) on the target Surface, using the default Color.

Parameters:
p1 Upper left co-ordinate of Box
p2 Lower right co-ordinate of Box

void wftk::Painter::trigon ( const Point p1,
const Point p2,
const Point p3 
)

Draw a triangle on the target Surface, using the default Color.

Parameters:
p1 First vertex of triangle
p2 Second vertex of triangle
p3 Third vertex of triangle

void wftk::Painter::trigon ( const Point p1,
const Point p2,
const Point p3,
const Color c 
)

Draw a triangle on the target Surface.

Parameters:
p1 First vertex of triangle
p2 Second vertex of triangle
p3 Third vertex of triangle
c Color used to draw the triangle

void wftk::Painter::shadedTrigon ( const Point d1,
const Point d2,
const Point d3,
const Color c1,
const Color c2,
const Color c3 
)

Draw a filled triangle on the target Surface.

Vertex colors are blended into each other across the bitmap.

Parameters:
d1 First vertex of triangle
d2 Second vertex of triangle
d3 Third vertex of triangle
c1 Color of first vertex
c2 Color of second vertex
c3 Color of third vertex

void wftk::Painter::texturedTrigon ( const Point d1,
const Point d2,
const Point d3,
const Point s1,
const Point s2,
const Point s3,
Surface texture 
)

Draw a textured triangle to the target Surface.

Parameters:
d1 First vertex of triangle
d2 Second vertex of triangle
d3 Third vertex of triangle
s1 First UV co-ordinate of texture
s2 Second UV co-ordinate of texture
s3 Third UV co-ordinate of texture
texture Surface used as texture for triangle


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

Generated Fri Nov 10 07:10:12 2006.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.