Scaling grouped graphics for iOS etc.
Posted: Fri Jul 01, 2011 8:22 pm
The many screen sizes and resolutions of mobile devices make it important to be able to incorporate vector graphics that can easily be scaled if one wants to make a single stack that supports multiple devices and orientations. (Note: although it's possible to import vector graphics in some cases, the importing is done by interpreting the file information and using it to construct the graphic out of LiveCode graphic objects.)
Unfortunately, many typical iOS graphics have to be constructed as groups of individual LiveCode graphic objects, and scaling the group DOES NOT properly scale the resulting graphic. (Think of the little red symbol for deleting, a red circle with a white outline and a white bar across it: a group of two graphics is required.) The only way I can think of to scale such a group is by brute force (for an example see below). Is there a better way? Will there someday be support for SVG or EPS or other standard form of vector graphics?
George
Unfortunately, many typical iOS graphics have to be constructed as groups of individual LiveCode graphic objects, and scaling the group DOES NOT properly scale the resulting graphic. (Think of the little red symbol for deleting, a red circle with a white outline and a white bar across it: a group of two graphics is required.) The only way I can think of to scale such a group is by brute force (for an example see below). Is there a better way? Will there someday be support for SVG or EPS or other standard form of vector graphics?
Code: Select all
on scaleGraphic pGroup, pScale
local tLoc
repeat with x = 1 to the number of graphics in pGroup
put the loc of pGroup into tLoc
get the width of graphic x of pGroup
set the width of graphic x of pGroup to it * pScale
get the height of graphic x of pGroup
set the height of graphic x of pGroup to it * pScale
get the linesize of graphic x of pGroup
set the linesize of graphic x of pGroup to it * pScale
set the loc of graphic x of pGroup to tLoc
end repeat
end scaleGraphic