Name
DrawPath -- draw a vector path (V5.0)
Synopsis
int ok = DrawPath(struct DrawPathCtrl *ctrl);
Function
This function has to draw a vector path to a bitmap. The path itself and all other parameters that you need to know are passed in the 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:
A buffer containing the actual path data. This buffer contains the individual commands and their parameters in a number of disparate items. The command is stored in an 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:
This is the terminator command. This will always be at the end of the path buffer. You must break out of your command loop when encountering CCMD_STACKTOP.

CCMD_NEWSUBPATH:
This has to start a new sub-path and set the current point to undefined.

CCMD_CLOSEPATH:
This has to close the current path by drawing a line from the current point to the first point in the sub-path. After that the current point has to be set to this start and end point of the sub-path.

CCMD_MOVETO:
This command has to begin a new sub-path. The sub-path's current point must be set to the specified position. CCMD_MOVETO receives the following three arguments:

rel (int)
This is a boolean value that indicates whether the coordinates are relative or absolute values. If this is True, the coordinates have to be interpreted as relative to the current point.

x (double)
The x coordinate of the new position.

y (double)
The y coordinate of the new position.

CCMD_LINETO:
This command has to draw a line from the current point to the specified position. Additionally, it must change the current point to the line's end point when it is done. CCMD_LINETO receives the following three arguments:

rel (int)
This is a boolean value that indicates whether the coordinates are relative or absolute values. If this is True, the coordinates have to be interpreted as relative to the current point.

x (double)
The x coordinate of the new position.

y (double)
The y coordinate of the new position.

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:
This command has to draw a Bézier curve that runs from the current point to the position passed in the final two coordinates. The other four coordinates are the control points for the curve. Additionally, it must change the current point to the curve's end point when it is done. CCMD_CURVETO receives the following seven arguments:

rel (int)
This is a boolean value that indicates whether the coordinates are relative or absolute values. If this is True, the coordinates have to be interpreted as relative to the current point.

x1 (double)
The x coordinate of the first control point.

y1 (double)
The y coordinate of the first control point.

x2 (double)
The x coordinate of the first control point.

y2 (double)
The y coordinate of the first control point.

x3 (double)
The x coordinate of the end point.

y3 (double)
The y coordinate of the end point.

If there is no current point, CCMD_CURVETO must use the point passed in (x1,y1) as the current point.

CCMD_ARC:
This command has to draw an elliptical 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)
The x center point of the arc.
yc (double)
The y center point of the arc.
ra (double)
Arc's radius on the x axis.
rb (double)
Arc's radius on the y axis.
start (double)
Start angle in degrees.
end (double)
End angle in degrees.
clockwise (int)
Whether or not the angles should be connected in clockwise direction.

When CCMD_ARC is done, it needs to set the current point to the position of the end angle.

CCMD_BOX:
This command has to draw a rectangle. 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)
X position of the rectangle.
y (double)
Y position of the rectangle.
width (double)
Rectangle width.
height (double)
Rectangle height.
rnd1 (int)
Integer value in the range of 0 to 100 specifying the degree of rounding for the first corner of the rectangle. 0 for no rounding.
rnd2 (int)
Integer value in the range of 0 to 100 specifying the degree of rounding for the second corner of the rectangle. 0 for no rounding.
rnd3 (int)
Integer value in the range of 0 to 100 specifying the degree of rounding for the third corner of the rectangle. 0 for no rounding.
rnd4 (int)
Integer value in the range of 0 to 100 specifying the degree of rounding for the fourth corner of the rectangle. 0 for no rounding.

CCMD_TEXT:
This command has to draw vector text relative to the current point. The individual characters should be added as closed subpaths. CCMD_TEXT receives the following arguments:

ptr (APTR)
This is set to a pointer to a vector font created by CreateVectorFont().

size (int)
Desired font size.

text (varies)
The text to draw is passed directly after the integer specifying the font size. It is a null-terminated string encoded in the UTF-8 format. To read the next command following the string data, you need to pad the pointer address after the terminating 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:
This will be set to a pointer to a 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:
Contains the desired line join style for the path. This can be one of the following constants:

HWLINEJOIN_MITER:
Join lines using a sharp corner.
HWLINEJOIN_ROUND:
Join lines using round edges.
HWLINEJOIN_BEVEL:
Join lines using cut-off edges.

LineCap:
Determines how line endings should be drawn. This can be one of the following constants:

HWLINECAP_BUTT:
Line should stop exactly at the end point without any further decoration.

HWLINECAP_ROUND:
Line ending should be round.

HWLINECAP_SQUARE:
Line ending should be squared.

FillRule:
Determines the fill rule for overlapping sections of the path. This can be one of the following constants:

HWFILLRULE_WINDING:
Fill all overlapping paths only if they are not winding.

HWFILLRULE_EVENODD:
Fill overlapping paths if the total number of intersections is odd.

AntiAlias:
This indicates whether Hollywood wants you to draw anti-aliased shapes or monochrome shapes. True means anti-aliasing should be used.

DashOffset:
If NumDashes is greater than zero, this specifies the offset at which dashing should start.

Dashes:
If 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:
If this is greater than zero, Hollywood wants you to draw dashed lines. The dashing pattern is specified in DashOffset and Dashes (see above).

MiterLimit:
This item is only present in Hollywood 7.1 and up. If you are targetting earlier Hollywood versions, assume a miter limit of 10. The miter limit is used when the join style is set to 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:
This member specifies whether Hollywood wants you to draw filled shapes or just the stroke outlines. If this is True, you have to fill all shapes.

Thickness:
This member sets the line thickness.

Color:
This is currently unused since DrawPath() doesn't draw into color channels at all. Ignore this.

Buf:
This contains a pointer to an 8-bit bitmap which you have to draw to. See LineWidth to find out about the bitmap's alignment.

LineWidth:
This contains the bytes per row of the bitmap passed in Buf.

Width:
Contains the width of the bitmap in pixels. This can be less than LineWidth.

Height:
Contains the height of the bitmap in pixels.

TX:
If this does not equal 0, Hollywood wants you to translate every pixel that you draw by this many pixels on the x-axis. Note that the translation must be done after applying the transformation matrix passed in Matrix.

TY:
If this does not equal 0, Hollywood wants you to translate every pixel that you draw by this many pixels on the y-axis. Note that the translation must be done after applying the transformation matrix passed in Matrix.

MinX:
You have to translate the path by this many pixels on the x-axis before drawing it. Note that this value is inverted. A positive value indicates translation to the left whereas a negative value requires you to translate the shape to the right.

MinY:
You have to translate the path by this many pixels on the y-axis before drawing it. Note that this value is inverted. A positive value indicates upwards translation whereas a negative value requires you to translate the shape in downward direction.

Matrix:
Contains a 2D transformation matrix that should be applied to this path. If there is no transformation, you'll get a pointer to an identity matrix consisting of (1,0,0,1).

Inputs
ctrl
pointer to a struct DrawPathCtrl
Results
ok
True for success, False otherwise

Show TOC