[Drawing Functions]


void fltk::concat (float, float, float, float, float, float)
void fltk::load_identity ()
void fltk::pop_matrix ()
void fltk::push_matrix ()
void fltk::rotate (float d)
void fltk::scale (float x)
void fltk::scale (float x, float y)
void fltk::transform (Rectangle &)
void fltk::transform (int &x, int &y)
void fltk::transform (float &x, float &y)
void fltk::transform_distance (float &x, float &y)
void fltk::translate (int x, int y)
void fltk::translate (float x, float y)

Detailed Description

FLTK provides an arbitrary 2-D linear transformation (ie rotation, scale, skew, reflections, and translation). This is very similar to PostScript, PDF, and SVG.

Due to limited graphics capabilities of some systems, all drawing methods that take int values only translate the x and y values, and round them to the nearest integer. You should use functions that take floating-point coordinates if you want accurately scaled drawings.

Function Documentation

void push_matrix  ) 

Save the current transformation on a stack, so you can restore it with pop_matrix().

void pop_matrix  ) 

Put the transformation back to the way it was before the last push_matrix(). Calling this without a matching push_matrix will crash!

void scale float  x,
float  y

Scale the current transformation by multiplying it by

x 0 0
0 y 0
0 0 1

void scale float  x  ) 

Scale the current transformation by multiplying it by

x 0 0
0 x 0
0 0 1

void translate float  x,
float  y

Translate the current transformation by multiplying it by

1 0 0
0 1 0
x y 1

void translate int  x,
int  y

This integer version is provided because it is much faster than the floating-point version. However C++ will not "resolve" which one you want to call if you try passing doubles as arguments. To get it to compile, make sure you cast the arguments to float (add 'f' after floating-point constants). Use the 'f' versions (ie sinf(), cosf(), etc) of the math functions from <fltk/math.h> to produce floats and get maximum calculation speed.

void rotate float  d  ) 

Rotate the current transformation counter-clockwise by d degrees (not radians!!). This is done by multiplying the matrix by:

cos -sin 0
sin  cos 0
0     0  1

void concat float  a,
float  b,
float  c,
float  d,
float  x,
float  y

Multiply the current transformation by

a b 0
c d 0
x y 1

void load_identity  ) 

Replace the current transform with the identity transform, which puts 0,0 in the top-left corner of the window and each unit is 1 pixel in size.

void transform float &  x,
float &  y

Replace x and y transformed into device coordinates. Device-specific code can use this to draw things using the fltk transformation matrix.

void transform_distance float &  x,
float &  y

Replace x and y with the tranformed coordinates, ignoring translation. This transforms a vector which is measuring a distance between two positions, rather than a position.

void transform int &  x,
int &  y

Replace x and y with the transformed coordinates, rounded to the nearest integer.

void transform Rectangle R  ) 

Replace the rectangle with a transformed version. Device-specific code can use this to get a rectangle that matches the current fltk transform. This only works correctly for 90 degree rotations, for other transforms this will produce an axis-aligned rectangle with the same area (this is useful for inscribing circles, and is about the best that can be done for device functions that don't handle rotation.

Sun May 8 21:48:57 2005. FLTK ©2004 Bill Spitzak and others. See Main Page for details.