Skip to content

Commit

Permalink
* fix wrong handling of RGB and RGBA arrays when constructing chroma …
Browse files Browse the repository at this point in the history
…color objects.

Signed-off-by: regorxxx <[email protected]>
  • Loading branch information
regorxxx committed Feb 20, 2024
1 parent 295255a commit 08f5eb6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Color {
args[0].constructor === this.constructor) {
// the argument is already a Color instance
return args[0];
} else if (type(args[0]) === 'array' && args.length === 1) {
args = [...args[0]];
}

// last argument could be the mode
Expand All @@ -33,7 +35,7 @@ class Color {
const rgb = _input.format[mode].apply(null, autodetect ? args : args.slice(0,-1));
me._rgb = clip_rgb(rgb);
} else {
throw new Error('unknown format: '+args);
throw new Error('unknown format: ' + args);
}

// add alpha channel
Expand Down

0 comments on commit 08f5eb6

Please sign in to comment.