diff --git a/packages/client/src/components/CanvasWrapper.tsx b/packages/client/src/components/CanvasWrapper.tsx
index c42d392b2e18d7f45d7beca8b99c3f6966a2730f..35d7b7bd5d4466eabb07fdce98f4692cc5c02830 100644
--- a/packages/client/src/components/CanvasWrapper.tsx
+++ b/packages/client/src/components/CanvasWrapper.tsx
@@ -47,6 +47,7 @@ const KEYBOARD_ZOOM_STEP = 1;
const KEYBOARD_ZOOM_SMALL_STEP = 0.35;
const INSPECT_END_ANIMATION_DURATION = 180;
const TOUCH_INSPECT_MOVE_THRESHOLD = 25;
+const GRID_LINE_FRACTION = 1 / 8;
export const CanvasWrapper = () => {
const hasMod = useHasRole("MOD");
@@ -122,7 +123,7 @@ export const CanvasWrapper = () => {
}
const CursorInspectPreview = () => {
- const { cursor } = useAppContext();
+ const { cursor, gridOverlay } = useAppContext();
const PanZoom = useContext(RendererContext);
const selectedColor =
typeof cursor.color === "number"
@@ -342,6 +343,8 @@ const CursorInspectPreview = () => {
const inspectScreenRect = (() => {
if (
(inspectHold === "idle" && !hasSelectedColor) ||
+ typeof previewPosition.x !== "number" ||
+ typeof previewPosition.y !== "number" ||
previewPosition.x < 0 ||
previewPosition.y < 0
) {
@@ -362,6 +365,10 @@ const CursorInspectPreview = () => {
const inspectBorderSize = inspectScreenRect
? Math.min(inspectScreenRect.width, inspectScreenRect.height)
: 1;
+ const gridInset =
+ inspectScreenRect && gridOverlay.enabled && hasSelectedColor
+ ? inspectBorderSize * GRID_LINE_FRACTION
+ : 0;
const preview = (
{
left: previewPosition.x,
...(inspectScreenRect && {
position: "fixed",
- top: inspectScreenRect.top,
- left: inspectScreenRect.left,
- width: inspectScreenRect.width,
- height: inspectScreenRect.height,
+ top: inspectScreenRect.top + gridInset,
+ left: inspectScreenRect.left + gridInset,
+ width: Math.max(0, inspectScreenRect.width - gridInset),
+ height: Math.max(0, inspectScreenRect.height - gridInset),
zIndex: 1,
"--inspect-border-start-inner": inspectBorderSize * 0.02 + "px",
"--inspect-border-start-outer": inspectBorderSize * 0.04 + "px",
diff --git a/packages/client/src/components/Overlay/GridOverlay.tsx b/packages/client/src/components/Overlay/GridOverlay.tsx
index 8d24f500357627cc6912648b3392d95a47efd11b..bcaec7ea61e26cef231f59a8641f178dd152a414 100644
--- a/packages/client/src/components/Overlay/GridOverlay.tsx
+++ b/packages/client/src/components/Overlay/GridOverlay.tsx
@@ -28,7 +28,10 @@ export const GridOverlay = () => {
if (!ctx) return;
ctx.clearRect(0, 0, canvas.width, canvas.height);
- ctx.fillStyle = "black"; // full black
+ // Keep grid lines neutral instead of tinting them with placed pixel colors.
+ const opacity = Math.min(Math.max(gridOverlay.opacity ?? 1, 0), 1);
+ const channel = Math.round(255 - (255 - 128) * opacity);
+ ctx.fillStyle = `rgb(${channel}, ${channel}, ${channel})`;
for (let x = 0; x <= canvas.width; x += GRID_SPACING) {
ctx.fillRect(x, 0, 1, canvas.height); // vertical line as 1px wide column
@@ -37,7 +40,7 @@ export const GridOverlay = () => {
for (let y = 0; y <= canvas.height; y += GRID_SPACING) {
ctx.fillRect(0, y, canvas.width, 1); // horizontal line as 1px tall row
}
- }, [gridOverlay.enabled]);
+ }, [gridOverlay.enabled, gridOverlay.opacity]);
return (