proportional resizing group of graphics

viktoras didziulis viktoras at ekoinf.net
Sat Sep 29 10:51:00 EDT 2007


Thanks, Bjoernke!

I naively expected an existing but yet undiscovered possibility for the 
group and its contents to behave like window on resize by setting 
properties in geometry manager. So the answer turned out to be "no-no" - 
need scripting for this...

Actually the map contains European, North African and Levantine 
countries and then oceans and continents for the rest of the world. As a 
backdrop I use public domain map from the CIA factbook converted to png 
(originally it is in pdf): 
https://www.cia.gov/library/publications/the-world-factbook/docs/refmaps.html

There was an idea about extraction of country polygons from shapefile - 
but then these have to be thinned, reprojected to match my backdrop 
(which is in Robinson projection) , etc, etc, etc... Finally I ended up 
drawing polygons manually - well, couple of days of work, not too long. 
Map's stack communicates with a database and either shows or hides 
polygons whose identifiers are fetched from the database in a query 
result like:

repeat foreach item identifier in dbOut
set the visible of graphic identifier to true
end repeat

of course all the polygons have to be "switched off" before this in 
another cycle. That's all to it...

Now trying to smoothly and eye-candilly (with zoom out/in animation) 
switch perspective from Europe to Entire world and vice versa without 
messing the polygons on  the map.

Thanks again for your help and Regards!
Viktoras







Björnke von Gierke wrote:
> 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
>




More information about the use-livecode mailing list