[Thuban-list] [Patch] Improved hsv ramps patch
bh at intevation.de
Mon Feb 23 21:20:29 CET 2004
"Daniel Calvelo Aros" <dcalvelo at minag.gob.pe> writes:
> Hi all.
> Following comments from BH and the new style guide, here is an improved
> (commented, styled, simplified) version of the HSV ramps patch.
Thanks. Much better now.
> Please give it a try and advise. To be a proper patch, it needs: tests,
> Changelog entry.
I think we can check this in once we have tests. I would especially
like to see tests for interpolate_hsv because it has quite a few special
Another thing that we might want to fix, but this can be done after the
hsv code has been checked in, is the way Transparent is interpolated
with non-transparent color.
As it's currently implemented in CVS (and inherited from the that in the
interpolate_rgb and interpolate_hsv functions in the patch) is wrong,
imo. For example. interpolate_rgb(Color(1, 1, 1), Transparent, 0)
yields black and not as one would expect, white. However, I'm not even
sure those functions should even allow interpolation of Transparent with
non-transparent colors. If Thuban could handle translucent shapes that
might be useful but currently it doesn't so that kind of interpolation
cannot really be done in a sensible way.
At the moment, I'd say that the interpolation functions should simply
assume that the color parameters are normal RGB colors and raise
exceptions when that assumption doesn't hold. This could either be done
implicitly when trying to access the red, green and blue attributes or
more explicitly by checking whether either of the color parameters is
Transparent and raise e.g. TypeError. Handling of Transparent for class
generation would then have to be done by the CustomRamp class.
Intevation GmbH http://intevation.de/
More information about the Thuban-list