Skip to content

Commit

Permalink
add helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshidwivedi committed Jun 18, 2024
1 parent c0a575b commit 7a8c954
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions modules/canvas/helpers/Canvas.helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const drawFromSocket = (
socketMoves: [number, number][],
socketOptions: CtxOptions,
ctx: CanvasRenderingContext2D,
afterDraw: ()=> void
)=>{
const tempCtx = ctx;

if(tempCtx){
tempCtx.lineWidth= socketOptions.lineWidth;
tempCtx.strokeStyle= socketOptions.lineColor;

tempCtx.beginPath();
socketMoves.forEach(([x,y])=>{
tempCtx.lineTo(x,y);
tempCtx.stroke();
});
tempCtx.closePath();
afterDraw();
}
};

0 comments on commit 7a8c954

Please sign in to comment.