25 #ifndef TBX_DRAWPATH_H_
26 #define TBX_DRAWPATH_H_
28 #include "drawtransform.h"
60 enum JoinStyle {MITRED_JOINS, ROUND_JOINS, BEVELLED_JOINS};
61 enum CapStyle {BUTT_CAPS, ROUND_CAPS, SQUARE_CAPS, TRIANGULAR_CAPS};
64 JoinStyle _join_style;
65 CapStyle _leading_cap_style;
66 CapStyle _trailing_cap_style;
70 int _trailing_tri_cap;
80 _join_style = ROUND_JOINS;
81 _leading_cap_style = ROUND_CAPS;
82 _trailing_cap_style = ROUND_CAPS;
85 _leading_tri_cap = 0x1010;
86 _trailing_tri_cap = 0x1010;
96 void join(JoinStyle style) {_join_style = style;}
102 JoinStyle
join()
const {
return _join_style;}
132 void leading_cap(CapStyle cap_style) { _leading_cap_style = cap_style;}
146 void trailing_cap(CapStyle cap_style) { _leading_cap_style = cap_style;}
161 void leading_cap_width(
short width) {_leading_tri_cap = (_leading_tri_cap & 0xFFFF0000) | width;};
175 void leading_cap_length(
short length) {_leading_tri_cap = (_leading_tri_cap & 0xFFFF) | (((
int)length) << 16);}
189 void trailing_cap_width(
short width) {_trailing_tri_cap = (_trailing_tri_cap & 0xFFFF0000) | width;};
203 void trailing_cap_length(
short length) {_trailing_tri_cap = (_trailing_tri_cap & 0xFFFF) | (((
int)length) << 16);}
240 _data =
new int[
count+2];
243 for (
int j = 0; j <
count; j++) _data[j+2] = dashes[j];
255 _data =
new int[
count+2];
258 for (
int j = 0; j <
count; j++) _data[j+2] = dash;
266 void start(
int value) {_data[0] = value;}
272 int start()
const {
return _data[0];}
276 int count()
const {
return _data[1];}
302 enum ElementType { END, CONTINUATION, MOVE, MOVE_INTERNAL, CLOSE_GAP, CLOSE_LINE, BEZIER, GAP, LINE };
404 DrawElementBezier(
int icx1,
int icy1,
int icx2,
int icy2,
int ix,
int iy) :
DrawElement(DrawElement::BEZIER),
cx1(icx1),
cy1(icy1),
cx2(icx2),
cy2(icy2),
x(ix),
y(iy) {}
474 void ensure_space(
int needed) {
if (_size + needed > _capacity)
capacity(_size + needed + 8);}
489 void move(
int x,
int y);
492 void bezier(
int cx1,
int cy1,
int cx2,
int cy2,
int x,
int y);
493 void gap(
int x,
int y);
494 void line(
int x,
int y);
496 void circle(
int x,
int y,
int radius);
Bezier curve to element.
Definition: drawpath.h:402
Class to represent a dash pattern for lines.
Definition: drawpath.h:226
int cx1
First control x coordinate.
Definition: drawpath.h:405
Class to set the cap and joins style for lines that are greater than a single pixel wide.
Definition: drawpath.h:58
Move to (x, y) starting new subpath.
Definition: drawpath.h:365
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
int cy1
First control y coordinate.
Definition: drawpath.h:406
@ PLOT_NON_BOUNDARY_EXTERIOR
plot non-boundary exterior pixels.
Definition: drawpath.h:46
Class to represent, display and manipulate a graphical path used by the Draw RISC OS module.
Definition: drawpath.h:465
@ PLOT_BOUNDARY_INTERIOR
plot boundary interior pixels.
Definition: drawpath.h:48
void close_line()
Close path with a line.
Definition: drawpath.cc:120
void close_gap()
Close path with a gap.
Definition: drawpath.cc:111
DrawDashPattern(int start, int *dashes, int count)
Construct a dash pattern from an array of dashes.
Definition: drawpath.h:238
short leading_cap_width() const
Get the leading cap width.
Definition: drawpath.h:167
Gap to (x, y) Element.
Definition: drawpath.h:419
End of path.
Definition: drawpath.h:318
int count() const
Get the number of elements in the dash pattern.
Definition: drawpath.h:276
CapStyle leading_cap() const
Get the leading cap style.
Definition: drawpath.h:138
void add(const DrawElement &element)
Add an element to the path.
Definition: drawpath.cc:72
int cy2
Second control y coordinate.
Definition: drawpath.h:408
DrawElementMove(int ix, int iy)
Construct a new move element.
Definition: drawpath.h:354
static int size_in_words(ElementType type)
Return the size of each Draw element type.
Definition: drawpath.cc:38
DrawElementContinuation(DrawElement *iptr)
Construct Continuation path element.
Definition: drawpath.h:336
@ WINDING_POSITIVE
positive winding number rule.
Definition: drawpath.h:45
void leading_cap_width(short width)
Leading triangular cap width on each side.
Definition: drawpath.h:161
int cx2
Second control x coordinate.
Definition: drawpath.h:407
void trailing_cap_length(short length)
Trailing triangular cap length away from the line.
Definition: drawpath.h:203
void leading_cap_length(short length)
Leading triangular cap length away from the line.
Definition: drawpath.h:175
Pointer to continuation of path.
Definition: drawpath.h:330
void join(JoinStyle style)
Set the join style.
Definition: drawpath.h:96
@ WINDING_NON_ZERO
non-zero winding number rule.
Definition: drawpath.h:42
void end_path()
End the path.
Definition: drawpath.cc:87
Line to (x, y) Element.
Definition: drawpath.h:437
int x
End point x coordinate.
Definition: drawpath.h:409
int start() const
Get the distance into the dash pattern of start.
Definition: drawpath.h:272
int & operator[](int index)
Get reference to a dash element.
Definition: drawpath.h:283
CapStyle trailing_cap() const
Get the trailing cap style.
Definition: drawpath.h:152
@ PLOT_BOUNDARY_EXTERIOR
plot boundary exterior pixels.
Definition: drawpath.h:47
JoinStyle join() const
Get the join style.
Definition: drawpath.h:102
DrawElementMoveInternal(int ix, int iy)
Construct a new move element.
Definition: drawpath.h:373
@ WINDING_EVEN_ODD
even-odd winding number rule.
Definition: drawpath.h:44
Class to represent a fixed point number with 16bits before and after the point.
Definition: fixed16.h:40
Base class for elements added to a draw path.
Definition: drawpath.h:297
void trailing_cap_width(short width)
Trailing triangular cap width on each side.
Definition: drawpath.h:189
void move(int x, int y)
Move to (x, y) starting new subpath.
Definition: drawpath.cc:100
ElementType
Draw element types.
Definition: drawpath.h:302
@ WINDING_NEGATIVE
negative winding number rule.
Definition: drawpath.h:43
void mitre_limit(const Fixed16 &limit)
Sets the mitre limit.
Definition: drawpath.h:118
DrawPath(int capacity=64)
Create a new draw path object.
Definition: drawpath.cc:54
DrawFillStyle
Enumeration to set the fill style when filling shapes.
Definition: drawpath.h:41
int operator[](int index) const
Get value of a dash element.
Definition: drawpath.h:290
short trailing_cap_width() const
Get the trailing cap width.
Definition: drawpath.h:195
short leading_cap_length() const
Get the leading cap length.
Definition: drawpath.h:181
DrawDashPattern(int start, int dash=1, int count=2)
Construct a dash pattern initialised to equal sized dashes.
Definition: drawpath.h:253
@ PLOT_ALL_AT_ONCE
Used with DrawPath::stroke, will only plot each pixel once at the cost of more temporary workspace.
Definition: drawpath.h:50
void line(int x, int y)
Add a line to a path.
Definition: drawpath.cc:155
int y
End point y coordinate.
Definition: drawpath.h:410
void trailing_cap(CapStyle cap_style)
Set the trailing cap style.
Definition: drawpath.h:146
@ PLOT_NON_BOUNDARY_INTERIOR
plot non-boundary interior pixels.
Definition: drawpath.h:49
int mitre_limit() const
Get the mitre limit.
Definition: drawpath.h:124
void circle(int x, int y, int radius)
Adds a circle subpath to the drawing.
Definition: drawpath.cc:176
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.
Definition: drawpath.cc:287
void fill(DrawFillStyle fill_style=WINDING_NON_ZERO, DrawTransform *transform=0, int flatness=0) const
Fill the interior of a path.
Definition: drawpath.cc:258
Close path with a gap element.
Definition: drawpath.h:383
int capacity() const
Get capacity in words (1 word = 4 bytes)
Definition: drawpath.h:486
void start(int value)
Set the distance into the dash pattern of start.
Definition: drawpath.h:266
void bezier(int cx1, int cy1, int cx2, int cy2, int x, int y)
Bezier curve to.
Definition: drawpath.cc:129
short trailing_cap_length() const
Get the trailing cap length.
Definition: drawpath.h:209
Move to (x, y) starting new subpath.
Definition: drawpath.h:346
void leading_cap(CapStyle cap_style)
Set the leading cap style.
Definition: drawpath.h:132
DrawCapAndJoin()
Construct with ROUND_JOINS and ROUND_CAPS at both ends.
Definition: drawpath.h:78
void gap(int x, int y)
Add a gap to a path.
Definition: drawpath.cc:144
Close path with a line element.
Definition: drawpath.h:393