CrystalSpace

Public API Reference

csPen Class Reference

A pen implementation with which you can do various kinds of 2D rendering. More...

#include <cstool/pen.h>

List of all members.

Public Member Functions

void ClearFlag (uint flag)
 Clears the given flag.
void ClearTransform ()
 Clears the current transform, resets to identity.
bool ClipLine (int &x1, int &y1, int &x2, int &y2)
 Clip a line to the given canvas size.
void DrawArc (int x1, int y1, int x2, int y2, float start_angle=0, float end_angle=6.2831853)
 Draws an elliptical arc from start angle to end angle.
void DrawLine (int x1, int y1, int x2, int y2)
 Draws a single line.
void DrawLines (const csArray< csPenCoordinatePair > &pairs)
 Draws a series of lines.
void DrawMiteredRect (int x1, int y1, int x2, int y2, uint miter)
 Draws a mitered rectangle.
void DrawPoint (int x1, int y2)
 Draws a single point.
void DrawRect (int x1, int y1, int x2, int y2)
 Draws a rectangle.
void DrawRoundedRect (int x1, int y1, int x2, int y2, uint roundness)
 Draws a rounded rectangle.
void DrawTriangle (int x1, int y1, int x2, int y2, int x3, int y3)
 Draws a triangle around the given vertices.
void PopTransform ()
 Pops the transform stack.
void PushTransform ()
 Pushes the current transform onto the stack.
void Rotate (const float &a)
 Rotates by the given angle.
void SetActiveCache (csPenCache *cache)
 Set an active pen cache.
void SetColor (float r, float g, float b, float a)
 Sets the current color.
void SetFlag (uint flag)
 Sets the given flag.
void SetMixMode (uint mode)
 Sets the given mix (blending) mode.
void SetOrigin (const csVector3 &o)
 Sets the origin of the coordinate system.
void SetPenWidth (float width)
 Sets the width of the pen for line drawing.
void SetTexture (iTextureHandle *tex)
 Sets the texture handle.
void SetTransform (const csReversibleTransform &trans)
 Set a transform.
void SwapColors ()
 Swaps the current color and the alternate color.
void Translate (const csVector3 &t)
 Translates by the given vector.
void Write (iFont *font, int x1, int y1, const char *text)
 Writes text in the given font at the given location.
void WriteBoxed (iFont *font, int x1, int y1, int x2, int y2, uint h_align, uint v_align, const char *text)
 Writes text in the given font, in the given box.
void WriteLines (iFont *font, int x1, int y1, const csStringArray &lines)
 Writes multiple lines of text in the given font at the given location.
void WriteLinesBoxed (iFont *font, int x1, int y1, int x2, int y2, uint h_align, uint v_align, const csStringArray &lines)
 Writes multiple lines of text in the given font, in the given box.

Protected Member Functions

void AddTexCoord (float x, float y)
 Adds a texture coordinate.
void AddThickPoints (float x1, float y1, float x2, float y2)
 Worker, adds thick line points.
void AddVertex (float x, float y, bool force_add=false)
 Adds a vertex.
void DrawMesh (csRenderMeshType mesh_type)
 Worker, draws the mesh.
void SetAutoTexture (float w, float h)
 Worker, sets up the pen to do auto texturing.
void SetupMesh ()
 Worker, sets up the mesh with the vertices, color and other information.
void Start ()
 Initializes our working objects.

Detailed Description

A pen implementation with which you can do various kinds of 2D rendering.

Definition at line 152 of file pen.h.


Member Function Documentation

void csPen::AddTexCoord ( float  x,
float  y 
) [inline, protected]

Adds a texture coordinate.

Parameters:
x The texture's x coord.
y The texture's y coord.
void csPen::AddThickPoints ( float  x1,
float  y1,
float  x2,
float  y2 
) [protected]

Worker, adds thick line points.

A thick point is created when the pen width is greater than 1. It uses polygons to simulate thick lines.

void csPen::AddVertex ( float  x,
float  y,
bool  force_add = false 
) [protected]

Adds a vertex.

Parameters:
x X coord
y Y coord
force_add Forces the coordinate to be added as a vertex, instead of trying to be smart and make it a thick vertex.
void csPen::ClearFlag ( uint  flag  ) 

Clears the given flag.

Parameters:
flag The flag to clear.
void csPen::ClearTransform (  ) 

Clears the current transform, resets to identity.

bool csPen::ClipLine ( int &  x1,
int &  y1,
int &  x2,
int &  y2 
)

Clip a line to the given canvas size.

Returns true the line is not empty.

void csPen::DrawArc ( int  x1,
int  y1,
int  x2,
int  y2,
float  start_angle = 0,
float  end_angle = 6.2831853 
)

Draws an elliptical arc from start angle to end angle.

Angle must be specified in radians. The arc will be made to fit in the given box. If you want a circular arc, make sure the box is a square. If you want a full circle or ellipse, specify 0 as the start angle and 2*PI as the end angle.

void csPen::DrawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)

Draws a single line.

void csPen::DrawLines ( const csArray< csPenCoordinatePair > &  pairs  ) 

Draws a series of lines.

void csPen::DrawMesh ( csRenderMeshType  mesh_type  )  [protected]

Worker, draws the mesh.

void csPen::DrawMiteredRect ( int  x1,
int  y1,
int  x2,
int  y2,
uint  miter 
)

Draws a mitered rectangle.

The miter value should be between 0.0 and 1.0, and determines how much of the corner is mitered off and beveled.

void csPen::DrawPoint ( int  x1,
int  y2 
)

Draws a single point.

void csPen::DrawRect ( int  x1,
int  y1,
int  x2,
int  y2 
)

Draws a rectangle.

void csPen::DrawRoundedRect ( int  x1,
int  y1,
int  x2,
int  y2,
uint  roundness 
)

Draws a rounded rectangle.

The roundness value should be between 0.0 and 1.0, and determines how much of the corner is rounded off.

void csPen::DrawTriangle ( int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3 
)

Draws a triangle around the given vertices.

void csPen::PopTransform (  ) 

Pops the transform stack.

The top of the stack becomes the current transform.

void csPen::PushTransform (  ) 

Pushes the current transform onto the stack.

*

void csPen::Rotate ( const float &  a  ) 

Rotates by the given angle.

void csPen::SetActiveCache ( csPenCache cache  )  [inline]

Set an active pen cache.

After this call all drawing calls to this pen will be cached on the cache until you clear the pen cache again. At that point the pen cache can be used to do cached drawings. Note that the pen cache does not work for text. Also note that the pen cache can be updated later with new commands if you set it again onto a pen. It is also safe to use the same pencache with different pens.

Definition at line 280 of file pen.h.

void csPen::SetAutoTexture ( float  w,
float  h 
) [protected]

Worker, sets up the pen to do auto texturing.

void csPen::SetColor ( float  r,
float  g,
float  b,
float  a 
)

Sets the current color.

Parameters:
r The red component.
g The green component.
b The blue component.
a The alpha component.
void csPen::SetFlag ( uint  flag  ) 

Sets the given flag.

Parameters:
flag The flag to set.
void csPen::SetMixMode ( uint  mode  ) 

Sets the given mix (blending) mode.

Parameters:
mode The mixmode to set.
void csPen::SetOrigin ( const csVector3 o  ) 

Sets the origin of the coordinate system.

void csPen::SetPenWidth ( float  width  ) 

Sets the width of the pen for line drawing.

void csPen::SetTexture ( iTextureHandle tex  ) 

Sets the texture handle.

Parameters:
tex A reference to the texture to use.
void csPen::SetTransform ( const csReversibleTransform trans  ) 

Set a transform.

void csPen::SetupMesh (  )  [protected]

Worker, sets up the mesh with the vertices, color and other information.

void csPen::Start (  )  [protected]

Initializes our working objects.

void csPen::SwapColors (  ) 

Swaps the current color and the alternate color.

void csPen::Translate ( const csVector3 t  ) 

Translates by the given vector.

void csPen::Write ( iFont font,
int  x1,
int  y1,
const char *  text 
)

Writes text in the given font at the given location.

void csPen::WriteBoxed ( iFont font,
int  x1,
int  y1,
int  x2,
int  y2,
uint  h_align,
uint  v_align,
const char *  text 
)

Writes text in the given font, in the given box.

The alignment specified in h_align and v_align determine how it should be aligned.

void csPen::WriteLines ( iFont font,
int  x1,
int  y1,
const csStringArray lines 
)

Writes multiple lines of text in the given font at the given location.

void csPen::WriteLinesBoxed ( iFont font,
int  x1,
int  y1,
int  x2,
int  y2,
uint  h_align,
uint  v_align,
const csStringArray lines 
)

Writes multiple lines of text in the given font, in the given box.

The alignment specified in h_align and v_align determine how it should be aligned.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1