UNPKG

fabric

Version:

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

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