render split points as squares

multi-curve-paths
Preet 1 year ago
parent 539071fcfe
commit 1e4bfceb13

@ -157,13 +157,25 @@ const fillCircle = (
cy: number, cy: number,
radius: number, radius: number,
stroke = true, stroke = true,
noFill = false,
) => { ) => {
context.beginPath(); context.beginPath();
context.arc(cx, cy, radius, 0, Math.PI * 2); context.arc(cx, cy, radius, 0, Math.PI * 2);
if (!noFill) { context.fill();
context.fill(); if (stroke) {
context.stroke();
} }
};
const fillSquare = (
context: CanvasRenderingContext2D,
cx: number,
cy: number,
side: number,
stroke = true,
) => {
context.beginPath();
context.rect(cx - side / 2, cy - side / 2, side, side);
context.fill();
if (stroke) { if (stroke) {
context.stroke(); context.stroke();
} }
@ -227,7 +239,7 @@ const renderSingleLinearPoint = (
point: Point, point: Point,
radius: number, radius: number,
isSelected: boolean, isSelected: boolean,
isSegmentSplitting: boolean, renderAsSquare: boolean,
isPhantomPoint = false, isPhantomPoint = false,
) => { ) => {
context.strokeStyle = "#5e5ad8"; context.strokeStyle = "#5e5ad8";
@ -239,22 +251,18 @@ const renderSingleLinearPoint = (
context.fillStyle = "rgba(177, 151, 252, 0.7)"; context.fillStyle = "rgba(177, 151, 252, 0.7)";
} }
fillCircle( const effectiveRadius = radius / appState.zoom.value;
context,
point[0], if (renderAsSquare) {
point[1], fillSquare(
radius / appState.zoom.value,
!isPhantomPoint,
);
if (isSegmentSplitting) {
fillCircle(
context, context,
point[0], point[0],
point[1], point[1],
(radius + 4) / appState.zoom.value, effectiveRadius * 2,
true, !isPhantomPoint,
true,
); );
} else {
fillCircle(context, point[0], point[1], effectiveRadius, !isPhantomPoint);
} }
}; };

Loading…
Cancel
Save