the points of graphic

Michael Kristensen michael-kristensen at dsa-net.dk
Sun Jan 19 10:41:51 EST 2014


hi Jim

Where can one use the code?

I put it in a button in alejandros stack and get errors.

I have never seen the To Poly syntax before

I ditto the challenge given to you before.

Michael





> This script will provide the individual points.
> 
> on mouseUp
>   put the width of this card/2 into x0
>   put the height of this card/2  into y0
>   put 6 into n
>   put 50 into L
>   put 360/n into tAngle
>   put x0,y0 & cr after tPoints
>   set the points of grc "polygon" to tPoints
>   repeat with i = 1 to n+1 -- plus 1 to close
>      --Calculate each line segment individually
>      --dx and dy and the x and y projections of the line segment
>      repeat with j = 1 to i
>         add  L * cosine(j*tAngle) to dx
>         subtract    L * sine(j*tAngle) from dy
>      end repeat
>      put x0 + dx , y0 + dy into theCoord[i] --if you want the coordinates of each vertex
>      put (x0 + dx), ( y0 + dy) & cr after tPoints
>      set the points of grc "polygon" to tPoints--if you want to see the polygon evolve
>      put 0 into dx
>      put 0 into dy
>   end repeat
> end mouseUp 
> 
> Given the individual points (theCoord[i]), it would be possible to do things line draw all diagonals, connect each vertex with all the others. When n is large, it is a pretty picture.
> 
> But, of course, there is always the much simpler Turtle Graphics.
> 
> To poly n, L
> repeat n 
>  forward L 
>  left 360/n
>  put xycor() into theVertex[i]
> end repeat
> end poly




More information about the use-livecode mailing list