Jecel Assumpcao Jr
jecel at merlintec.com
Wed Mar 26 23:11:54 UTC 2003
On Tuesday 25 March 2003 18:05, legyxo42 wrote:
> Hi, I'm trying to clip drawing submorphs with baseBounds of
> their owner. code looks like this:
> drawon: aCanvas = (
> baseDrawOn: aCanvas.
> 0 = morphCount ifFalse: [| c |
> c: (aCanvas copyOffset: position).
> c clip: baseBounds. "is this OK?"
It is okay, but not enough since clipping is not fully implemented but
only has some methods here and there. In particular, this line would be
c gc setClipRectangle: baseBounds.
Adding this line here is a disaster, unfortunately, since the graphics
context (gc) is shared with other canvases and this will mess things
It is very natural to assume that "c clip: ..." would take care of the
details, but it doesn't.
> morphsReverseDo: [| :m | m drawOn: c].
Here is the simplest solution that will mostly work:
drawon: aCanvas = (
0 = morphCount ifFalse: [| c |
c: (aCanvas copyOffset: position).
morphsReverseDo: [| :m | c withClip: (baseBounds translate: position
Do: [m drawOn: c]].
This code looks good but when you move the morph the shadow still
includes the outlines of any submorphs that are sticking out. It is
probably easy to fix this.
Having withClip:Do: inside the loop is bad since the same old clipping
rectangle keeps being saved and restored over and over and is always
being replaced with the same rectangle. It would be nice to do this
More information about the Self-interest