UNPKG

fabric

Version:

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

2 lines 1.62 kB
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,twoMathPi as r}from"../constants.min.mjs";import{classRegistry as i}from"../ClassRegistry.min.mjs";import{escapeXml as a}from"../util/lang_string.min.mjs";import{cacheProperties as o}from"./Object/defaultValues.min.mjs";import{FabricObject as s}from"./Object/FabricObject.min.mjs";import{SHARED_ATTRIBUTES as c}from"../parser/attributes.min.mjs";import{parseAttributes as l}from"../parser/parseAttributes.min.mjs";const u=[`rx`,`ry`];var d=class e extends s{static getDefaults(){return{...super.getDefaults(),...e.ownDefaults}}constructor(t){super(),Object.assign(this,e.ownDefaults),this.setOptions(t)}_set(e,t){switch(super._set(e,t),e){case`rx`:this.rx=t,this.set(`width`,2*t);break;case`ry`:this.ry=t,this.set(`height`,2*t)}return this}getRx(){return this.get(`rx`)*this.get(t)}getRy(){return this.get(`ry`)*this.get(n)}toObject(e=[]){return super.toObject([...u,...e])}_toSVG(){return[`<ellipse `,`COMMON_PARTS`,`cx="0" cy="0" rx="${a(this.rx)}" ry="${a(this.ry)}" />\n`]}_render(e){e.beginPath(),e.save(),e.transform(1,0,0,this.ry/this.rx,0,0),e.arc(0,0,this.rx,0,r,!1),e.restore(),this._renderPaintInOrder(e)}static async fromElement(e,t,n){let r=l(e,this.ATTRIBUTE_NAMES,n);return r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,new this(r)}};e(d,`type`,`Ellipse`),e(d,`cacheProperties`,[...o,...u]),e(d,`ownDefaults`,{rx:0,ry:0}),e(d,`ATTRIBUTE_NAMES`,[...c,`cx`,`cy`,`rx`,`ry`]),i.setClass(d),i.setSVGClass(d);export{d as Ellipse}; //# sourceMappingURL=Ellipse.min.mjs.map