Re: [wxpython-users] What's going on with wx.Pen()?
by Tim Roberts other posts by this author
May 8 2008 3:34PM messages near this date
[wxpython-users] What's going on with wx.Pen()?
|
RE: [wxpython-users] What's going on with wx.Pen()?
Marlin Rowley wrote:
>
> I'm confused. I've set up a rectangular region program that will draw
> a rectangle and dynamically size it when the user drags the mouse.
> This is going to be used for viewing only images within the window. I
> want the pen to be bright red. And I want it to be that way ALL the
> time! For some reason, when I change the background color of my brush
> to something OTHER than black, I get a different color. Why?
Is it really that confusing? Notice:
> def OnMotion(self,event):
> if event.Dragging() and event.LeftIsDown():
> # get device context of canvas
> dc= wx.BufferedDC(wx.ClientDC(self),self.buffer)
>
> # Set logical function to XOR for rubberbanding
> dc.SetLogicalFunction(wx.XOR)
That's the reason. You are drawing with a red pen, but the logical
function means that the color of the pen is XOR-ed with the color of the
background. When the background is black, the pixel value is 0, and
anything XORed with 0 is itself. When the background is not black,
XORing with red simple inverts the red component in whatever color was
there before.
This is absolutely normal behavior for rubber banding. If you really
want a red rubber band all of the time, then you can't use a simple
erase-the-old and draw-the-new scheme for drawing the rubber band. You
will have to use some kind of double-buffered scheme, by keeping a copy
of the background in a bitmap. Then every time the rubber banding
changes, you'll have to copy the virgin bitmap to the screen, then draw
the rubber band on top of it.
--
Tim Roberts, timr@[...].com
Providenza & Boekelheide, Inc.
_______________________________________________
wxpython-users mailing list
wxpython-users@[...].org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Thread:
Marlin Rowley
Tim Roberts
Marlin Rowley
Tim Roberts
Marlin Rowley
Christopher Barker
Marlin Rowley
Christopher Barker
Christopher Barker
Marlin Rowley
|