fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines (2 loc) • 1.68 kB
JavaScript
import{defineProperty as t}from"../../_virtual/_rollupPluginBabelHelpers.min.mjs";import{SCALE_X as r,SCALE_Y as s,twoMathPi as e}from"../constants.min.mjs";import{SHARED_ATTRIBUTES as i}from"../parser/attributes.min.mjs";import{parseAttributes as n}from"../parser/parseAttributes.min.mjs";import{classRegistry as o}from"../ClassRegistry.min.mjs";import{FabricObject as m}from"./Object/FabricObject.min.mjs";import{escapeXml as a}from"../util/lang_string.min.mjs";import{cacheProperties as l}from"./Object/defaultValues.min.mjs";const c={rx:0,ry:0},h=["rx","ry"];class p extends m{static getDefaults(){return{...super.getDefaults(),...p.ownDefaults}}constructor(t){super(),Object.assign(this,p.ownDefaults),this.setOptions(t)}_set(t,r){switch(super._set(t,r),t){case"rx":this.rx=r,this.set("width",2*r);break;case"ry":this.ry=r,this.set("height",2*r)}return this}getRx(){return this.get("rx")*this.get(r)}getRy(){return this.get("ry")*this.get(s)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...h,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",`cx="0" cy="0" rx="${a(this.rx)}" ry="${a(this.ry)}" />\n`]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,e,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,r,s){const e=n(t,this.ATTRIBUTE_NAMES,s);return e.left=(e.left||0)-e.rx,e.top=(e.top||0)-e.ry,new this(e)}}t(p,"type","Ellipse"),t(p,"cacheProperties",[...l,...h]),t(p,"ownDefaults",c),t(p,"ATTRIBUTE_NAMES",[...i,"cx","cy","rx","ry"]),o.setClass(p),o.setSVGClass(p);export{p as Ellipse,c as ellipseDefaultValues};
//# sourceMappingURL=Ellipse.min.mjs.map