Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiboSoftwareDev committed Dec 22, 2024
1 parent dec0706 commit be9ea3a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -181,33 +181,19 @@ export const createSvgObjectsFromSchematicComponentWithSymbol = ({
textValue = schComponent.symbol_display_value ?? ""
}

const getTextOffset = (
bounds: { minX: number; maxX: number; minY: number; maxY: number },
anchor: TextPrimitive["anchor"],
transform: Matrix,
) => {
const symbolHeight = Math.abs(bounds.maxY - bounds.minY)
const offsetFactor = 0.1
const symbolHeight = Math.abs(bounds.maxY - bounds.minY)
const offsetFactor = 0.1
const baseOffset = symbolHeight * offsetFactor
const transformScale = Math.abs(transformFromSymbolToReal.a)

const baseOffset = symbolHeight * offsetFactor
let verticalOffset = 0

const transformScale = Math.abs(transform.a)

if (anchor.includes("bottom")) {
return baseOffset * transformScale
}
if (anchor.includes("top")) {
return -baseOffset * transformScale
}
return 0
if (text.anchor.includes("bottom")) {
verticalOffset = baseOffset * transformScale
} else if (text.anchor.includes("top")) {
verticalOffset = -baseOffset * transformScale
}

const verticalOffset = getTextOffset(
bounds,
text.anchor,
transformFromSymbolToReal,
)

const dominantBaseline = text.anchor.includes("bottom")
? "auto"
: text.anchor.includes("top")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@types/bun": "^1.1.9",
"biome": "^0.3.3",
"bun-match-svg": "^0.0.6",
"circuit-json": "^0.0.111",
"circuit-json": "^0.0.119",
"esbuild": "^0.20.2",
"performance-now": "^2.1.0",
"react": "^18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/sch/transform-attribute.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "bun:test"
import { convertCircuitJsonToSchematicSvg } from "lib"

test.skip("svg should have data-real-to-screen-transform attribute", () => {
test("svg should have data-real-to-screen-transform attribute", () => {
const svg = convertCircuitJsonToSchematicSvg([
{
type: "schematic_box",
Expand Down

0 comments on commit be9ea3a

Please sign in to comment.