From 07569831d4363ebce6cd77a1d6b27d2c615012d3 Mon Sep 17 00:00:00 2001 From: scamiv <6170744+scamiv@users.noreply.github.com> Date: Fri, 6 Mar 2026 20:27:35 +0100 Subject: [PATCH] missing --- tests/SegmentTrailRaster.test.ts | 45 +++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/tests/SegmentTrailRaster.test.ts b/tests/SegmentTrailRaster.test.ts index abcd13d8d..8dd3805fd 100644 --- a/tests/SegmentTrailRaster.test.ts +++ b/tests/SegmentTrailRaster.test.ts @@ -79,8 +79,8 @@ describe("SegmentTrailRaster", () => { expect(drew).toBe(true); expect(ops).toEqual([ { op: "beginPath" }, - { op: "moveTo", x: 0, y: 0 }, - { op: "lineTo", x: 1, y: 0 }, + { op: "moveTo", x: 0.5, y: 0.5 }, + { op: "lineTo", x: 1.5, y: 0.5 }, { op: "stroke" }, ]); }); @@ -93,9 +93,9 @@ describe("SegmentTrailRaster", () => { expect(drew).toBe(true); expect(ops).toEqual([ { op: "beginPath" }, - { op: "moveTo", x: 2, y: 0 }, - { op: "lineTo", x: 3, y: 0 }, - { op: "lineTo", x: 3, y: 2 }, + { op: "moveTo", x: 2.5, y: 0.5 }, + { op: "lineTo", x: 3.5, y: 0.5 }, + { op: "lineTo", x: 3.5, y: 2.5 }, { op: "stroke" }, ]); }); @@ -108,6 +108,33 @@ describe("SegmentTrailRaster", () => { expect(ops).toEqual([]); }); + it("keeps +0.5 offset even when rounding is disabled", () => { + const { ctx, ops } = makeMockCtx(); + const game = { + x(ref: number): number { + return ref === 0 ? 0.2 : 1.7; + }, + y(): number { + return 0.4; + }, + }; + const plan = { + startTick: 0, + ticksPerStep: 1, + points: Uint32Array.from([0, 1]), + segmentSteps: Uint32Array.from([1]), + segCumSteps: Uint32Array.from([0, 1]), + }; + + expect(strokeStepInterval(ctx, game, plan, 0, 1, false)).toBe(true); + expect(ops).toEqual([ + { op: "beginPath" }, + { op: "moveTo", x: 0.7, y: 0.9 }, + { op: "lineTo", x: 2.2, y: 0.9 }, + { op: "stroke" }, + ]); + }); + it("supports replan-style epoch replay by drawing multiple intervals", () => { const { ctx, ops } = makeMockCtx(); const game = makeGame(); @@ -131,12 +158,12 @@ describe("SegmentTrailRaster", () => { expect(ops).toEqual([ { op: "beginPath" }, - { op: "moveTo", x: 0, y: 0 }, - { op: "lineTo", x: 3, y: 0 }, + { op: "moveTo", x: 0.5, y: 0.5 }, + { op: "lineTo", x: 3.5, y: 0.5 }, { op: "stroke" }, { op: "beginPath" }, - { op: "moveTo", x: 3, y: 0 }, - { op: "lineTo", x: 3, y: 2 }, + { op: "moveTo", x: 3.5, y: 0.5 }, + { op: "lineTo", x: 3.5, y: 2.5 }, { op: "stroke" }, ]); });