graph and function

Jim Hurley jhurley at infostations.com
Mon Nov 18 10:08:00 EST 2002


Wilhelm Sanke wrote:
>
>Hello,
>
>here is an example to draw functions from a stack used to introduce
>students:
>
>
>- The first sript sets the values for the coordinates (and is then
>called from the first mouseup-handler):
>
>on Koordinaten
>    choose line tool
>   drag from (10 , 125) to (370, 125)
>   drag from (10 , 0) to (10 , 250)
>   set the width of the templateField to 25
>   set the height of the templateField to 25
>   set the textAlign of the templateField to "center"
>   set the opaque of the templateField to false
>   set the showBorder of the templateField to false
>end Koordinaten


etc.

There is a tool which is very useful in introducing students to 
graphics and that is Turtle Graphics first introduced in Logo. It is 
not difficult to implement in Rev as well.

For example, to draw a sine curve with an amplitude of 100 pixels, 
the button script would be:

On mouseUp
   StartTurtle -- initiate Turtle Graphics
   repeat with a = 0 to 360
     setxy a, 100*sine(a)
   end repeat
end mosueUP

Where "StartTurtle" and  "sine()" have been defined for the students 
in the stack script. ("Sine" differs from "Sin")

function sine a
   return sin(pi/180* a)
end sine

The axes may be drawn with such simple statements as "Forward 100" 
and "Setheading 90"
-- 
Jim Hurley



More information about the use-livecode mailing list