-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hex <=> Hsv mutual conversion not equal #6
Comments
noyobo
added a commit
to noyobo/color-picker
that referenced
this issue
Jun 21, 2015
由于色彩间存在误差 see [colr#6](stayradiated/colr#6)
There seems to be a mistake in the last test: it('from hex #80468f should to hsv [288, 51, 56]', function(done) {
...
assert.deepEqual(hsv, [289, 51, 56]);
...
}); After fixing that, the results I get when I run the test are:
I then checked in Photoshop, using the color picker:
I think this is just a rounding error due to not enough significant figures. If you need accurate results, try using:
Conversions
Extended Tests'use strict';
var assert = require('assert');
var Colr = require('./index');
var colr = new Colr();
describe('colr hsv', function() {
// rgb[128, 70, 143] = #80468f
// rgb[129, 70, 143] = #81468f
it('from rgb [128, 70, 143] to hsv [288, 51, 56]', function(done) {
var c = colr.fromRgbArray([128, 70, 143]);
assert.deepEqual(c.toRawHsvArray(), [
287.6712328767123,
51.048951048951054,
56.07843137254902,
]);
assert.deepEqual(c.toHsvArray(), [
288,
51,
56,
]);
done();
});
it('from rgb [129, 70, 143] to hsv [288, 51, 56]', function(done) {
var c = colr.fromRgbArray([129, 70, 143]);
assert.deepEqual(c.toRawHsvArray(), [
288.4931506849315,
51.048951048951054,
56.07843137254902,
]);
assert.deepEqual(c.toHsvArray(), [
288,
51,
56,
]);
done();
});
it('from hsv [288, 51, 56] to rgb [128, 70, 143]', function(done) {
var c = colr.fromHsvArray([288, 51, 56]);
assert.deepEqual(c.toRawRgbArray(), [
128.2344,
69.97200000000001,
142.8,
]);
assert.deepEqual(c.toRgbArray(), [
128,
70,
143,
]);
done();
});
it('from hsv [289, 51, 56] to rgb [129, 70, 143]', function(done) {
var c = colr.fromHsvArray([289, 51, 56]);
assert.deepEqual(c.toRawRgbArray(), [
129.44819999999999,
69.97200000000001,
142.8,
]);
assert.deepEqual(c.toRgbArray(), [
129,
70,
143,
]);
done();
});
}); Test Results
|
Sorry for mistake in the last test 😧 Thank you for your answer, This seems a reasonable a rounding value. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your the colr 😃
I found some colors can not be equal when converted;
test.js
result:
The text was updated successfully, but these errors were encountered: