fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines (2 loc) • 927 B
JavaScript
import{isPercent as t}from"../../parser/percent.min.mjs";import{parseGradientUnits as r,parseType as n}from"./misc.min.mjs";function e(t,r){return t.getAttribute(r)}function i(t){return{x1:e(t,"x1")||0,y1:e(t,"y1")||0,x2:e(t,"x2")||"100%",y2:e(t,"y2")||0}}function c(t){return{x1:e(t,"fx")||e(t,"cx")||"50%",y1:e(t,"fy")||e(t,"cy")||"50%",r1:0,x2:e(t,"cx")||"50%",y2:e(t,"cy")||"50%",r2:e(t,"r")||"50%"}}function f(e,f){return function(r,n){let e,{width:i,height:c,gradientUnits:f}=n;return Object.entries(r).reduce((r,n)=>{let[y,o]=n;if("Infinity"===o)e=1;else if("-Infinity"===o)e=0;else{const r="string"==typeof o;e=r?parseFloat(o):o,r&&t(o)&&(e*=.01,"pixels"===f&&("x1"!==y&&"x2"!==y&&"r2"!==y||(e*=i),"y1"!==y&&"y2"!==y||(e*=c)))}return r[y]=e,r},{})}("linear"===n(e)?i(e):c(e),{...f,gradientUnits:r(e)})}export{f as parseCoords,i as parseLinearCoords,c as parseRadialCoords};
//# sourceMappingURL=parseCoords.min.mjs.map