UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

2 lines 821 B
import{Color as e}from"../../color/Color.min.mjs";import{ifNaN as t}from"../../util/internals/ifNaN.min.mjs";import{parsePercent as n}from"../../parser/percent.min.mjs";const r=/\s*;\s*/,i=/\s*:\s*/;function a(a,o){let s,c,l=a.getAttribute(`style`);if(l){let e=l.split(r);e[e.length-1]===``&&e.pop();for(let t=e.length;t--;){let[n,r]=e[t].split(i).map(e=>e.trim());n===`stop-color`?s=r:n===`stop-opacity`&&(c=r)}}s=s||a.getAttribute(`stop-color`)||`rgb(0,0,0)`,c=t(parseFloat(c||a.getAttribute(`stop-opacity`)||``),1);let u=new e(s);return u.setAlpha(u.getAlpha()*c*o),{offset:n(a.getAttribute(`offset`),0),color:u.toRgba()}}function o(e,t){let r=[],i=e.getElementsByTagName(`stop`),o=n(t,1);for(let e=i.length;e--;)r.push(a(i[e],o));return r}export{o as parseColorStops}; //# sourceMappingURL=parseColorStops.min.mjs.map