fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines (2 loc) • 2.22 kB
JavaScript
import{defineProperty as t}from"../../_virtual/_rollupPluginBabelHelpers.min.mjs";import{SHARED_ATTRIBUTES as s}from"../parser/attributes.min.mjs";import{parseAttributes as e}from"../parser/parseAttributes.min.mjs";import{cos as r}from"../util/misc/cos.min.mjs";import{degreesToRadians as i}from"../util/misc/radiansDegreesConversion.min.mjs";import{sin as n}from"../util/misc/sin.min.mjs";import{classRegistry as o}from"../ClassRegistry.min.mjs";import{FabricObject as a}from"./Object/FabricObject.min.mjs";import{SCALE_X as m,SCALE_Y as u}from"../constants.min.mjs";import{escapeXml as c}from"../util/lang_string.min.mjs";import{cacheProperties as l}from"./Object/defaultValues.min.mjs";const p=["radius","startAngle","endAngle","counterClockwise"],d={radius:0,startAngle:0,endAngle:360,counterClockwise:!1};class h extends a{static getDefaults(){return{...super.getDefaults(),...h.ownDefaults}}constructor(t){super(),Object.assign(this,h.ownDefaults),this.setOptions(t)}_set(t,s){return super._set(t,s),"radius"===t&&this.setRadius(s),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,i(this.startAngle),i(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(m)}getRadiusY(){return this.get("radius")*this.get(u)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...p,...t])}_toSVG(){const{radius:t,startAngle:s,endAngle:e}=this,o=(e-s)%360;if(0===o)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',`${c(t)}`,'" />\n'];{const a=i(s),m=i(e),u=r(a)*t,c=n(a)*t,l=r(m)*t,p=n(m)*t;return[`<path d="M ${u} ${c} A ${t} ${t} 0 ${o>180?1:0} ${this.counterClockwise?0:1} ${l} ${p}" `,"COMMON_PARTS"," />\n"]}}static async fromElement(t,s,r){const{left:i=0,top:n=0,radius:o=0,...a}=e(t,this.ATTRIBUTE_NAMES,r);return new this({...a,radius:o,left:i-o,top:n-o})}static fromObject(t){return super._fromObject(t)}}t(h,"type","Circle"),t(h,"cacheProperties",[...l,...p]),t(h,"ownDefaults",d),t(h,"ATTRIBUTE_NAMES",["cx","cy","r",...s]),o.setClass(h),o.setSVGClass(h);export{h as Circle,d as circleDefaultValues};
//# sourceMappingURL=Circle.min.mjs.map