int ok = DrawPath(struct DrawPathCtrl *ctrl);
struct DrawPathCtrl
pointer that this function
receives. struct DrawPathCtrl
looks like this:
struct DrawPathCtrl { void *Path; // [in] struct PathStyle *Style; // [in] int Fill; // [in] int Thickness; // [in] ULONG Color; // [in] UBYTE *Buf; // [in] int LineWidth; // [in] int Width; // [in] int Height; // [in] int Pad; // [unused] double TX; // [in] double TY; // [in] double MinX; // [in] double MinY; // [in] struct hwMatrix2D *Matrix; // [in] }; |
Hollywood will pass the following data in this structure:
Path:
int
and is always first. The number of parameters that follow the command int
and their
sizes depend on the actual command that has been passed. The following commands are
currently recognized:
CCMD_STACKTOP:
CCMD_STACKTOP
.
CCMD_NEWSUBPATH:
CCMD_CLOSEPATH:
CCMD_MOVETO:
CCMD_MOVETO
receives the following three arguments:
rel (int)
True
, the coordinates have to be interpreted as
relative to the current point.
x (double)
y (double)
CCMD_LINETO:
CCMD_LINETO
receives the following three arguments:
rel (int)
True
, the coordinates have to be interpreted as
relative to the current point.
x (double)
y (double)
If there is no current point, CCMD_LINETO
must behave as if it was CCMD_MOVETO
,
i.e. it must simply set the current point to the specified vertex.
CCMD_CURVETO:
CCMD_CURVETO
receives the following
seven arguments:
rel (int)
True
, the coordinates have to be interpreted as
relative to the current point.
x1 (double)
y1 (double)
x2 (double)
y2 (double)
x3 (double)
y3 (double)
If there is no current point, CCMD_CURVETO
must use the point passed in (x1,y1) as
the current point.
CCMD_ARC:
CCMD_ARC
must open a new subpath for
the new arc only in case there is no currently active subpath. If there is already
a subpath, CCMD_ARC
must connect its starting vertex with the current vertex of
the subpath. CCMD_ARC
also must not close the subpath when it has finished adding
its vertices. CCMD_ARC
must not connect the start and end angles of the arc with
its center point automatically. The user has to explicitly request this by issuing
separate CCMD_MOVETO
and CCMD_LINETO
commands before and after CCMD_ARC
. CCMD_ARC
receives the following arguments:
xc (double)
yc (double)
ra (double)
rb (double)
start (double)
end (double)
clockwise (int)
When CCMD_ARC
is done, it needs to set the current point to the position of the
end angle.
CCMD_BOX:
CCMD_BOX
must first open a new subpath,
then add the rectangle's vertices to it and close the subpath when it is finished.
Optionally, the rectangle can have rounded corners. CCMD_BOX
receives the following arguments:
x (double)
y (double)
width (double)
height (double)
rnd1 (int)
rnd2 (int)
rnd3 (int)
rnd4 (int)
CCMD_TEXT:
CCMD_TEXT
receives the following
arguments:
ptr (APTR)
size (int)
text (varies)
NULL
to a multiple of 4, i.e. a long-aligned address. Commands are always long-aligned
so be sure to pad to a long-aligned address after the string end.
When CCMD_TEXT
is done, it needs to set the current point to where the next
character would be displayed.
Style:
struct PathStyle
containing
information about the line style that shall be used when drawing this path.
struct PathStyle
looks like this:
struct PathStyle { int LineJoin; int LineCap; int FillRule; int AntiAlias; double DashOffset; double *Dashes; int NumDashes; double MiterLimit; // V7.1 }; |
Here's an explanation of the individual member's function:
LineJoin:
HWLINEJOIN_MITER:
HWLINEJOIN_ROUND:
HWLINEJOIN_BEVEL:
LineCap:
HWLINECAP_BUTT:
HWLINECAP_ROUND:
HWLINECAP_SQUARE:
FillRule:
HWFILLRULE_WINDING:
HWFILLRULE_EVENODD:
AntiAlias:
True
means anti-aliasing should be used.
DashOffset:
NumDashes
is greater than zero, this specifies the offset at which dashing
should start.
Dashes:
NumDashes
is greater than zero, this is set to a double
array which
contains NumDashes
entries, specifying alternate on and off sections that
define the dash style.
NumDashes:
DashOffset
and Dashes
(see above).
MiterLimit:
HWLINEJOIN_MITER
to determine when to join lines
with a bevel and when to join them using a miter. When drawing line ends, the
length of the miter is divided by the line width and if the result of this division
is greater than the miter limit set using this function, lines are joined using
a bevel. (V7.1)
Fill:
True
, you have to fill all shapes.
Thickness:
Color:
DrawPath()
doesn't draw into color channels
at all. Ignore this.
Buf:
LineWidth
to find out about the bitmap's alignment.
LineWidth:
Buf
.
Width:
LineWidth
.
Height:
TX:
Matrix
.
TY:
Matrix
.
MinX:
MinY:
Matrix:
struct DrawPathCtrl
True
for success, False
otherwise