use-revolution digest, Vol 1 #301 - 16 msgs

Jim Hurley jphurley at jps.net
Sun Mar 31 12:11:04 EST 2002


>
>Recently, Brad Allen wrote:
>
>  > I'm trying to script the drawing of a hexmap, with each hex having an
>  > individual set of properties. This is easy to do by manually drawing
>  > each hex, but I'm having trouble automating this process because of a
>>  weird quirk of the drag command.
>>
>  > Whenever I use the drag command with a drawing tool (such as regular
>>  polygon), Revolution creates a graphic which appears to be the
>>  expected size, but in fact is part of a bigger graphic which always
>>  ends up being the size of the entire card window.
>>
>>  Here is an example script which gives this result:
>>
>>  on drawHexTest
>>  set the polysides to 6
>>  choose regular polygon
>>  drag from "50,50" to "50,80"
>>  end drawHexTest
>>
>>  If I iterate the drag command, each subsequent graphic is within the
>>  same "canvas" and has the very same id. How can I draw individualized
>>  graphic objects?
>
>The reg poly tool is used to make image objects.  Try this instead:
>
>   set the style of the templateGraphic to "regular"
>   set the rect of templateGraphic to 0,0,40,40
>   set the polysides of the templateGraphic to 6
>   create graphic
>
>Regards,
>
>Scott Rossi
>Creative Director


And if you wish to draw multiple polygons with individual properties 
you need individual graphic objects. For example to draw polygons of 
3,4, ....,8 sides:

on mouseUp
   clean
   put 0 into x
   put 0 into y
   put 80 into dx
   put 80 into dy
   put 3 into n
   repeat 6
     set the style of the templateGraphic to "regular"
     set the rect of templateGraphic to x,y,x+100,y+100
     set the polysides of the templateGraphic to n
     create graphic "myPoly" & n
     add 1 to n
     add dx to x
     add dy to y
   end repeat
   choose the browse tool
end mouseUp

on clean
   --Delete only myPoly graphics
   repeat with i = the number of graphics down to 1
     if "myPoly" is in the name of graphic i then  delete graphic i
   end repeat
end clean


-- 
Jim Hurley



More information about the use-livecode mailing list