Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
draw a straight horizontal line
Last updated at 1:12 pm UTC on 16 January 2006
BobArning: There are several methods that will help here. See:

   FormCanvas>>line:to:width:color: 

Dan Ingalls: For a line object, use PolygonMorph in its PolyLine mode, thus

World addMorph: 
  (PolygonMorph
      vertices: {pointA. pointB}
      color: Color red 
      borderWidth: 2 
      borderColor: Color red)


(Taken from Andreas Raab, Date: Sat Oct 25, 2003 4:41 am ,Subject: RE: Beginner Question Bezier Curves with Balloon.)
You want to do draw some free flowing shapes. Get a Canvas so that you can draw on a Form. Use drawBezierShape: to draw one or more Bezier line segments.

In the following example, we draw a shape that looks vaguely like the Nike logo with the top cut of. First, we get a balloon canvas so we can draw on the Display (as opposed to the form of a Morph.) We draw two rounded line segments and one straight line segment. Each segment is defined by three points: begin-, mid- and end-point. A straight line is created by setting the mid-point equal to the end-point (or the begin-point, it doesn’t matter.) Since, the three line shapes in our example, make a continuous line we get a red filled “swoosh” outlined in red. (Note: the seldom used braces {} used to define the array of points.)

Display getCanvas asBalloonCanvas aaLevel: 4;		
	drawBezierShape: {30 @ 30. 30 @ 200. 200 @ 10. 
			 200 @ 10. 50 @ 150.  50 @ 30. 
			  50 @ 30. 30 @ 30.   30 @ 30}
	color: Color red
	borderWidth: 1
	borderColor: Color green