I don't get how this would be more efficient. You would have to reacreate a
very large mask everytime you change the canvas. Creating a lot of small
masks only one time seems a lot more effiecent to me.

Also, what do you mean with this:
"This is because drawing a masked picture into a canvas doesn't erase the
background behind the masked areas which is proper behavior."
If you mean that the background should be erased if you draw a mask to it, I
think you're wrong. The whole point of a mask is to not affect anything in
the masked area. If you wan't this behaviour you can use
Canvas.ClearRectinstead of
Canvas.Refresh. This is also what I would do. It's indeed not effiecent to
clear the canvas totaly everytime, but ClearRect should be.

So, what I'd do:
When you draw a shadow, keep track of the X,Y,Width and Height (store in an
array or something). When you are going to draw the next shadow, call
Canvas.ClearRect(X,Y,Width,Height) first, then draw the shadow.

Maarten


On 22/06/06, Stephen Dodd <[EMAIL PROTECTED]> wrote:

Wouldn't it be nice to apply a mask directly to a Canvas?

Currently the only way to mask a canvas is to create a Picture, apply
the a mask to the picture and then use Canvas.Graphics.DrawPicture
MyPicture, 0, 0.

While this works, it would be more convenient to have a mask applied
directly to the Canvas. For instance, lets say for example you want
to recreate the glowing OK button on OS X.  You would need to mask
each of your dozen or two pictures shape that you use to animate the
glow in the rounded rectangle, rather than masking the canvas once.

Another example: Lets say you have an animated UI element that has a
shadow that you create using a mask. You have to be careful to erase
the full background or use Refresh when replacing one shadowed
picture for the next because otherwise overlapping shadows start to
multiply until you get black.  (This is because drawing a masked
picture into a canvas doesn't erase the background behind the masked
areas which is proper behavior.) Erasing is viable but inefficient.
It would be more efficient to have a nice shadow mask on the UI
element and then flop pictures in and out of it.

Another example: you can't edit the canvas.graphics property directly
and apply a mask. You need to offload your editing into an another
masked picture and bring it in.

Another example: you want to change the mask on your canvas.  It
would be nice to be able to do this without knowledge of what is
currently on the canvas and re-creating the contents.

Before I submit a feature request, am I going about this the wrong
way? Am I missing something obvious?  Is applying a mask to a picture
and then applying the picture to the Canvas the normal and
recommended route?

Thanks!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to