Thanks for these intriguing examples and the short tutorial on TG. I'll have fun with these for some time.
Roger
Message: 3 Date: Tue, 5 Aug 2003 08:34:20 -0700 To: [EMAIL PROTECTED] From: Jim Hurley <[EMAIL PROTECTED]> Subject: Turtle Graphics Reply-To: [EMAIL PROTECTED]
Greetings all,
I have been working on a optics tutorial. It involves the manipulation of mirrors, lenses, microscopes, telescopes, focal points, light rays, fish, bugs, eyes, etc. I have found it useful to modify the traditional Turtle Graphics so that the language may be applied to any RR control and not just to the turtle drawing cursor. This will not be useful to the majority on this list, those whose primary objective is text manipulation. But for those interested in educational software or games, you may find TG a useful tool.
Actually there are three flavors, each useful in a different circumstance. The first is "Control Graphics." The turtle becomes a metaphor for a control, any control--button, field, image, graphic. The Turtle Graphic vocabulary acts on the custom properties assigned to each control. These properties are:
px, py, pangle,p PenDown, pPoints
They are in order: The x and y Cartesian coordinates (measured relative to the center of the screen) the heading, the pen state (up or down--drawing or not) and the graphic points which define the line drawn by the control if the pen is down.
For example, in the following handler, a hare moves in a circle chased by a fox. (The hare and fox are buttons with the obvious icon.)
on mouseUp startTurtle "hare" startTurtle "fox" put 0 into theta put 5 into dTheta
repeat until theta > 360
tell "hare" setRA 200,theta -- Set the polar coord. radius and angle add dTheta to theta put xycor() into theHareLocation
tell "fox" setheading direction(theHareLocation) forward 8
end repeat end mouseUp
The see some example of "Control Graphics" run this in the msg box:
go url "http://home.infostations.net/jhurley/ControlGraphics.rev"
(Richard: Would this be better: go url <http://home.infostations.net/jhurley/ControlGraphics.rev>?)
----------------------------------
The second flavor is "Multiple Turtles" which is useful in programing graphic lines with different properties (color, line size, etc.) It only draws; it does not control the controls.
The syntax is somewhat different from Control Graphics. As an example, the following handler draws a pinwheel with different colored spokes:
on mouseUP put "red,orange,black,green,blue,violet" into colorList
repeat with i = 1 to 6 put "Spoke" &i into tName
startTurtle tName set the forecolor of grc tName to item i of colorlist set the linesize of grc tName to 8 setheading i*360/6 forward 100 stopturtle tName
end repeat
end mouseUP
To see some examples run this in the msg box:
go url "http://home.infostations.net/jhurley/MultipleTurtle.rev"
-------------------------------------
And lastly, there is the flavor which is most useful in teaching science students to program in Transcript. It addresses only the turtle graphic (the cursor). It draws an image rather than a graphic. (A graphic slows down dramatically for lengthy draws--the graphic must repeatedly be redrawn with each additional graphic points since this is an *evolving* line.) It is based on the assumption that beginning students are more receptive to graphic output rather than text. This has the potential for quite sophisticated applications. After a short while students learn how to program satellite orbits--the satellite being the turtle (cursor).
For some examples, run this in the msg box:
go url "http://home.infostations.net/jhurley/TurtleGraphics.rev"
All three tools are RR 1.1.1 compatible.
Jim
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
