Skip to content

Commit

Permalink
negative value tests
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed Apr 25, 2024
1 parent 7e14167 commit adff13d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/commons/color/color.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Colorjs, ArrayFrom } from '../../core/imports';

const hexRegex = /^#[0-9a-f]{3,8}$/i;
const hslRegex = /hsl\(\s*([\d.]+)(rad|turn)/;
const hslRegex = /hsl\(\s*([-\d.]+)(rad|turn)/;

/**
* @class Color
Expand Down
18 changes: 18 additions & 0 deletions test/commons/color/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ describe('color.Color', () => {
assert.equal(c.alpha, 1);
});

it('supports negative rad on hue', () => {
const c = new Color();
c.parseColorFnString('hsl(-3.49rad, 40%, 50%)');
assert.equal(c.red, 77);
assert.equal(c.green, 179);
assert.equal(c.blue, 145);
assert.equal(c.alpha, 1);
});

it('supports turn on hue', () => {
const c = new Color();
c.parseColorFnString('hsl(0.444turn, 40%, 50%)');
Expand All @@ -174,6 +183,15 @@ describe('color.Color', () => {
assert.equal(c.blue, 144);
assert.equal(c.alpha, 1);
});

it('supports negative turn on hue', () => {
const c = new Color();
c.parseColorFnString('hsl(-0.556turn, 40%, 50%)');
assert.equal(c.red, 77);
assert.equal(c.green, 179);
assert.equal(c.blue, 144);
assert.equal(c.alpha, 1);
});
});

describe('with hwb()', () => {
Expand Down

0 comments on commit adff13d

Please sign in to comment.