Right. Thanks. Should've checked first.

Far from a 1:1 ratio in any case:
16,777,216 != 3,600,000

Also, the rounding actually does mess up more numbers than I had
recalled.
Very, very few round numbers actually convert to round numbers.

I updated the test page to mootools 1.2.4 and cleaned the functions a
bit.
Its now actually a teeny bit longer, but still more efficient than the
moo method.
http://siteroller.net/projects/color/test.htm

You can click on the result boxes and it will convert the numbers
back, which makes it very easy to see what happens on a round trip.
(ie. click on "Convert from RGB", and then click on the HSB result,
and - look below - it will convert it back to RGB.)

-- Request for help --
I started writing an article on how color spaces work, but didn't know
how to do the graphics for the article.
I also need a pretty simple graphic for the MooRTE color picker, but
don't know how to use Photoshop.
If anyone reading this has some talent and time, I sure would
appreciate some help.

On Jan 24, 2:56 am, Daniel Lohse <[email protected]> wrote:
> As far as I know, RGB does not have 360x360x360 number of color but 
> 256x256x256.
>
> E.g. from 0,0,0 to 255,255,255.
>
> Cheers, Daniel
>
> On 23.01.2010, at 22:12, SamGoody wrote:
>
> > To clarify.
>
> > 1.  Mootools's conversion is highly accurate.
> > When I said mine is moreso, that is simply because I round a little
> > later in the conversion - the difference between our results is never
> > more than one out of 16.5 million colors away - entirely negligible.
> > 2. RGB has 360 x 360 x 360 possible values. HSB has 360 x 100 x 100
> > values.  Not even close to 1:1.
> > 3. Post is based on memory - my work was done awhile ago, have to
> > crack it out and dust it off.
>
> > On Jan 23, 10:43 pm, SamGoody <[email protected]> wrote:
> >> Conversion from HSL to RGB is nowhere near 1:1, no matter what system
> >> you use.
>
> >> This has nothing to do with Mootools, it has to do with the way the
> >> colors are represented.
>
> >> For example; where the saturation and value are 0, the RGB output will
> >> be (0,0,0) no matter what hue. That means that all 360 values on the
> >> HSL system translate to only one color on the RGB system.
> >> If you go from HSL(200,0,0) -> RGB(0,0,0) -> HSL(0,0,0).... you will
> >> be back to the color you started with (or very very close) even though
> >> the numbers have changed drastically.
>
> >> Rounding just aggravates the issue, but the majority of numbers wont
> >> un-convert to the original, no matter how you do it.
>
> >> In graphics editors such as the GIMP, they figure that if they get
> >> back to the same color (or very close), you won't notice or care if
> >> the HSL numbers have changed.
>
> >> I wrote a class to convert to and from HSB/L/V/G that is shorter and
> >> more accurate than the one used in Mootools (besides the added support
> >> for HSB and HSG). Unfortunately, due to issues with the forge, its
> >> just sitting pretty.
>
> >> For playing around, you can use this 
> >> page:http://siteroller.net/projects/color/index.htm
> >> It's an unofficial test page for some of my work on colors.
> >> Top column is my class, bottom is Val's.
>
> >> On Jan 22, 2:20 pm, Barry van Oudtshoorn <[email protected]>
> >> wrote:
>
> >>> You'll probably find that this is because the HSL representation uses
> >>> different value ranges for its components than RGB. As far as I'm
> >>> aware, HSL can represent slightly fewer colours (in the context of RGB
> >>> media) than RGB. I think you will also find that most tools that allow
> >>> you to arbitrarily choose your representation will also exhibit this
> >>> lack of reflexivity; I think that Photoshop & the GIMP both also use
> >>> integers to represent HSL colours.
>
> >>> Clearly this isn't desired behaviour in your application, but I'm not
> >>> so sure if it really is s bug in MooTools. A limitation, perhaps. It
> >>> might be worthwhile producing a colour palette for your application,
> >>> and "snapping" all values to that palette. Perhaps only allow colours
> >>> in RGB whose values are multiples of 8 or something.
>
> >>> On Friday, January 22, 2010, woomla <[email protected]> wrote:
> >>>> Playing around with Color conversions, I've found out that conversion
> >>>> from RGB to HSB and back to RGB not yield in the same result. Should
> >>>> it not? Probably because the HSB values should be float. Anyhow, I've
> >>>> written this JSSpec test to easily see what's wrong.
>
> >>>>   describe('Color conversions vice-versa', {
>
> >>>>     'Conversion from RGB to HSB to RGB should not change': function ()
> >>>> {
> >>>>       var color = new Color([10, 11, 12], 'rgb');
> >>>>       value_of(new Color(color.hsb, 'hsb').rgb).should_be([10, 11,
> >>>> 12]);
> >>>>     },
>
> >>>>     'Conversion from HSB to RGB to HSB should not change': function ()
> >>>> {
> >>>>       var color = new Color([210, 17, 5], 'hsb');
> >>>>       value_of(new Color(color.rgb, 'rgb').hsb).should_be([210, 17,
> >>>> 5]);
> >>>>     },
>
> >>>>     'Conversion from RGB to HEX to RGB should not change': function ()
> >>>> {
> >>>>       var color = new Color([10, 11, 12], 'rgb');
> >>>>       value_of(new Color(color.hex).rgb).should_be([10, 11, 12]);
> >>>>     },
>
> >>>>     'Conversion from HEX to RGB to HEX should not change': function ()
> >>>> {
> >>>>       var color = new Color('0A0B0C');
> >>>>       value_of(new Color(color.rgb, 'rgb').hex).should_be('#0a0b0c');
> >>>>     },
>
> >>>>     'Conversion from HSB to HEX to HSB should not change': function ()
> >>>> {
> >>>>       var color = new Color([210, 17, 5], 'hsb');
> >>>>       value_of(new Color(color.hex).hsb).should_be([210, 17, 5]);
> >>>>     },
>
> >>>>     'Conversion from HEX to HSB to HEX should not change': function ()
> >>>> {
> >>>>       var color = new Color('0A0B0C');
> >>>>       value_of(new Color(color.hsb, 'hsb').hex).should_be('#0a0b0c');
> >>>>     }
>
> >>>>   });
>
> >>> --http://barryvan.com.au/
> >>> [email protected]
>
>

Reply via email to