[Cuis-dev] Fix for VectorCanvas>>image:at:sourceRect:

Luciano Notarfrancesco luchiano at gmail.com
Fri Nov 28 23:57:18 PST 2025


Works great, thanks!
I guess no one was using this, and I'd like to share how I'm using it
because it might be useful for other people programming with Morphic.
I use it in morphs that scroll continuously. This is sometimes called
rolling, or waterfall effect. For example, I have a SpectrogramMorph that
has an 'image' (a Form) and a 'position' (the current horizontal position
in the image) that starts at 0. Another process periodically draws a new
vertical line at the current position, and updates position := position + 1
\\ image width. Then, in the drawOn:, I just make two calls to
image:at:sourceRect: like this:

drawOn: aCanvas
    | w h p |
    w := image width - 1.
    h := image height - 1.
    p := position.
    "from left to right, draw from the next column position+1 to the last
column:"
    aCanvas image: image at: 0 @ 0 sourceRect: ((p + 1) @ 0 corner: w @ h).
    "and then wrap and continue drawing from the first column to the
current column position:"
    aCanvas image: image at: (w - p - 1) @ 0 sourceRect: (0 @ 0 corner: p @
h)

On Fri, Nov 28, 2025 at 11:20 PM Juan Vuletich <juan at cuis.st> wrote:

> Hi Luciano,
>
> On 2025-11-27 2:24 PM, Luciano Notarfrancesco via Cuis-dev wrote:
> > This fixes a little problem. I thought we fixed it before, but there
> > was still an inconsistency that showed up when starting unzoomed and
> > then zooming in or out.
> >
> This method has had many iterations. The real reason is that WarpBlt has
> integer arguments. The geometrically correct result requires Float
> arguments. Besides, a better image resampling algorithm would help too.
> Some day...
>
> I just pushed a slightly different version of your fix, that should give
> identical results. I also updated two other related methods for
> consistency.
>
> Thanks!
>
> --
> Juan Vuletich
> www.cuis.st
> github.com/jvuletich
> researchgate.net/profile/Juan-Vuletich
> independent.academia.edu/JuanVuletich
> patents.justia.com/inventor/juan-manuel-vuletich
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20251129/76e61428/attachment.htm>


More information about the Cuis-dev mailing list