wx.Mask

Hi,

I am starting with the "drag image" code from the demo where wxPython
obviously can draw text on a multi-colored background without changing the
background.

I notice the need for a background colour which (from the demo code:)
[...]
        # Make a shape from some text
        text = "Some Text"
        bg_colour = wx.Colour(57, 115, 57) # matches the bg image
[...]

My problem is that the mask fails on my side and I get the rectangle of my
text with my backround color.

What I don't get in the above sample is: what color is that ? as the
background of the demo clearly has many colors.

I'm not a graphics expert.

Regards,

Philippe

···

--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________

Well I just used DrawText to fix the problem :slight_smile:

···

On Wednesday 24 January 2007 10:35, Philippe C. Martin wrote:

Hi,

I am starting with the "drag image" code from the demo where wxPython
obviously can draw text on a multi-colored background without changing the
background.

I notice the need for a background colour which (from the demo code:)
[...]
        # Make a shape from some text
        text = "Some Text"
        bg_colour = wx.Colour(57, 115, 57) # matches the bg image
[...]

My problem is that the mask fails on my side and I get the rectangle of my
text with my backround color.

What I don't get in the above sample is: what color is that ? as the
background of the demo clearly has many colors.

I'm not a graphics expert.

Regards,

Philippe

--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________

Philippe C. Martin wrote:

Hi,

I am starting with the "drag image" code from the demo where wxPython obviously can draw text on a multi-colored background without changing the background.

I notice the need for a background colour which (from the demo code:)
[...]
        # Make a shape from some text
        text = "Some Text"
        bg_colour = wx.Colour(57, 115, 57) # matches the bg image
[...]

My problem is that the mask fails on my side and I get the rectangle of my text with my backround color.

What I don't get in the above sample is: what color is that ? as the background of the demo clearly has many colors.

It's simply a color that that was chosen such that it blends well with the green texture used in the background. You'll notice in the following code that this color is used to first fill the bitmap that the text is drawn on, and then it is set as the mask color so when the bitmap is drawn the areas with this color be kept transparent. So why was it important that the color be blendable with the background texture? Try dragging the text and dropping it over the star. You'll probably notice some bits of extra greenish pixels around the text. This is from the anti-aliasing done when the text was drawn on the memory DC, to allow it to blend with the background and make the edges to appear smoother. So by choosing a similar color the text doesn't show any anti-aliasing artifacts when drawn on the textured background.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!