@visactor/vrender-kits
Version:
## Description
46 lines (39 loc) • 2.52 kB
JavaScript
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
return c > 3 && r && Object.defineProperty(target, key, r), r;
}, __metadata = this && this.__metadata || function(k, v) {
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
}, __param = this && this.__param || function(paramIndex, decorator) {
return function(target, key) {
decorator(target, key, paramIndex);
};
};
import { CIRCLE_NUMBER_TYPE, DefaultCanvasCircleRender, inject, injectable } from "@visactor/vrender-core";
import rough from "roughjs";
import { RoughBaseRender } from "./base-render";
let RoughCanvasCircleRender = class extends RoughBaseRender {
constructor(canvasRenderer) {
super(), this.canvasRenderer = canvasRenderer, this.style = "rough", this.type = "circle",
this.numberType = CIRCLE_NUMBER_TYPE;
}
draw(circle, renderService, drawContext, params) {
const {context: context} = drawContext;
if (!context) return;
const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas, {}), circleAttribute = circle.getGraphicTheme();
let {x: x = circleAttribute.x, y: y = circleAttribute.y} = circle.attribute;
circle.transMatrix.onlyTranslate() ? context.onlyTranslate() || context.clearMatrix() : (x = 0,
y = 0, context.transformFromMatrix(circle.transMatrix, !0));
const {radius: radius = circleAttribute.radius, fill: fill = circleAttribute.fill, stroke: stroke = circleAttribute.stroke, lineWidth: lineWidth = circleAttribute.lineWidth} = circle.attribute;
rc.circle(x, y, radius, {
fill: fill || void 0,
stroke: stroke || void 0,
strokeWidth: lineWidth,
fillStyle: "zigzag",
roughness: .5
});
}
};
RoughCanvasCircleRender = __decorate([ injectable(), __param(0, inject(DefaultCanvasCircleRender)), __metadata("design:paramtypes", [ Object ]) ], RoughCanvasCircleRender);
export { RoughCanvasCircleRender };
//# sourceMappingURL=rough-circle.js.map