UNPKG

@visactor/vrender-core

Version:
27 lines (21 loc) 847 B
import { sqrt } from "@visactor/vutils"; import { BaseSymbol } from "./base"; const sqrt3 = sqrt(3); export function thinTriangle(ctx, r, x, y) { const h = r * sqrt3; return ctx.moveTo(x, y + -h / 3 * 2), ctx.lineTo(r + x, y + h), ctx.lineTo(x - r, y + h), ctx.closePath(), !0; } export class ThinTriangleSymbol extends BaseSymbol { constructor() { super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z"; } draw(ctx, size, x, y) { return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y); } drawOffset(ctx, size, x, y, offset) { return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y); } } export default new ThinTriangleSymbol; //# sourceMappingURL=thin-triangle.js.map