Parents | Children | Properties | Methods | Events |
Purpose: | A graphical object used to draw lines, polygons, and filled areas. |
Description
The Points property specifies one or more sets of co-ordinates through which one or more lines are drawn. The resulting polygon(s) may also be filled.
LStyle and LWidth define the style and width of the lines. FCol and BCol determine the colour of the lines.
FStyle specifies whether or not the polygon(s) are filled, and if so, how. For a solid fill (FStyle 0), FillCol defines the fill colour used. For a pattern fill (FStyle 1-6) FillCol defines the colour of the hatch lines and BCol the colour of the areas between them.
Note that if you specify filling, you do not have to define a closed polygon. The first and last points will automatically be joined for you if necessary.
The value of Dragable determines whether or not the object can be dragged. The value of AutoConf determines whether or not the Poly object is resized when its parent is resized.
The structure of the property values is best considered separately for single and multiple polylines or polygons.
Single Polyline or Polygon
For a single polyline or polygon, Points is either a 2-column matrix of (y,x) co-ordinates, or a 2-element vector of y and x co-ordinates respectively.
LStyle and LWidth are both simple scalar numbers.
FStyle is either a single number specifying a standard fill pattern, or the name of a Bitmap object which is to be used as a "brush" to fill the polygon.
FCol, BCol and FillCol are each either single numbers representing standard colours, or 3-element vectors which specify colours explicitly in terms of their RGB values.
Examples:
First make a Form :
'F' ⎕WC 'Form'
Draw a single line from (y=20, x=10) to (y=30, x=50)
'F.L1' ⎕WC 'Poly' ((20 30)(10 50))
or
L ← 2 2⍴20 10 30 50 'F.L1' ⎕WC 'Poly' L
Draw a horizontal line from (y=20, x=10) to (y=20, x=50). Note scalar extension of y-coordinate.
'F.L1' ⎕WC 'Poly' (20(10 50))
Draw an empty box in green :
Y ← 10 10 50 50 10 X ← 10 50 50 10 10 'F.L1' ⎕WC 'Poly' (Y X) (0 255 0)
Ditto, using a green/blue dashed line (LStyle 1) :
'F.L1' ⎕WC 'Poly' (Y X) (0 255 0)(0 0 255) 1
Draw a red filled rectangle with a black border 5 pixels wide :
'F.L1' ⎕WC 'Poly' (Y X) (0 0 0) ('LWidth' 5) ('FStyle' 0)('FillCol' 255 0 0)
Multiple Polylines/Polygons
To draw a set of polylines or polygons with a single name, Points is a nested vector whose items are themselves 2-column matrices or 2-element nested vectors.
LStyle and LWidth may each be simple scalar values (applying to all the polylines) or simple vectors whose elements refer to each of the corresponding polylines in turn.
FStyle may be a simple scalar numeric or a simple character vector (Bitmap name) applying to all polylines, or a vector whose elements refer to each of the corresponding polylines in turn.
Similarly, FCol, BCol and FillCol may each be single numbers or a single (enclosed) 3-element vector applying to all the polylines. Alternatively, these properties may contain vectors whose elements refer to each of the polylines in turn. If so, their elements may be single numbers or nested RGB triplets, or a combination of the two.
Examples:
First make a Form :
'F' ⎕WC 'Form'
Draw two concentric triangles :
BY ← 10 10 50 10 BX ← 15 65 40 15 RY ← 15 15 40 15 RX ← 25 55 40 25 'F.L1' ⎕WC 'Poly' ((BY BX)(RY RX))
Or, using matrices :
BT ← BY,[1.5]BX RT ← RY,[1.5]RX 'F.L1' ⎕WC P←'Poly' (BT RT)
Ditto, but draw the first blue, the second red :
'F.L1' ⎕WC P,⊂((0 0 255)(255 0 0))
Ditto, but make the lines 3 pixels wide :
'F.L1' ⎕WC P, ((0 0 255)(255 0 0))('LWidth' 3)
Ditto, but make the line widths 3 and 6 pixels respectively :
'F.L1' ⎕WC P, ((0 0 255)(255 0 0))('LWidth' 3 6)
Draw the first hollow, but fill the second in green :
'F.L1' ⎕WC P, ('FStyle' ¯1 0)('FillCol' (⊂0 255 0))