@visactor/vrender-core
Version:
## Description
29 lines (23 loc) • 1.23 kB
JavaScript
import { sqrt } from "@visactor/vutils";
import { BaseSymbol } from "./base";
const sqrt3 = sqrt(3);
export function arrow(ctx, r, transX, transY) {
const triangleH = r, trangleBottomSide = triangleH / sqrt3, rectW = trangleBottomSide / 5, rectH = r;
return ctx.moveTo(0 + transX, -triangleH + transY), ctx.lineTo(trangleBottomSide / 2 + transX, transY),
ctx.lineTo(rectW / 2 + transX, transY), ctx.lineTo(rectW / 2 + transX, rectH + transY),
ctx.lineTo(-rectW / 2 + transX, rectH + transY), ctx.lineTo(-rectW / 2 + transX, transY),
ctx.lineTo(-trangleBottomSide / 2 + transX, transY), ctx.closePath(), !0;
}
export class ArrowSymbol extends BaseSymbol {
constructor() {
super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
}
draw(ctx, size, transX, transY) {
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
}
drawOffset(ctx, size, transX, transY, offset) {
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
}
}
export default new ArrowSymbol;
//# sourceMappingURL=arrow.js.map