Skip to content

Commit 7464e2b

Browse files
committed
fixed parsing colors from strings
for both cases, just the CSV numbers and the rgba() notation
1 parent 79167db commit 7464e2b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

morphic.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@
13061306

13071307
/*jshint esversion: 11, bitwise: false*/
13081308

1309-
var morphicVersion = '2024-February-12';
1309+
var morphicVersion = '2024-March-01';
13101310
var modules = {}; // keep track of additional loaded modules
13111311
var useBlurredShadows = true;
13121312

@@ -2130,7 +2130,9 @@ Color.prototype.toRGBstring = function () {
21302130

21312131
Color.fromString = function (aString) {
21322132
// I parse rgb/rgba strings into a Color object
2133-
var channels = aString.split(/[\(),]/).slice(0,4);
2133+
var components = aString.split(/[\(),]/),
2134+
channels = aString.startsWith('rgba') ?
2135+
components.slice(1, 5) : components.slice(0, 4);
21342136
return new Color(+channels[0], +channels[1], +channels[2], +channels[3]);
21352137
};
21362138

0 commit comments

Comments
 (0)