Skip to content

Commit

Permalink
fixed parsing colors from strings
Browse files Browse the repository at this point in the history
for both cases, just the CSV numbers and the rgba() notation
  • Loading branch information
jmoenig committed Mar 1, 2024
1 parent 79167db commit 7464e2b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions morphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@

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

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

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

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

Expand Down

0 comments on commit 7464e2b

Please sign in to comment.