Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gka committed Sep 8, 2024
1 parent bdc836c commit a63b177
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 68 deletions.
36 changes: 21 additions & 15 deletions dist/chroma-light.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
};

// this gets updated automatically
var version = '3.0.0';
var version = '3.1.0';

var chroma = function () {
var args = [], len = arguments.length;
Expand Down Expand Up @@ -522,7 +522,7 @@
var mode = last(args) || 'lab';
lcha[0] = rnd2(lcha[0]) + '%';
lcha[1] = rnd2(lcha[1]);
lcha[2] = rnd2(lcha[2]) + 'deg'; // add deg unit to hue
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (mode === 'lcha' || (lcha.length > 3 && lcha[3] < 1)) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
Expand Down Expand Up @@ -644,7 +644,7 @@
// L in range [0,1]. For use in CSS, multiply by 100 and add a percent
}

var oklab2css$1 = function () {
var oklab2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

Expand Down Expand Up @@ -680,20 +680,20 @@
return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : []));
};

var oklab2css = function () {
var oklch2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

var laba = unpack(args, 'lab');
laba[0] = rnd2(laba[0] * 100) + '%';
laba[1] = rnd3(laba[1]);
laba[2] = rnd2(laba[2]) + 'deg';
if (laba.length > 3 && laba[3] < 1) {
laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1);
var lcha = unpack(args, 'lch');
lcha[0] = rnd2(lcha[0] * 100) + '%';
lcha[1] = rnd3(lcha[1]);
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (lcha.length > 3 && lcha[3] < 1) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
laba.length = 3;
lcha.length = 3;
}
return ("oklch(" + (laba.join(' ')) + ")");
return ("oklch(" + (lcha.join(' ')) + ")");
};

var round$3 = Math.round;
Expand Down Expand Up @@ -732,10 +732,10 @@
return cssColor$1;
}
if (mode.substr(0, 5) === 'oklab') {
return oklab2css$1(rgb2oklab(rgba));
return oklab2css(rgb2oklab(rgba));
}
if (mode.substr(0, 5) === 'oklch') {
return oklab2css(rgb2oklch(rgba));
return oklch2css(rgb2oklch(rgba));
}
rgba[0] = round$3(rgba[0]);
rgba[1] = round$3(rgba[1]);
Expand Down Expand Up @@ -1104,6 +1104,11 @@

var css2rgb = function (css) {
css = css.toLowerCase().trim();

if (css === 'transparent') {
return [0, 0, 0, 0];
}

var m;

if (input.format.named) {
Expand Down Expand Up @@ -1227,7 +1232,8 @@
RE_RGB_LEGACY.test(s) ||
RE_RGBA_LEGACY.test(s) ||
RE_HSL_LEGACY.test(s) ||
RE_HSLA_LEGACY.test(s)
RE_HSLA_LEGACY.test(s) ||
s === 'transparent'
);
};

Expand Down
2 changes: 1 addition & 1 deletion dist/chroma-light.min.cjs

Large diffs are not rendered by default.

36 changes: 21 additions & 15 deletions dist/chroma.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
};

// this gets updated automatically
var version = '3.0.0';
var version = '3.1.0';

var chroma = function () {
var args = [], len = arguments.length;
Expand Down Expand Up @@ -593,7 +593,7 @@
var mode = last(args) || 'lab';
lcha[0] = rnd2(lcha[0]) + '%';
lcha[1] = rnd2(lcha[1]);
lcha[2] = rnd2(lcha[2]) + 'deg'; // add deg unit to hue
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (mode === 'lcha' || (lcha.length > 3 && lcha[3] < 1)) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
Expand Down Expand Up @@ -715,7 +715,7 @@
// L in range [0,1]. For use in CSS, multiply by 100 and add a percent
}

var oklab2css$1 = function () {
var oklab2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

Expand Down Expand Up @@ -751,20 +751,20 @@
return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : []));
};

var oklab2css = function () {
var oklch2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

var laba = unpack(args, 'lab');
laba[0] = rnd2(laba[0] * 100) + '%';
laba[1] = rnd3(laba[1]);
laba[2] = rnd2(laba[2]) + 'deg';
if (laba.length > 3 && laba[3] < 1) {
laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1);
var lcha = unpack(args, 'lch');
lcha[0] = rnd2(lcha[0] * 100) + '%';
lcha[1] = rnd3(lcha[1]);
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (lcha.length > 3 && lcha[3] < 1) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
laba.length = 3;
lcha.length = 3;
}
return ("oklch(" + (laba.join(' ')) + ")");
return ("oklch(" + (lcha.join(' ')) + ")");
};

var round$4 = Math.round;
Expand Down Expand Up @@ -803,10 +803,10 @@
return cssColor$1;
}
if (mode.substr(0, 5) === 'oklab') {
return oklab2css$1(rgb2oklab(rgba));
return oklab2css(rgb2oklab(rgba));
}
if (mode.substr(0, 5) === 'oklch') {
return oklab2css(rgb2oklch(rgba));
return oklch2css(rgb2oklch(rgba));
}
rgba[0] = round$4(rgba[0]);
rgba[1] = round$4(rgba[1]);
Expand Down Expand Up @@ -1175,6 +1175,11 @@

var css2rgb = function (css) {
css = css.toLowerCase().trim();

if (css === 'transparent') {
return [0, 0, 0, 0];
}

var m;

if (input.format.named) {
Expand Down Expand Up @@ -1298,7 +1303,8 @@
RE_RGB_LEGACY.test(s) ||
RE_RGBA_LEGACY.test(s) ||
RE_HSL_LEGACY.test(s) ||
RE_HSLA_LEGACY.test(s)
RE_HSLA_LEGACY.test(s) ||
s === 'transparent'
);
};

Expand Down
4 changes: 2 additions & 2 deletions dist/chroma.min.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,13 @@ <h3 id="cubehelix-scale">cubehelix.scale</h3>
.colors(5);
</code></pre>
<h2 id="changelog">Changelog</h2>
<h3 id="3-1-0-pre-release-">3.1.0 (pre-release)</h3>
<h3 id="3-1-0">3.1.0</h3>
<ul>
<li>feat: parse <code>&#39;transparent&#39;</code> as black with 0% opacity - resolves <a href="https://github.com/gka/chroma.js/issues/280">#280</a></li>
<li>make it easier to access colorbrewer palette names - resolves <a href="https://github.com/gka/chroma.js/issues/314">#314</a></li>
<li>docs: explain differences to official colorbrewer scales - resolves <a href="https://github.com/gka/chroma.js/issues/316">#316</a></li>
<li>fix: correct parsing of modern css colors with percentage alpha - resolves <a href="https://github.com/gka/chroma.js/issues/297">#297</a></li>
<li>fix: css output for hue-less colors in lch() and oklch() - resolves <a href="https://github.com/gka/chroma.js/issues/357">#357</a></li>
</ul>
<h3 id="3-0-0">3.0.0</h3>
<ul>
Expand Down
36 changes: 21 additions & 15 deletions docs/libs/chroma-light.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
};

// this gets updated automatically
var version = '3.0.0';
var version = '3.1.0';

var chroma = function () {
var args = [], len = arguments.length;
Expand Down Expand Up @@ -522,7 +522,7 @@
var mode = last(args) || 'lab';
lcha[0] = rnd2(lcha[0]) + '%';
lcha[1] = rnd2(lcha[1]);
lcha[2] = rnd2(lcha[2]) + 'deg'; // add deg unit to hue
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (mode === 'lcha' || (lcha.length > 3 && lcha[3] < 1)) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
Expand Down Expand Up @@ -644,7 +644,7 @@
// L in range [0,1]. For use in CSS, multiply by 100 and add a percent
}

var oklab2css$1 = function () {
var oklab2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

Expand Down Expand Up @@ -680,20 +680,20 @@
return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : []));
};

var oklab2css = function () {
var oklch2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

var laba = unpack(args, 'lab');
laba[0] = rnd2(laba[0] * 100) + '%';
laba[1] = rnd3(laba[1]);
laba[2] = rnd2(laba[2]) + 'deg';
if (laba.length > 3 && laba[3] < 1) {
laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1);
var lcha = unpack(args, 'lch');
lcha[0] = rnd2(lcha[0] * 100) + '%';
lcha[1] = rnd3(lcha[1]);
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (lcha.length > 3 && lcha[3] < 1) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
laba.length = 3;
lcha.length = 3;
}
return ("oklch(" + (laba.join(' ')) + ")");
return ("oklch(" + (lcha.join(' ')) + ")");
};

var round$3 = Math.round;
Expand Down Expand Up @@ -732,10 +732,10 @@
return cssColor$1;
}
if (mode.substr(0, 5) === 'oklab') {
return oklab2css$1(rgb2oklab(rgba));
return oklab2css(rgb2oklab(rgba));
}
if (mode.substr(0, 5) === 'oklch') {
return oklab2css(rgb2oklch(rgba));
return oklch2css(rgb2oklch(rgba));
}
rgba[0] = round$3(rgba[0]);
rgba[1] = round$3(rgba[1]);
Expand Down Expand Up @@ -1104,6 +1104,11 @@

var css2rgb = function (css) {
css = css.toLowerCase().trim();

if (css === 'transparent') {
return [0, 0, 0, 0];
}

var m;

if (input.format.named) {
Expand Down Expand Up @@ -1227,7 +1232,8 @@
RE_RGB_LEGACY.test(s) ||
RE_RGBA_LEGACY.test(s) ||
RE_HSL_LEGACY.test(s) ||
RE_HSLA_LEGACY.test(s)
RE_HSLA_LEGACY.test(s) ||
s === 'transparent'
);
};

Expand Down
2 changes: 1 addition & 1 deletion docs/libs/chroma-light.min.cjs

Large diffs are not rendered by default.

36 changes: 21 additions & 15 deletions docs/libs/chroma.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
};

// this gets updated automatically
var version = '3.0.0';
var version = '3.1.0';

var chroma = function () {
var args = [], len = arguments.length;
Expand Down Expand Up @@ -593,7 +593,7 @@
var mode = last(args) || 'lab';
lcha[0] = rnd2(lcha[0]) + '%';
lcha[1] = rnd2(lcha[1]);
lcha[2] = rnd2(lcha[2]) + 'deg'; // add deg unit to hue
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (mode === 'lcha' || (lcha.length > 3 && lcha[3] < 1)) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
Expand Down Expand Up @@ -715,7 +715,7 @@
// L in range [0,1]. For use in CSS, multiply by 100 and add a percent
}

var oklab2css$1 = function () {
var oklab2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

Expand Down Expand Up @@ -751,20 +751,20 @@
return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : []));
};

var oklab2css = function () {
var oklch2css = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

var laba = unpack(args, 'lab');
laba[0] = rnd2(laba[0] * 100) + '%';
laba[1] = rnd3(laba[1]);
laba[2] = rnd2(laba[2]) + 'deg';
if (laba.length > 3 && laba[3] < 1) {
laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1);
var lcha = unpack(args, 'lch');
lcha[0] = rnd2(lcha[0] * 100) + '%';
lcha[1] = rnd3(lcha[1]);
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
if (lcha.length > 3 && lcha[3] < 1) {
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
} else {
laba.length = 3;
lcha.length = 3;
}
return ("oklch(" + (laba.join(' ')) + ")");
return ("oklch(" + (lcha.join(' ')) + ")");
};

var round$4 = Math.round;
Expand Down Expand Up @@ -803,10 +803,10 @@
return cssColor$1;
}
if (mode.substr(0, 5) === 'oklab') {
return oklab2css$1(rgb2oklab(rgba));
return oklab2css(rgb2oklab(rgba));
}
if (mode.substr(0, 5) === 'oklch') {
return oklab2css(rgb2oklch(rgba));
return oklch2css(rgb2oklch(rgba));
}
rgba[0] = round$4(rgba[0]);
rgba[1] = round$4(rgba[1]);
Expand Down Expand Up @@ -1175,6 +1175,11 @@

var css2rgb = function (css) {
css = css.toLowerCase().trim();

if (css === 'transparent') {
return [0, 0, 0, 0];
}

var m;

if (input.format.named) {
Expand Down Expand Up @@ -1298,7 +1303,8 @@
RE_RGB_LEGACY.test(s) ||
RE_RGBA_LEGACY.test(s) ||
RE_HSL_LEGACY.test(s) ||
RE_HSLA_LEGACY.test(s)
RE_HSLA_LEGACY.test(s) ||
s === 'transparent'
);
};

Expand Down
4 changes: 2 additions & 2 deletions docs/libs/chroma.min.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// this gets updated automatically
export const version = '3.0.0';
export const version = '3.1.0';

0 comments on commit a63b177

Please sign in to comment.