fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines (2 loc) • 1.29 kB
JavaScript
import{defineProperty as s}from"../../_virtual/_rollupPluginBabelHelpers.min.mjs";import{Color as t}from"../color/Color.min.mjs";class o{constructor(t){s(this,"color","rgb(0, 0, 0)"),s(this,"width",1),s(this,"shadow",null),s(this,"strokeLineCap","round"),s(this,"strokeLineJoin","round"),s(this,"strokeMiterLimit",10),s(this,"strokeDashArray",null),s(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(s){s.strokeStyle=this.color,s.lineWidth=this.width,s.lineCap=this.strokeLineCap,s.miterLimit=this.strokeMiterLimit,s.lineJoin=this.strokeLineJoin,s.setLineDash(this.strokeDashArray||[])}_saveAndTransform(s){const t=this.canvas.viewportTransform;s.save(),s.transform(t[0],t[1],t[2],t[3],t[4],t[5])}needsFullRender(){return new t(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const s=this.canvas,t=this.shadow,o=s.contextTop,i=s.getZoom()*s.getRetinaScaling();o.shadowColor=t.color,o.shadowBlur=t.blur*i,o.shadowOffsetX=t.offsetX*i,o.shadowOffsetY=t.offsetY*i}_resetShadow(){const s=this.canvas.contextTop;s.shadowColor="",s.shadowBlur=s.shadowOffsetX=s.shadowOffsetY=0}_isOutSideCanvas(s){return s.x<0||s.x>this.canvas.getWidth()||s.y<0||s.y>this.canvas.getHeight()}}export{o as BaseBrush};
//# sourceMappingURL=BaseBrush.min.mjs.map