[Sc-devel] propose: Color-addons
Fredrik Olofsson
f at fredrikolofsson.com
Tue Jul 24 18:21:41 PDT 2007
i don't think the old behaviour is wrong. it already does clipping
and the correct math. just that arguments are flipped and that
affects sub and div.
a= Color(1, 0.9, 0.7, 0.2)
b= Color(0.6, 0.5, 0.1, 0.6)
a.subtract(b) //Color(0.0, 0.0, 0.0, 0.4) here think b.subtract(a)
with clipping
b.subtract(a) //Color(0.4, 0.4, 0.6, 0.0) here think a.subtract(b)
with clipping
a.divide(b) //Color(0.5999400059994, 0.55549383401844,
0.14283673760891, 1.0)
b.divide(a) //Color(1.0, 1.0, 1.0, 0.33327778703549)
a.add(b) //Color(1.0, 1.0, 0.8, 0.8) no change
a.multiply(b) //Color(0.6, 0.45, 0.07, 0.12)
this backwards thing i think should be fixed, but i wouldn't want
colour objects created with negatives, >1 and inf.
but this is only my preference and i really haven't done much work
with colours recently. let's see what others have to say.
_f
Am 24.07.2007 um 15:24 schrieb Till Bovermann:
> Hey,
>
> I did test it a lot (I work with it). I never said that it does the
> same as before, since I think that e.g. this:
>
>> // old behavior
>> a= Color(1, 0.5, 0)
>> b= Color(1, 0.9, 0.5)
>> a.subtract(b) //Color(0.0, 0.4, 0.5, 0.0)
>
> is simply wrong. So I fixed it by using the standard methods for +
> - * / and the syntax of SequencableCollections-+ and wrapped it
> into Colors.
> I think we should discuss on what to do if substraction returns an
> illegal color (with negative values in one part for example...),
> e.g. we may just clip the values into [0, 1].
> I decided to just leave this upto the user.
> We may also leave the existing methods ("multiply", "add", ...) as
> they are and only add + - * / with new behavior...
>
> kind regards
> Till
>
>
> On 24.07.2007, at 14:55, Fredrik Olofsson wrote:
>
>> sorry till but how much did you really test this?
>>
>> seems pretty broken to me and i object to commit.
>>
>>
>> //before:
>> a= Color(1, 0.5, 0)
>> b= Color(1, 0.9, 0.5)
>>
>> a.multiply(b) //Color(1.0, 0.45, 0.0, 1.0)
>> a.subtract(b) //Color(0.0, 0.4, 0.5, 0.0)
>> b.subtract(a) //Color(0.0, 0.0, 0.0, 0.0)
>> a.add(b) //Color(1.0, 1.0, 0.5, 1.0)
>> b.divide(a) //Color(0.999900009999, 0.55549383401844, 0.0,
>> 0.999900009999)
>> a.divide(b) //Color(0.999900009999, 1.0, 1.0, 0.999900009999)
>>
>>
>> //after installing your extensions:
>> a.multiply(b) //Color(1.0, 0.45, 0.0, 1.0)
>> a.subtract(b) //Color(0.0, -0.4, -0.5, 0.0)
>> b.subtract(a) //Color(0.0, 0.4, 0.5, 0.0)
>> a.add(b) //Color(2.0, 1.4, 0.5, 2.0)
>> b.divide(a) //Color(1.0, 1.8, inf, 1.0)
>> a.divide(b) //Color(1.0, 0.55555555555556, 0.0, 1.0)
>>
>> a*b //Color(1, 0.45, 0.0, 1.0)
>> a-b //Color(0, -0.4, -0.5, 0.0)
>> b-a //Color(0, 0.4, 0.5, 0.0)
>> a+b //Color(2, 1.4, 0.5, 2.0)
>> b/a //Color(1.0, 1.8, inf, 1.0)
>> a/b //Color(1.0, 0.55555555555556, 0.0, 1.0)
>>
>>
>>
>>
>>
>> Am 24.07.2007 um 11:58 schrieb Till Bovermann:
>>
>>> Hello,
>>>
>>> I put together my implementations on binaryOps on Color here:
>>> http://swiki.hfbk-hamburg.de/MusicTechnology/861
>>>
>>> It works quite well for me for about half a year now and I
>>> thought we could put it into the distro... any objections/
>>> comments are welcome
>>>
>>> regards
>>> Till
#|
fredrikolofsson.com klippav.org musicalfieldsforever.com
|#
More information about the Sc-devel
mailing list