MCPcopy Create free account
hub / github.com/CreateJS/TweenJS / parseRgbOrHsl

Function parseRgbOrHsl

src/tweenjs/plugins/ColorPlugin.js:181–194  ·  view source on GitHub ↗
(value, mode)

Source from the content-addressed store, hash-verified

179 }
180
181 function parseRgbOrHsl(value, mode) {
182 var o=[0,0,0,1], result = s.RGB_HSL_RE.exec(value);
183 if (!result) { return o;}
184
185 var rgb = value[0] === "r", m = (rgb && value.lastIndexOf("%") !== -1) ? 255/100 : 1;
186 o[0] = parseInt(result[1]) * m;
187 o[1] = parseInt(result[2]) * m;
188 o[2] = parseInt(result[3]) * m;
189 o[3] = result[4] === undefined ? 1 : parseFloat(result[4]);
190
191 if (!rgb && mode === "rgb") { hslToRgb(o); }
192 else if (rgb && mode !== "rgb") { rgbToHsl(o); }
193 return o;
194 };
195
196 function parseHex(value, mode) {
197 var o=[0,0,0,1], result = s.HEX_RE.exec(value);

Callers 1

getColorObjFunction · 0.85

Calls 2

hslToRgbFunction · 0.85
rgbToHslFunction · 0.85

Tested by

no test coverage detected