color-js / apps

A collection of color tools
https://apps.colorjs.io
MIT License
16 stars 3 forks source link

XYZ color picker confuses 0..1 and 0..100% range #2

Open svgeesus opened 2 years ago

svgeesus commented 2 years ago

The XYZ-d65 color picker has 0..100 scale but gives black for [0,0,0] and an oog color close to white for [1,1,1]; it is not possible to pick any other colors due to the slider granularity.

image

svgeesus commented 2 years ago

@LeaVerou

LeaVerou commented 2 years ago

Maybe the max granularity shouldn't be 1 but .1? Take a look here and tell me how you think we should fix this generically. We can't just special case XYZ.

svgeesus commented 2 years ago

'''js let {name, range, refRange} = meta; name = name || id; range = range || refRange || [0, 100]; let [min, max] = range; let step = (max - min) / 100; if (step > 1) { step = 1; } '''

Since xyzd65 and xyzd50 don't declare a range, they end up with [0, 100] and (100-0)/100 should be 1 but is, I suspect, something like 1.00000000000001 and thus greater than 1. An epsilon in there would catch this and make it more robust. Although why forcing there to be only 100 steps is beneficial could also be examined.

svgeesus commented 2 years ago

Giving the relative XYZs a reference range of [0, 1] would also work.

svgeesus commented 1 year ago

(confirming this UI bug still exists)

LeaVerou commented 6 months ago

Is this issue still present on https://apps.colorjs.io/picker/ ? If so, please transfer to the apps repo.

svgeesus commented 6 months ago

Confirming that the issue still exists, because [0..1] and [0..100] are being confused

LeaVerou commented 6 months ago

What should the range be for each XYZ space?

svgeesus commented 5 days ago

As I said earlier:

Giving the relative XYZs a reference range of [0, 1] would also work.