Hi,

On Mon, Oct 29, 2007 at 08:25:14AM -0500, Jonathon Jongsma wrote:

> If I was to wrap this API directly into an object-oriented style, I
> would end up with something like:
> 
> void Color::darken(Color& dest) const; [A]
> 
> or alternately
> 
> Color Color::darken() const; [B]
> 
> I looked at what other bindings did, and it seems that the vala and
> C# bindings both chose version [A], the python and ruby bindings
> both chose [B], and I couldn't figure out what the perl bindings did
> :)
>
> So I had an idea to just modify the src object directly and omit the
> dest parameter, e.g.:
> 
> void Color::darken(); [C]

It's probably worth mentioning that the Ruby bindings actually have
two methods for darken:

col2 = col.darken

or

col.darken!

The first form is like [B] and the second form is like [C]. This is a
fairly common thing to do in Ruby so I assume most Ruby programmers
would expect to have both.

However, in the darken! method, I actually make a temporary copy of
the color to use as the destination to clutter_color_darken because I
wasn't sure whether the API was guaranteed to allow src to equal
dest. Maybe this would be worth clarifying in the documentation?

On an sort of related note, I think there is a slight issue with
clutter_color_darken that I worked around in the Ruby bindings which
is that the alpha value of the destination is not copied over from the
source and is left uninitialised. So you have to make sure you
initialise the destination color if src != dest.

Regards,
- Neil
-- 
To unsubscribe send a mail to [EMAIL PROTECTED]

Reply via email to