XPRINT ARC statement  

Purpose

Draw an arc on a host printer page.

Syntax

XPRINT ARC (x1!, y1!) - (x2!, y2!), arcStart!, arcEnd! [, rgbColor&]

Remarks

An arc is a section of a circle or an ellipse. To specify a particular arc, you would first define the full circle or ellipse of which it is a part, and then specify the points on the ellipse where the arc starts and stops.

The full circle or ellipse is defined by its bounding rectangle, which is the smallest rectangle which can be drawn around the circle or ellipse. For example, if the circle is centered at position (400,400), with a radius of 100 pixels, the upper left corner (x1,y1) of the bounding rectangle is (300,300), and the lower right corner (x2,y2) is (500,500).

The start point and end point of the arc are specified by their angle, which must be given in radians. A complete circle or ellipse is 2*pi radians. On a 12-hour clock-face, the values 0 and 2*pi both refer to the position of 3 o'clock, while the value 1*pi refers to the position of 9 o'clock. Other positions are specified by a radian value relative to these. In PowerBASIC, arcs are always drawn counter-clockwise from the starting point to the ending point.

Prior to any XPRINT operations, a host printer must first be selected with XPRINT ATTACH. The coordinate points are specified in pixels (or world coordinates, if those were chosen with XPRINT SCALE). Line width can be set using XPRINT WIDTH. If line width is set to 1 (the default), the line style can be set with XPRINT STYLE. Because of the nature of an arc, XPRINT ARC neither uses, nor updates, POS (last point referenced). If executed without a host printer attached, error 57 is generated.

x1!, y1!

The upper left corner of the bounding rectangle of the full circle or ellipse.

x2!, y2!

The lower right corner of the bounding rectangle of the full circle or ellipse.

ArcStart!

The starting angle of the arc, in radians, from 0 to 2*pi.

ArcEnd!

The ending angle of the arc, in radians, from 0 to 2*pi radians.  Note that arcs are always drawn counter-clockwise from arcStart! to arcEnd!.  Compared with a 12-hour clock-face, 0 or 2*pi radians is at 3 o'clock, and 1*pi radians is at 9 o'clock.

rgbColor&

Optional RGB color for the arc. If omitted (or -1), the current foreground color for the host printer page is used.

See also

Built In RGB Color Equates, XPRINT ATTACH, XPRINT COLOR, XPRINT ELLIPSE, XPRINT PIE, XPRINT STYLE, XPRINT WIDTH

Example

' Draw two arcs that combine into a circle.

' The upper half uses the default foreground color.

' The lower half is drawn in red.

LOCAL Pi AS DOUBLE

Pi = 4 * ATN(1)                             ' Calculate Pi

XPRINT ARC (5, 5) - (105, 105), 0,  Pi      ' Upper half

XPRINT ARC (5, 5) - (105, 105), Pi, 0, %RED ' Lower half