Make selection handle resolution independent (#948)

They shouldn't really change when zooming in or out.
pull/950/head
Christopher Chedeau 5 years ago committed by GitHub
parent 809d7ba9f5
commit e19088f214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -155,12 +155,15 @@ export function renderScene(
const initialLineDash = context.getLineDash(); const initialLineDash = context.getLineDash();
context.setLineDash([8 / sceneState.zoom, 4 / sceneState.zoom]); context.setLineDash([8 / sceneState.zoom, 4 / sceneState.zoom]);
const lineWidth = context.lineWidth;
context.lineWidth = 1 / sceneState.zoom;
context.strokeRect( context.strokeRect(
elementX1 - dashledLinePadding, elementX1 - dashledLinePadding,
elementY1 - dashledLinePadding, elementY1 - dashledLinePadding,
elementWidth + dashledLinePadding * 2, elementWidth + dashledLinePadding * 2,
elementHeight + dashledLinePadding * 2, elementHeight + dashledLinePadding * 2,
); );
context.lineWidth = lineWidth;
context.setLineDash(initialLineDash); context.setLineDash(initialLineDash);
}); });
resetZoom(context); resetZoom(context);
@ -174,8 +177,11 @@ export function renderScene(
Object.values(handlers) Object.values(handlers)
.filter(handler => handler !== undefined) .filter(handler => handler !== undefined)
.forEach(handler => { .forEach(handler => {
const lineWidth = context.lineWidth;
context.lineWidth = 1 / sceneState.zoom;
context.fillRect(handler[0], handler[1], handler[2], handler[3]); context.fillRect(handler[0], handler[1], handler[2], handler[3]);
context.strokeRect(handler[0], handler[1], handler[2], handler[3]); context.strokeRect(handler[0], handler[1], handler[2], handler[3]);
context.lineWidth = lineWidth;
}); });
resetZoom(context); resetZoom(context);
} }

Loading…
Cancel
Save