Re: Setting =?UTF-8?Q?*color=5Frgba=20properties?=



On Tue, 03 Feb 2009 17:40:47 -0800, Brandon Lewis
<brandon_lewis berkeley edu> wrote:
> There are a number of choices. The simplest, conceptually, is not to use
> the *rgba properties at all, but to create a solid cairo pattern and use
the
> corresponding *pattern property. This has the advantage of being flexible
> in case you later decide you don't want a solid color at all, but a
gradient
> or image.

Good idea; I hadn't thought of that one.

> But to actually answer your question, you use shifting to pack the three
> values into a 32-bit integer. Your gdk.Color object is a struct
containing these
> three values. You shift each byte shift each byte into the proper
location and
> then OR them all together.  Let's say you've extracted these into the
variables
> red, green, and blue. The red bytes is the most significant byte, so it
must be
> shifted the most number of bits leftward (24 places). The alpha byte
> doesn't need to be shifted at all.

The mere talk of bits makes me shudder! Thanks for explaining bit shifting,
it seems I was on the right track but I thought I was missing something
obvious (I think I need to re-read some basic programming texts; gtk is
making me soft!)

Is there a reason why a 32-bit integer is used, as opposed to an rgb
triplet (+alpha) (although cairo itself uses doubles)?



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