[Cuis-dev] tiled background image

Mark Volkmann r.mark.volkmann at gmail.com
Tue Oct 1 17:04:26 PDT 2024


In the current code the WorldMorph drawOn: method sends
aCanvas image: backgroundImage at: `0 at 0`
if backgroundImage is set.
That can be set with code like the following:

filePath := '/Users/volkmannm/Pictures/images/altitude1600.jpg'.
byteArray := (filePath asFileEntry readStream) binary contentsOfEntireFile.
self runningWorld backgroundImageData: byteArray.

The backgroundImageData: method is defined in PasteUpMorph which is the
superclass of WorldMorph.
That method sends #buildMagnifiedBackgroundImage to self.
That method contains this line:

backgroundImage := image magnifyTo: extent.

That stretches the image to fit the size of the WorldMorph which is the
size of the whole window.
It does not maintain the aspect ratio of the image.

That seems fine for images that are patterns, but not for images that
contain recognizable things like people, animals, buildings, cars, ...

I think it would be great to have three options for how a background image
is used,
1) stretch as is done currently
2) change size to cover WorldMorph without changing the aspect ratio (right
or bottom of image could be cut off)
3) tile the image over the window

I have learned how to modify WorldMorph and PasteUpMorph to tile the image
and the cover option wouldn't be difficult to implement.
If I were to submit a change set that modifies WorldMorph and PasteMorph to
support all three options, would it be considered?


On Mon, Sep 30, 2024 at 8:23 PM Juan Vuletich <juan at cuis.st> wrote:

> On 9/30/2024 8:21 PM, Mark Volkmann via Cuis-dev wrote:
>
> I see the Squeak has the class BackgroundMorph that supports tiling an
> image over the World background, but that class is not in Cuis. Is there
> another way to tile an image over the World background that is in the base
> Cuis image?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
>
> Yes. You need to create your own morph, and in its #drawOn: method do
> whatever you need. You can also modify WorldMorph so it tiles. Go Smalltalk
> go!
>
> Cheers,
>
> --
> Juan Vuletichcuis.stgithub.com/jvuletichresearchgate.net/profile/Juan-Vuletichindependent.academia.edu/JuanVuletichpatents.justia.com/inventor/juan-manuel-vuletichlinkedin.com/in/juan-vuletich-75611b3twitter.com/JuanVuletich
>
>

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20241001/f3fad0b6/attachment.htm>


More information about the Cuis-dev mailing list