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