graph and fonction

Wilhelm Sanke sanke at hrz.uni-kassel.de
Sun Nov 17 17:14:01 EST 2002


On Sun, 17 Nov 2002,  Grudet at aol.com wrote

> Please what are the instructions for dysplaying graph functions in a stack
> How can i do to plot points and line on a stack by programming
>
> Thanks for help
>
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

- the x- and y-axis is drawn:

on mouseUp
 call Koordinaten of this stack
  create field "y-1"
  set the loc of field "y-1" to (10 , 25)
  put "1" into field "y-1"
  create field "x-180"
  set the loc of field "x-180" to (190 , 125)
  put "180" into field "x-180"
  choose browser tool
  set the layer of image 1 to 1
end mouseUp

- a sinus curve is drawn:

on mouseUp
   choose line tool
  drag from (10 , 125) to (370, 125)
  choose curve tool
  repeat with i = 0 to  360
    put ( -sin(i * pi / 180)) into yeins
    put ( -sin((i + 1) * pi / 180)) into yzwei
    drag from (i + 10 , 125 + 100 * yeins) to ((i + 10 + 1), 125 + 100 *
yzwei)
  end repeat
  choose browser tool
  set the layer of image 1 to 1
end mouseUp

Parts of these scripts could be simplified.

Hope this information is helpful.

Regards,

Wilhelm Sanke




More information about the use-livecode mailing list