Skip to content

Commit

Permalink
fix incorrect hue component rotation in HCG (fixes #73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Aug 19, 2019
1 parent 7607099 commit 3359002
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conversions.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ convert.rgb.hcg = function (rgb) {
if (max === g) {
hue = 2 + (b - r) / chroma;
} else {
hue = 4 + (r - g) / chroma + 4;
hue = 4 + (r - g) / chroma;
}

hue /= 6;
Expand Down
7 changes: 6 additions & 1 deletion test/basic.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const assert = require('assert');
const chalk = require('chalk');
const convert = require('..');
const keywords = require('color-name');

const conversions = require('../conversions');

const convert = require('..');

const models = Object.keys(conversions);
for (let len = models.length, i = 0; i < len; i++) {
const toModel = models[i];
Expand Down Expand Up @@ -122,6 +124,9 @@ assert.deepStrictEqual(convert.hcg.rgb([96, 39, 64]), [139, 199, 100]);
assert.deepStrictEqual(convert.hcg.hsv([96, 39, 64]), [96, 50, 78]);
assert.deepStrictEqual(convert.hcg.hsl([96, 39, 64]), [96, 47, 59]);

// https://github.com/Qix-/color-convert/issues/73
assert.deepStrictEqual(convert.rgb.hcg.raw([250, 0, 255]), [298.8235294117647, 100, 0]);

// Non-array arguments
assert.deepStrictEqual(convert.hsl.rgb(96, 48, 59), [140, 201, 100]);

Expand Down

0 comments on commit 3359002

Please sign in to comment.