Visibility against an unknown background
Grant Edwards
grante at visi.com
Tue Oct 24 11:29:59 EDT 2006
On 2006-10-24, Grant Edwards <grante at visi.com> wrote:
> On 2006-10-24, Odalrick <odalrick at hotmail.com> wrote:
>
>> I need to draw visible lines on pictures with wxPython. That means I
>> can't simply use, for instance, a black line since it wont be visible
>> on a black or dark picture.
>>
>> Painting applications like the GIMP accomplish this by altering the
>> colour of the line based on the colour of the pixel it covers,
>
> Yup.
>
>> but the only way I can think of doing that is getting each
>> pixel, transforming the colour then painting it on the screen,
>> which seems like a horribly inefficient way do it.
>
> That's not how it's generally done. When you draw a line, most
> graphics toolkits allow you to specify an "operator" that is
> applied to the existing pixel and the line-color to determine
> the new pixel color. The traditional way to draw lines on
> something with varying colors is to use the "xor" operator when
> drawing the lines.
Oh, another big benefit from using the xor operator is that you
can restore the pixmap to it's original state by simply
repeating the exact same line-draw operation. That makes it
trivial to do things like rubber-banding.
--
Grant Edwards grante Yow! I just forgot my
at whole philosophy of life!!!
visi.com
More information about the Python-list
mailing list