Circle
ClassObjects of Circle
class contain instance variables that define
the center and radius of a circle. The class also defines methods
for drawing circles on X displays.
The methods defined in this class can render circles on any
GUI drawable surface. To work with the pane buffering mechanism,
however, X11CanvasPane
class also defines drawing methods.
See X11CanvasPane.
Circle drawing methods also require an interior color argument. This is the name of the color within the circle. To give the appearance of drawing just the circle’s rim, a program can set the interior color to the window’s background color. If the fill argument is TRUE, then the circle is filled with the rim color. If the fill argument is FALSE, the width and color of the rim are determined by the pen object used to draw the circle, and the color inside the circle is determined by the interior color argument.
int main () { X11Pane new xPane; InputEvent new e; X11PaneDispatcher new xTopLevelPane; X11CanvasPane new xCanvasPane; Application new paneApp; Circle new inner; Circle new outer; Circle new middle; Pen new innerPen; Pen new middlePen; Pen new outerPen; String new bgColor; paneApp enableExceptionTrace; paneApp installExitHandlerBasic; bgColor = "white"; xPane initialize 10, 10, 300, 300; xTopLevelPane attachTo xPane; xCanvasPane attachTo xTopLevelPane; xPane map; xPane raiseWindow; xPane openEventStream; xPane clearWindow; xCanvasPane background bgColor; inner center x = 150; inner center y = 150; inner radius = 30; innerPen colorName = "navy"; innerPen width = 10; middle center x = 150; middle center y = 150; middle radius = 40; middlePen colorName = "blue"; middlePen width = 10; outer center x = 150; outer center y = 150; outer radius = 50; outerPen colorName = "sky blue"; outerPen width = 10; xCanvasPane pen width = 1; xCanvasPane pen colorName = "black"; xCanvasPane drawCircle outer, outerPen, FALSE, bgColor; xCanvasPane drawCircle middle, middlePen, FALSE, bgColor; xCanvasPane drawCircle inner, innerPen, FALSE, bgColor; xCanvasPane drawLine 50, 150, 250, 150; xCanvasPane drawLine 150, 50, 150, 250; xCanvasPane refresh; while (TRUE) { xPane inputStream queueInput; if (xPane inputStream eventPending) { e become xPane inputStream inputQueue unshift; xPane subPaneNotify e; switch (e eventClass value) { case WINDELETE: xPane deleteAndClose; exit (0); break; case EXPOSE: case RESIZENOTIFY: xCanvasPane drawCircle outer, outerPen, TRUE, bgColor; xCanvasPane drawCircle middle, middlePen, TRUE, bgColor; xCanvasPane drawCircle inner, innerPen, TRUE, bgColor; xCanvasPane drawLine 50, 150, 250, 150; xCanvasPane drawLine 150, 50, 150, 250; xCanvasPane refresh; break; default: break; } } } }
center
A Point
object that defines the x,y
coordinates
of the circle’s center. If drawn on a X display the units
represent pixels on the display. See Point.
radius
An Integer
that defines the Circle
object’s
radius.
draw
(Pane
paneObject, Integer
filled, String
bgColor)
draw
(Pane
paneObject, Pen
penObject, Integer
filled, String
bgColor)
Draw the receiver circle on the display. If a Pen
argument is
given, use the Pen
object’s color and line width to draw the
circle. If a Pen
argument is not given use a default Pen
,
and fill the interior of the circle with bgColor if filled
is false.