Observations Re: Images
Sivakatirswami
katir at hindu.org
Sat Jun 22 20:56:01 EDT 2002
> I have two icons for the same button: enabled & disabled. Switching
> the disabled property of the button causes the image to return to its
> original size.
>
> I guess it's back to duplicate images in substacks of the same stack
> or standardized image size...a poor second choice.
A resizeIcon property would be useful, but if it resizes the image, then one
has the caveat that if you want to use it in other instances at a different
size... what happens?
A work around that I came to was to store a single instance of the image in
a substack and set a custom prop for each one defining its default/contant
width and height. Then, in pre-open card handlers, resize the image on the
fly for buttons on that card by passing a ratio and the image number. In
this case I have 18 images that are used in multiple instances of various
sizes on different cards.
Image in invisible substack:
images id 2001 to 2018 each with a custom prop named "mySize" set to 214,420
========
On any given card where the size is predetermined... in this case for 18
buttons...
on preopenCard
repeat with x = 1 to 18
resizeImage .17, (2000+x)
end repeat
end preopenCard
on closeCard
repeat with x = 1 to 18
restoreimagesize (2000+x)
end repeat
end closeCard
stack script: ## to be called from any card pre-opencard handler
or whenever, for that matter... in this case the buttons on the card above
are 17 percent of the original.
on resizeImage theRatio theImage
set the defaultStack to "alphabet"
set the width of image id theImage to theRatio * item 1 of the mySize of
image id theImage
set the height of image id theImage to theRatio * item 2 of the mySize
of image id theImage
end resizeImage
on restoreImageSize theImage
set the defaultStack to "alphabet"
set the width of image id theImage to item 1 of the mySize of image id
theImage
set the height of image id theImage to item 2 of the mySize of image id
theImage
end restoreImageSize
This has the interesting effect of allowing one to use images in multiple
instances with a single set of image data. In this case these were vector
images and the resulting stack was incredibly small, though from a user
point of view, see the images in larger sizes, give the expectation that the
stack would be much fatter... if one had true SVG, this could rather useful
you can see it in action at www.himalayanacademy.com/studyhall/
just go down to the bottom, download the HAKEY.MC stack (if you are a rev or
mc user you won't need the full stand alone) then download the portal stack
and then download "Shum Color Basics) save to your hard drive and open in
Rev... it's not locked.
Hinduism Today
Sivakatirswami
Editor's Assistant/Production Manager
katir at hindu.org
www.HinduismToday.com, www.HimalayanAcademy.com,
www.Gurudeva.org, www.hindu.org
Read The Master Course Lesson of the Day at
http://www.gurudeva.org/lesson.shtml
More information about the use-livecode
mailing list