UNPKG

fabric

Version:

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

3 lines (2 loc) 1.66 kB
import{defineProperty as t,objectSpread2 as r}from"../../_virtual/_rollupPluginBabelHelpers.min.mjs";import{SCALE_X as e,SCALE_Y as s,twoMathPi as i}from"../constants.min.mjs";import{SHARED_ATTRIBUTES as n}from"../parser/attributes.min.mjs";import{parseAttributes as o}from"../parser/parseAttributes.min.mjs";import{classRegistry as a}from"../ClassRegistry.min.mjs";import{FabricObject as c}from"./Object/FabricObject.min.mjs";import{cacheProperties as m}from"./Object/defaultValues.min.mjs";const h={rx:0,ry:0},l=["rx","ry"];class p extends c{static getDefaults(){return r(r({},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(e)}getRy(){return this.get("ry")*this.get(s)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...l,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(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,i,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,r,e){const s=o(t,this.ATTRIBUTE_NAMES,e);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}t(p,"type","Ellipse"),t(p,"cacheProperties",[...m,...l]),t(p,"ownDefaults",h),t(p,"ATTRIBUTE_NAMES",[...n,"cx","cy","rx","ry"]),a.setClass(p),a.setSVGClass(p);export{p as Ellipse,h as ellipseDefaultValues}; //# sourceMappingURL=Ellipse.min.mjs.map