thi-ng/umbrella

View on GitHub
packages/hiccup-canvas/src/internal/end-shape.ts

Summary

Maintainability
A
55 mins
Test Coverage
import type { IObjectOf } from "@thi.ng/api";

/** @internal */
export const __endShape = (
    ctx: CanvasRenderingContext2D,
    attribs: IObjectOf<any>,
    doFill = true
) => {
    let v: any;
    if (doFill && (v = attribs.fill) && v !== "none") {
        (v = attribs.fillRule) ? ctx.fill(v) : ctx.fill();
    }
    if ((v = attribs.stroke) && v !== "none") {
        ctx.stroke();
    }
    if ((v = attribs.clip)) {
        ctx.clip(v === true ? "nonzero" : v);
    }
};