From dc3365c1cca2d049d628455257b2551773d0571d Mon Sep 17 00:00:00 2001 From: seveibar Date: Fri, 8 Nov 2024 10:40:45 -0800 Subject: [PATCH] fix labelled points not appearing at correct position, make sans-serif --- lib/sch/draw-schematic-labeled-points.ts | 13 +++++++------ tests/sch/__snapshots__/grid-and-points.snap.svg | 2 +- tests/sch/grid-and-points.test.tsx | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/sch/draw-schematic-labeled-points.ts b/lib/sch/draw-schematic-labeled-points.ts index cf84029..86ee6bc 100644 --- a/lib/sch/draw-schematic-labeled-points.ts +++ b/lib/sch/draw-schematic-labeled-points.ts @@ -17,10 +17,10 @@ export function drawSchematicLabeledPoints(params: { for (const point of points) { // Transform offset points for X marker - const [x1, y1] = applyToPoint(transform, [point.x - 0.1, -(point.y - 0.1)]) - const [x2, y2] = applyToPoint(transform, [point.x + 0.1, -(point.y + 0.1)]) - const [x3, y3] = applyToPoint(transform, [point.x - 0.1, -(point.y + 0.1)]) - const [x4, y4] = applyToPoint(transform, [point.x + 0.1, -(point.y - 0.1)]) + const [x1, y1] = applyToPoint(transform, [point.x - 0.1, point.y - 0.1]) + const [x2, y2] = applyToPoint(transform, [point.x + 0.1, point.y + 0.1]) + const [x3, y3] = applyToPoint(transform, [point.x - 0.1, point.y + 0.1]) + const [x4, y4] = applyToPoint(transform, [point.x + 0.1, point.y - 0.1]) // Add X marker labeledPointsGroup.push({ @@ -37,7 +37,7 @@ export function drawSchematicLabeledPoints(params: { // Transform label position const [labelX, labelY] = applyToPoint(transform, [ point.x + 0.15, - -(point.y - 0.15), + point.y - 0.15, ]) // Add label @@ -48,9 +48,10 @@ export function drawSchematicLabeledPoints(params: { x: labelX.toString(), y: labelY.toString(), fill: colorMap.schematic.grid, - "font-size": (0.15 * Math.abs(transform.a)).toString(), + "font-size": (0.1 * Math.abs(transform.a)).toString(), "fill-opacity": "0.7", "text-anchor": "start", + "font-family": "sans-serif", "dominant-baseline": "middle", }, children: [ diff --git a/tests/sch/__snapshots__/grid-and-points.snap.svg b/tests/sch/__snapshots__/grid-and-points.snap.svg index ccde4a9..bc1631e 100644 --- a/tests/sch/__snapshots__/grid-and-points.snap.svg +++ b/tests/sch/__snapshots__/grid-and-points.snap.svg @@ -9,4 +9,4 @@ .pin-number { fill: rgb(169, 0, 0); } .port-label { fill: rgb(0, 100, 100); } .component-name { fill: rgb(0, 100, 100); } - -1,-1-1,-0.5-1,0-1,0.5-1,1-0.5,-1-0.5,-0.5-0.5,0-0.5,0.5-0.5,10,-10,-0.50,00,0.50,10.5,-10.5,-0.50.5,00.5,0.50.5,11,-11,-0.51,01,0.51,1OriginPoint ATest Box \ No newline at end of file + -1,-1-1,-0.5-1,0-1,0.5-1,1-0.5,-1-0.5,-0.5-0.5,0-0.5,0.5-0.5,10,-10,-0.50,00,0.50,10.5,-10.5,-0.50.5,00.5,0.50.5,11,-11,-0.51,01,0.51,1OriginPoint ATest Box \ No newline at end of file diff --git a/tests/sch/grid-and-points.test.tsx b/tests/sch/grid-and-points.test.tsx index d963e76..3b376d1 100644 --- a/tests/sch/grid-and-points.test.tsx +++ b/tests/sch/grid-and-points.test.tsx @@ -17,7 +17,7 @@ test("schematic with grid and labeled points", () => { grid: { cellSize: 0.5, labelCells: true }, labeledPoints: [ { x: 0, y: 0, label: "Origin" }, - { x: 1, y: 1, label: "Point A" }, + { x: 0.75, y: 0.75, label: "Point A" }, ], }, ),