Re: setting Gtk2::Gdk::Color pixel

muppet <scott asofyet org> writes:

         $gc->set_function ('xor');
         $gc->set_foreground ($widget->style->white);

I think that can flip a 0 pixel (which is probably black) to become
white, and then back again, but for a different background I think it
has to be something like

    my $fgcolor = $widget->style->fg('normal');
    my $bgcolor = $widget->style->bg('normal');

    my $mycolor = Gtk2::Gdk::Color->new;
    $mycolor->set_pixel ($fgcolor->pixel ^ $bgcolor->pixel);
    $gc->set_foreground ($mycolor);

Ie. for xors or other crazy GCFunction operations I think the GdkColor
is not a colour, just a way to pass a pixel value with the bits you want
to flip or set or whatever.

(I imagine apart from xors most such things are only really useful for a
pseudocolor where you've setup particular colours in particular pixels
of the colormap.  Maybe on a truecolor you could OR in some extra red on
top of other drawing, or something like that though.)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]