[Cuis-dev] scaling an ImageMorph

Juan Vuletich juan at cuis.st
Sun Mar 30 11:29:06 PDT 2025


On 3/19/2025 6:11 PM, Mark Volkmann via Cuis-dev wrote:
> What is the proper way (minimum code) to scale an ImageMorph?
> Do I have to scale both the form into which the image file is loaded 
> AND the ImageMorph like this?
>
> filePath := '/Users/volkmannm/Pictures/images/altitude1600.jpg'.
> percent := 0.75.
> form := Form fromFileNamed: filePath :: magnifyBy: percent.
> morph := ImageMorph newWith: form :: scaleBy: percent.
>
> When I add this morph to a SystemWindow, the image is scaled, but 
> there is an orange rectangle of the original size behind the image. 
> See the attached screenshot.
>
> -- 
> R. Mark Volkmann
> Object Computing, Inc.

Just scale the form prior to using it: `(ImageMorph newWith: (ImageMorph 
defaultForm magnifyBy: 0.5)) openInWorld.`

A new kind of morph that is not part of the BoxMorph hierarchy would 
give better flexibility, by not using an `extent` instance variable. But 
may be the simplest solution works for you.

Cheers,

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250330/1673d645/attachment.htm>


More information about the Cuis-dev mailing list