proportional resizing group of graphics

Björnke von Gierke bvg at mac.com
Sat Sep 29 09:36:50 EDT 2007


Any chance of sharing  the country generation code? I am trying to 
generate random maps myself.

Resizing polygons of unknown size, all in the same aspect is a somewhat 
complicated matter. Here some random thoughts of mine:

You could multiply all dimensions by a modifier, and then the original 
location by the same multiplier:

put the loc of graphic 1 into theLoc
set the width of graphic 1 to the width of graphic 1 div 2
set the height of graphic 1 to the height of graphic 1 div 2
set the Loc of graphic 1 to item 1 of theLoc div 2, item 2 of theLoc 
div 2

If you want to size them to an arbitrary size, you need to know the 
total width and height of all polygons combined, and then find out what 
ratio the new total size produces (If you don't need perfect precision, 
you can also group all your polygons, and get the size of that group, 
which will give you an approximation of the size of all polygons 
combined):

put 100 into oldWidth
put 50 into oldHeight
put 40 into newWidth
-- 40/100= 0.4 (ratio)
-- 0.4 * 50 = 20 (newHeight)
put round(newWidth / oldWidth * oldHeight) into newHeight

If you want the result to be pixel precise, it's best to store the 
points of the polygons in a multiple of any actually shown size, to 
reduce rounding/trunctuation problems.

If you have AnimationEngine from Malte, you can use the aspect... 
handlers.

For speed, lock screen once then set all polygons. Alternatively, you 
can get the points of your polygon, multiply all entries by your ratio, 
and then set the points of the polygon to that. This might be faster 
then resizing visual objects (untested).

Hope this will get you thinking (and that I haven't made any grave 
thinking errors)
Bjoernke

On 29 Sep 2007, at 14:20, viktoras didziulis wrote:

> is there any property that allows proportional resizing of grouped 
> graphics when group's size changes. Or all one can do is setting width 
> and height of each and every graphic within the group from within a 
> script ?
>
> Making a world map with countries represented by polygons. Now trying 
> to figure out what is the best way to make it zoomable :-)
>
> Best regards
> Viktoras

-- 

official ChatRev page:
http://chatrev.bjoernke.com

Chat with other RunRev developers:
go stack URL "http://homepage.mac.com/bvg/chatrev1.3.rev"




More information about the use-livecode mailing list