Restyle hollow circle node slot (#156)

This commit is contained in:
Chenlei Hu
2024-09-22 15:23:54 +09:00
committed by GitHub
parent 0a86c3347c
commit dd0f0d2890

View File

@@ -48,6 +48,7 @@ export function drawSlot(
// Save the current fillStyle and strokeStyle
const originalFillStyle = ctx.fillStyle;
const originalStrokeStyle = ctx.strokeStyle;
const originalLineWidth = ctx.lineWidth;
const slot_type = slot.type as SlotType;
const slot_shape = (
@@ -90,12 +91,18 @@ export function drawSlot(
if (low_quality) {
ctx.rect(pos[0] - 4, pos[1] - 4, 8, 8);
} else {
ctx.arc(pos[0], pos[1], 4, 0, Math.PI * 2);
let radius: number;
if (slot_shape === SlotShape.HollowCircle) {
doFill = false;
doStroke = true;
ctx.lineWidth = 3;
ctx.strokeStyle = ctx.fillStyle;
radius = 3;
} else {
// Normal circle
radius = 4;
}
ctx.arc(pos[0], pos[1], radius, 0, Math.PI * 2);
}
}
@@ -127,4 +134,5 @@ export function drawSlot(
// Restore the original fillStyle and strokeStyle
ctx.fillStyle = originalFillStyle;
ctx.strokeStyle = originalStrokeStyle;
ctx.lineWidth = originalLineWidth;
}