Shrinking an image to a button icon

Jim Carwardine JimCarwardine at OwnYourFuture-net.com
Tue Dec 23 06:13:48 EST 2003


Oooohhhh... Thanks, Jacque... Jim

on 12/23/03 2:49 AM, J. Landman Gay wrote:

> On 12/22/03 6:50 PM, Jim Carwardine wrote:
> 
>> Now I'm getting unpredictable results and I'm not sure why.  Sometimes my
>> picture is 40 pixels too wide in all 4 dimensions, sometimes my picture is
>> offset to the top left by 40 pixels and sometimes it's right on.  I'm
>> getting an error (can't set that property) on the line "set the rect of card
>> 1 of stack "Picture" to it".  Jim
>> 
>> Here's my script...
>> 
>> if it is "Enlarge" then
>>     lock screen
>>     go stack "Picture"
>>     put 300 into theTargetSize -- adjust size here
>>     set the filename of img "Palette Picture Graphic" to the pictPath of me
>>     put theTargetSize/the formattedwidth of img "Palette Picture Graphic"
>> into theRatio
>>     set the width of img "Palette Picture Graphic" to theTargetSize
>>     set the height of img "Palette Picture Graphic" to \
>>         round(the formattedheight of img "Palette Picture Graphic" *
>> theRatio)
>>         set the topleft of img "Palette Picture Graphic" to 0,0
>>     get the rect of img "Palette Picture Graphic" of card 1 of stack
>> "Picture"
>>     set the rect of card 1 of stack "Picture" to it
>>     set the topleft of stack "Picture" to 380,310
>>     palette stack "Picture"
>>   end if
> 
> 
> Almost there. You can't set the rect of a card. You have to set its
> width and its height separately. Instead of the line "set the rect of
> card 1..." you need to script as follows (watch for line wrap):
> 
>  lock screen
>  go stack "Picture"
>  put 300 into theTargetSize -- adjust size here
>  set the filename of img "Palette Picture Graphic" to the pictPath of me
>  put theTargetSize/the formattedwidth of img "Palette Picture Graphic"
> into theRatio
>  set the width of img "Palette Picture Graphic" to theTargetSize
>  set the height of img "Palette Picture Graphic" to \
>      round(the formattedheight of img "Palette Picture Graphic" *
> theRatio)
>  -- changes to script start here:
>  set the width of cd 1 to the width of img "Palette Picture Graphic"
>  set the height of cd 1 to the height of img "Palette Picture Graphic"
>  set the topleft of img "Palette Picture Graphic" to 0,0
>  set the topleft of stack "Picture" to 380,310
>  palette stack "Picture"
> 

-- 

OYF is... Highly resourceful people working together.
<http://www.OwnYourFuture-net.com>

Own Your Future Consulting Services Limited,
1959 Upper Water Street, Suite 407, Halifax, Nova Scotia. B3J 3N2
Info Line: 902-823-2477, Phone: 902-823-2339. Fax: 902-823-2139





More information about the Use-livecode mailing list