[Cuis-dev] scaling an ImageMorph

H. Hirzel hannes.hirzel at gmail.com
Mon Mar 31 08:48:50 PDT 2025


Hi Juan

the solution you provide is good as it is a good workaround. Looks a bit 
clumsy however constructing two ImageMorph objects as you start with a 
jpg form. And Mark wants to include this example in a booklet about Morphic.

Reading a JPG picture into an instance of Form, scaling it and 
constructing an ImageMorph object works fine as example [1b] in this

https://lists.cuis.st/mailman/archives/cuis-dev/2025-March/010742.html

thread shows.

So I'd like to draw your attention that on the fact that shrinking an 
ImageMorph object does not work as example 2 in the same thread shows.

The solution to  make ImageMorph>>shrinkBy:  work provided by 
Weslleymberg Lisboa is shown in this mail

https://lists.cuis.st/mailman/archives/cuis-dev/2025-March/010745.html


Current ImageMorph>>minimumExtent implementation

````
minimumExtent

      ^ image extent + (2 * self interiorOrigin)
````

-------------------------------------------------------------------------------------------


Weslleymberg proposal for ImageMorph>>minimumExtent

````
minimumExtent

      ^ image extent + (2 * self interiorOrigin) * self scale

-------------------------------------------------------------------------------------------


Seems to be pretty straightforward though it took him a considerable 
time to come up this it. What do you think about this solution? Are 
there side-effects about this fix? If not I suggest that it should be 
included.

Kind regards

Hannes


On 30/03/2025 8:29 pm, Juan Vuletich via Cuis-dev wrote:
> 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/20250331/27475533/attachment-0001.htm>


More information about the Cuis-dev mailing list