Skip to content

Commit

Permalink
Improve type safety of JCanvasObject
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed May 29, 2024
1 parent 3c3f41d commit ff0b932
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 86 deletions.
10 changes: 9 additions & 1 deletion src/jcanvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ interface JCanvasDefaults {
dx: number;
dy: number;
end: number;
endArrow: boolean;
eventX: number | null;
eventY: number | null;
fillRule: CanvasFillRule;
fillStyle: string | CanvasGradient | CanvasPattern | JCanvasStyleFunction;
flipArcText: boolean;
fontStyle: string;
fontSize: string;
fontFamily: string;
Expand Down Expand Up @@ -249,12 +251,14 @@ interface JCanvasDefaults {
source: string | HTMLImageElement | HTMLCanvasElement;
spread: number;
start: number;
startArrow: boolean;
strokeCap: CanvasRenderingContext2D["lineCap"];
strokeDash: number[] | null;
strokeDashOffset: CanvasRenderingContext2D["lineDashOffset"];
strokeJoin: CanvasRenderingContext2D["lineJoin"];
strokeStyle: string | CanvasGradient | CanvasPattern | JCanvasStyleFunction;
strokeWidth: number;
style: Record<string, boolean>;
sWidth: number | null;
sx: number | null;
sy: number | null;
Expand All @@ -276,6 +280,11 @@ interface JCanvasDefaults {
this: HTMLCanvasElement,
arg: JCanvasObject | CanvasPattern | null
) => void;
fn?: (
this: HTMLCanvasElement,
ctx: CanvasRenderingContext2D,
params: JCanvasObject
) => void;
click?: JCanvasLayerCallback;
dblclick?: JCanvasLayerCallback;
mousedown?: JCanvasLayerCallback;
Expand Down Expand Up @@ -313,7 +322,6 @@ interface JCanvasDefaults {
[key: `l${number}`]: number;
[key: `p${number}`]: number;
[key: `_${string}`]: any;
[key: string]: any;
}

interface JCanvasObject extends JCanvasDefaults {}
Expand Down
Loading

0 comments on commit ff0b932

Please sign in to comment.