highlight squares appropriately

This commit is contained in:
Preet 2023-10-23 18:13:43 -07:00
parent 1e4bfceb13
commit 4372e992e0

View File

@ -362,16 +362,16 @@ const highlightPoint = (
point: Point, point: Point,
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
appState: InteractiveCanvasAppState, appState: InteractiveCanvasAppState,
renderAsSquare = false,
) => { ) => {
context.fillStyle = "rgba(105, 101, 219, 0.4)"; context.fillStyle = "rgba(105, 101, 219, 0.4)";
const radius = LinearElementEditor.POINT_HANDLE_SIZE / appState.zoom.value;
fillCircle( if (renderAsSquare) {
context, fillSquare(context, point[0], point[1], radius * 2, false);
point[0], } else {
point[1], fillCircle(context, point[0], point[1], radius, false);
LinearElementEditor.POINT_HANDLE_SIZE / appState.zoom.value, }
false,
);
}; };
const renderLinearElementPointHighlight = ( const renderLinearElementPointHighlight = (
context: CanvasRenderingContext2D, context: CanvasRenderingContext2D,
@ -393,10 +393,15 @@ const renderLinearElementPointHighlight = (
element, element,
hoverPointIndex, hoverPointIndex,
); );
const segmented = element.roundness
? element.segmentSplitIndices
? element.segmentSplitIndices.includes(hoverPointIndex)
: false
: false;
context.save(); context.save();
context.translate(appState.scrollX, appState.scrollY); context.translate(appState.scrollX, appState.scrollY);
highlightPoint(point, context, appState, segmented);
highlightPoint(point, context, appState);
context.restore(); context.restore();
}; };