Skip to content

Commit 4cb466f

Browse files
authored
chore: Update canvas-connection-system.md
1 parent 562dbbc commit 4cb466f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

docs/connections/canvas-connection-system.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ class SimpleLineConnection extends BaseConnection {
327327
const ctx = this.context.ctx;
328328

329329
// Custom rendering logic
330-
ctx.strokeStyle = this.state.selected ? "#ff0000" : "#000000";
331-
ctx.lineWidth = 3;
332-
ctx.beginPath();
333-
ctx.moveTo(source.x, source.y);
334-
ctx.lineTo(target.x, target.y);
335-
ctx.stroke();
330+
this.context.ctx.strokeStyle = this.state.selected ? "#ff0000" : "#000000";
331+
this.context.ctx.lineWidth = 3;
332+
this.context.ctx.beginPath();
333+
this.context.ctx.moveTo(source.x, source.y);
334+
this.context.ctx.lineTo(target.x, target.y);
335+
this.context.ctx.stroke();
336336
}
337337
}
338338
```
@@ -364,9 +364,9 @@ class CustomPathConnection extends BlockConnection {
364364

365365
// Override styling
366366
public style(ctx: CanvasRenderingContext2D) {
367-
ctx.strokeStyle = this.state.hovered ? "#ff6b6b" : "#4285f4";
368-
ctx.lineWidth = this.state.selected ? 4 : 2;
369-
ctx.setLineDash(this.state.dashed ? [8, 4] : []);
367+
this.context.ctx.strokeStyle = this.state.hovered ? "#ff6b6b" : "#4285f4";
368+
this.context.ctx.lineWidth = this.state.selected ? 4 : 2;
369+
this.context.ctx.setLineDash(this.state.dashed ? [8, 4] : []);
370370
return { type: "stroke" };
371371
}
372372
}
@@ -388,10 +388,10 @@ class AnimatedConnection extends BlockConnection {
388388
const x = source.x + (target.x - source.x) * progress;
389389
const y = source.y + (target.y - source.y) * progress;
390390

391-
ctx.fillStyle = "#ffeb3b";
392-
ctx.beginPath();
393-
ctx.arc(x, y, 4, 0, Math.PI * 2);
394-
ctx.fill();
391+
this.context.ctx.fillStyle = "#ffeb3b";
392+
this.context.ctx.beginPath();
393+
this.context.ctx.arc(x, y, 4, 0, Math.PI * 2);
394+
this.context.ctx.fill();
395395
}
396396

397397
this.animationPhase += 0.02;

0 commit comments

Comments
 (0)