User Guide

Ruby Component
Basic Shapes
You can draw a number of different basic shapes using methods of the View class. They all take a drawing instrument (either a Pen for
outlines or a Brush for fills) and then a number of other parameters to define position and size.
The parameters are usually points, collections of points or rectangles. These are represented by Ruby arrays. A point is represented by a two
element array with the first element being the x coordinate and the second being the y coordinate.
A rectangle is represented by a four element array. The first two elements are the x and y coordinates of the top-left corner followed by the
width and the height.
A collection of points is represented by an array of two element point arrays.
There are 6 shape methods:
drawRectangle instrument, rect
drawRoundRect instrument, rect, corner
drawEllipse instrument, rect
drawPie instrument, rect, startAngle, sweepAngle
drawPolygon instrument, points
drawClosedCurve instrument, points
Here are some examples of drawing shapes:
The drawClosedCurve method can take an additional input:
drawClosedCurve instrument, points, tension
The tension input determines the curvature. A value of zero will produce straight lines, a value of 0.5 will produce curves at the standard
curvature and increasing tensions will produce more curvy lines.
Lines and Curves
The View class has a number of different line drawing methods. They all take a pen as their first input. The remaining parameters depend on
the type of line. As with the shapes, Ruby arrays are used to specify points, collections of points and rectangles.
There are 5 line drawing methods:
drawLine instrument, point1, point2
drawArc instrument, rect, startAngle, sweepAngle
drawCurve instrument, points
drawBeziers instrument, points
drawLines instrument, points
Here are some examples of line drawing in action:
119 of 212