Clipping

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Clipping

Stéphane Ducasse
In SMxCanvas>>copyClipRect: aRectangle
        ^ self copyOrigin: origin clipRect: (aRectangle translateBy: origin)

SMxFormCanvas>>copyOrigin: aPoint clipRect: aRectangle
        "Return a copy of this canvas with the given origin. The clipping rectangle of this canvas is the intersection of the given rectangle and the receiver's current clipping rectangle. This allows the clipping rectangles of nested clipping morphs to be composed."
        ^ self copy
                setOrigin: aPoint
                clipRect: (clipRect intersect: aRectangle)

Canvas>>copyClipRect: newClipRect

        ^ ClippingCanvas canvas: self clipRect: newClipRect

FormCanvas>>copyOrigin: aPoint clipRect: aRectangle
        "Return a copy of this canvas with the given origin. The clipping rectangle of this canvas is the intersection of the given rectangle and the receiver's current clipping rectangle. This allows the clipping rectangles of nested clipping morphs to be composed."
        ^ self copy
                setOrigin: aPoint
                clipRect: (clipRect intersect: aRectangle)


Do you think that we can remove ClippingCanvas. There are too many canvases in Pharo.

Stef
Reply | Threaded
Open this post in threaded view
|

Re: Clipping

Igor Stasenko
On 9 February 2011 14:57, Stéphane Ducasse <[hidden email]> wrote:

> In SMxCanvas>>copyClipRect: aRectangle
>        ^ self copyOrigin: origin clipRect: (aRectangle translateBy: origin)
>
> SMxFormCanvas>>copyOrigin: aPoint clipRect: aRectangle
>        "Return a copy of this canvas with the given origin. The clipping rectangle of this canvas is the intersection of the given rectangle and the receiver's current clipping rectangle. This allows the clipping rectangles of nested clipping morphs to be composed."
>        ^ self copy
>                setOrigin: aPoint
>                clipRect: (clipRect intersect: aRectangle)
>
> Canvas>>copyClipRect: newClipRect
>
>        ^ ClippingCanvas canvas: self clipRect: newClipRect
>
> FormCanvas>>copyOrigin: aPoint clipRect: aRectangle
>        "Return a copy of this canvas with the given origin. The clipping rectangle of this canvas is the intersection of the given rectangle and the receiver's current clipping rectangle. This allows the clipping rectangles of nested clipping morphs to be composed."
>        ^ self copy
>                setOrigin: aPoint
>                clipRect: (clipRect intersect: aRectangle)
>
>
> Do you think that we can remove ClippingCanvas. There are too many canvases in Pharo.
>

More than that.
I'd prefer not seeing such invocations (copyClipRect:)

a more correct form for usage is:

canvas clipBy:rect during: [ .... ]

so it will clip using given rect, and then restore clipping back to
previous one.

And of course there is no need to copy canvas (except from some corner
cases).. it's only adds a complexity on top of already complex drawing
operations.

--
Best regards,
Igor Stasenko AKA sig.