From 549c5800152690b53f3c5824dcc4bb157df1ad44 Mon Sep 17 00:00:00 2001 From: Kevin Zheng Date: Wed, 20 Mar 2024 15:30:59 +1100 Subject: [PATCH] Fix off by one errors --- client/src/components/renderer/map-parser/grid/index.tsx | 4 ++-- .../src/components/renderer/parser/parseTraceSlave.worker.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/components/renderer/map-parser/grid/index.tsx b/client/src/components/renderer/map-parser/grid/index.tsx index 41cecdb2..8c02f1bc 100644 --- a/client/src/components/renderer/map-parser/grid/index.tsx +++ b/client/src/components/renderer/map-parser/grid/index.tsx @@ -11,7 +11,7 @@ import interpolate from "color-interpolate"; import { EditorProps } from "components/Editor"; import { FeaturePickerButton } from "components/app-bar/FeaturePickerButton"; import { Option } from "components/layer-editor/Option"; -import { find, flow, set, sortBy, startCase } from "lodash"; +import { find, flow, round, set, sortBy, startCase } from "lodash"; import PopupState, { bindPopover, bindTrigger } from "material-ui-popup-state"; import memo from "memoizee"; import { getClosestColor } from "nearest-pantone"; @@ -156,7 +156,7 @@ export const hydrate: ParsedMapHydrator = (result) => { return { ...result, snap: ({ x: x1, y: y1 }, scale = 1) => { - const [x, y] = [floor(x1 + scale / 2), floor(y1 + scale / 2)]; + const [x, y] = [round(-1 + x1 + scale / 2), round(-1 + y1 + scale / 2)]; if (between(x, 0, width) && between(y, 0, height)) return { x, y }; }, nodeAt: (point) => { diff --git a/client/src/components/renderer/parser/parseTraceSlave.worker.ts b/client/src/components/renderer/parser/parseTraceSlave.worker.ts index f3ab5522..05324785 100644 --- a/client/src/components/renderer/parser/parseTraceSlave.worker.ts +++ b/client/src/components/renderer/parser/parseTraceSlave.worker.ts @@ -64,7 +64,7 @@ function parse({ return { persistent, transient }; }) .map((c) => mapValues(c, (b) => b.filter(isVisible))) - .map((c, i) => mapValues(c, (b) => b.map(makeEntryIteratee(i)))) + .map((c, i) => mapValues(c, (b) => b.map(makeEntryIteratee(from + i)))) .value(); return { stepsPersistent: map(steps, (c) => c.persistent),