tbx
0.7.3
|
Class to represent, display and manipulate a graphical path used by the Draw RISC OS module. More...
#include <drawpath.h>
Public Member Functions | |
DrawPath (int capacity=64) | |
Create a new draw path object. More... | |
void | add (const DrawElement &element) |
Add an element to the path. More... | |
void | capacity (int capacity) |
Set the capacity of the path. More... | |
int | capacity () const |
Get capacity in words (1 word = 4 bytes) | |
void | end_path () |
End the path. | |
void | move (int x, int y) |
Move to (x, y) starting new subpath. More... | |
void | close_gap () |
Close path with a gap. | |
void | close_line () |
Close path with a line. | |
void | bezier (int cx1, int cy1, int cx2, int cy2, int x, int y) |
Bezier curve to. | |
void | gap (int x, int y) |
Add a gap to a path. | |
void | line (int x, int y) |
Add a line to a path. | |
void | circle (int x, int y, int radius) |
Adds a circle subpath to the drawing. More... | |
void | fill (DrawFillStyle fill_style=WINDING_NON_ZERO, DrawTransform *transform=0, int flatness=0) const |
Fill the interior of a path. More... | |
void | stroke (DrawFillStyle fill_style=WINDING_NON_ZERO, DrawTransform *transform=0, int flatness=0, int thickness=0, DrawCapAndJoin *cap_and_join=0, DrawDashPattern *dashes=0) const |
Sends a path to the VDU. More... | |
Class to represent, display and manipulate a graphical path used by the Draw RISC OS module.
A path is created by adding DrawElements to the path.
Convenience methods are included to add the common draw elements without need to construct a draw element first.
The units used for coordinates in a path are user defined, they are converted to screen coordinates by a transform when the path it filled or stroked.
tbx::DrawPath::DrawPath | ( | int | capacity = 64 | ) |
Create a new draw path object.
A move, line or gap takes 3 words. A curve takes 7 words Closing a path takes 1 word. The end element and draw continuation take 2 words
initial | capacity in words. 1 word is 4 bytes. Default is 64. |
void tbx::DrawPath::add | ( | const DrawElement & | element | ) |
Add an element to the path.
element | DrawElement to add |
void tbx::DrawPath::capacity | ( | int | new_cap | ) |
Set the capacity of the path.
new_cap | new capacity in words (1 word = 4 bytes) |
void tbx::DrawPath::circle | ( | int | x, |
int | y, | ||
int | radius | ||
) |
Adds a circle subpath to the drawing.
The circle is an approximation using bezier curves.
The circle is made of 4 bezier curves, a move and a close so requires 32 words.
x | user x coordinate of centre |
y | user y coordinate of centre |
radius | radius of the circle (maximum 32767). |
void tbx::DrawPath::fill | ( | DrawFillStyle | fill_style = WINDING_NON_ZERO , |
DrawTransform * | transform = 0 , |
||
int | flatness = 0 |
||
) | const |
Fill the interior of a path.
This method emulates the PostScript 'fill' operator. It performs the following actions:
The transform needs to map the user units into internal draw units which are 1/256th of an OS unit.
style | DrawFillStyle flags for filling. Default is WINDING_NON_ZERO. |
transform | transformation matrix of 0 for none |
flatness | maximum distance allowed from beizer curve when flattening it in user units (0 use default) |
void tbx::DrawPath::move | ( | int | x, |
int | y | ||
) |
Move to (x, y) starting new subpath.
The new subpath does affect winding numbers and so is filled normally.
void tbx::DrawPath::stroke | ( | DrawFillStyle | fill_style = WINDING_NON_ZERO , |
DrawTransform * | transform = 0 , |
||
int | flatness = 0 , |
||
int | thickness = 0 , |
||
DrawCapAndJoin * | cap_and_join = 0 , |
||
DrawDashPattern * | dashes = 0 |
||
) | const |
Sends a path to the VDU.
This command emulates the PostScript 'stroke' operator. It performs the following actions: flattens the path
The transform needs to map the user units into internal draw units which are 1/256th of an OS unit.
fill_style | DrawFillStyle. Default is WINDING_NON_ZERO. |
transform | pointer to transformation matrix, or 0 for identity matrix |
flatness | flatness, or 0 for default |
thickness | line thickness, or 0 for default. If the thickness is zero then the line is drawn with the minimum width that can be used, given the limitations of the pixel size (so lines are a single pixel wide). If the thickness is n, then the line will be drawn with a thickness of n/2 user coordinates translated to pixels on either side of the theoretical line position. If the line thickness is non-zero, then the cap and join parameter must also be passed. |
cap_and_join | pointer to line cap and join specification (if required) |
pointer | to dash pattern, or 0 for no dashes |