Skip to content

Commit

Permalink
feat(hiccup-canvas): add IToHiccup support in draw
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 5, 2020
1 parent 6f4ddf1 commit a59bb09
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/hiccup-canvas/src/draw.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray } from "@thi.ng/checks";
import { implementsFunction, isArray } from "@thi.ng/checks";
import type { DrawState } from "./api";
import { circularArc, ellipticArc } from "./arc";
import { defLinearGradient, defRadialGradient } from "./color";
Expand All @@ -15,10 +15,14 @@ import { text } from "./text";

export const draw = (
ctx: CanvasRenderingContext2D,
shape: any[],
shape: any,
pstate: DrawState = { attribs: {}, edits: [] }
) => {
if (!shape) return;
if (implementsFunction(shape, "toHiccup")) {
draw(ctx, shape.toHiccup(), pstate);
return;
}
if (isArray(shape[0])) {
for (let s of shape) {
draw(ctx, s, pstate);
Expand Down

0 comments on commit a59bb09

Please sign in to comment.