diff --git a/lib/svg-serialization/serialize-altium-sheet-to-svg.ts b/lib/svg-serialization/serialize-altium-sheet-to-svg.ts
index eb99e26..4668d97 100644
--- a/lib/svg-serialization/serialize-altium-sheet-to-svg.ts
+++ b/lib/svg-serialization/serialize-altium-sheet-to-svg.ts
@@ -819,19 +819,31 @@ function getSchematicRecordsInPaintOrder(
)
if (firstPinIndex < 0) continue
- const lateOpaqueGraphics = componentRecords
+ const lateFilledGraphics = componentRecords
.slice(firstPinIndex + 1)
- .filter(isOpaqueSchematicGraphic)
- if (lateOpaqueGraphics.length === 0) continue
+ .filter(isFilledSchematicGraphic)
+ if (lateFilledGraphics.length === 0) continue
- const lateOpaqueGraphicSet = new Set(lateOpaqueGraphics)
+ const backgroundGraphics = lateFilledGraphics.filter(
+ (record) => record.getBoolean("TRANSPARENT") === true,
+ )
+ const foregroundGraphics = lateFilledGraphics.filter(
+ (record) => record.getBoolean("TRANSPARENT") !== true,
+ )
+
+ const lateFilledGraphicSet = new Set(lateFilledGraphics)
const reorderedComponentRecords = componentRecords.filter(
- (record) => !lateOpaqueGraphicSet.has(record),
+ (record) => !lateFilledGraphicSet.has(record),
)
const insertionIndex = reorderedComponentRecords.findIndex(
(record) => record.recordKind === "2",
)
- reorderedComponentRecords.splice(insertionIndex, 0, ...lateOpaqueGraphics)
+ reorderedComponentRecords.splice(
+ insertionIndex,
+ 0,
+ ...backgroundGraphics,
+ ...foregroundGraphics,
+ )
for (const [indexOffset, recordIndex] of indexes.entries()) {
const record = reorderedComponentRecords[indexOffset]
@@ -870,7 +882,7 @@ function getParentSchematicRecord(
: context.records[ownerIndex]
}
-function isOpaqueSchematicGraphic(record: AltiumRecord): boolean {
+function isFilledSchematicGraphic(record: AltiumRecord): boolean {
if (record.recordKind === "7") {
return (
record.getBoolean("ISSOLID") === true &&
diff --git a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-32.snap.svg b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-32.snap.svg
index 7679b8c..f150fc4 100644
--- a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-32.snap.svg
+++ b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-32.snap.svg
@@ -917,6 +917,7 @@
R375
2.49K_1%
+
@@ -963,7 +964,6 @@
-
1
2
7
diff --git a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-33.snap.svg b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-33.snap.svg
index 3546de8..1a6c815 100644
--- a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-33.snap.svg
+++ b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-33.snap.svg
@@ -266,6 +266,7 @@
10V
C26
10uF
+
@@ -312,7 +313,6 @@
-
1
2
7
diff --git a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-35.snap.svg b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-35.snap.svg
index cbda32b..ec4880f 100644
--- a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-35.snap.svg
+++ b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-35.snap.svg
@@ -367,8 +367,8 @@
G
Q11
CSD16301Q2
-
+
1
2
3
diff --git a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-36.snap.svg b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-36.snap.svg
index d8c3d09..3bf4092 100644
--- a/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-36.snap.svg
+++ b/tests/svg/__snapshots__/ti-tmds62levm-schematic-sheets-sheet-36.snap.svg
@@ -93,8 +93,8 @@
R195
10K
-
+
1
2
3
diff --git a/tests/svg/schematic-component-paint-order.test.ts b/tests/svg/schematic-component-paint-order.test.ts
index 6cd3fdf..a15b945 100644
--- a/tests/svg/schematic-component-paint-order.test.ts
+++ b/tests/svg/schematic-component-paint-order.test.ts
@@ -1,7 +1,7 @@
import { expect, test } from "bun:test"
import { parseAltiumAscii, serializeAltiumSheetToSvg } from "../../lib"
-test("renders opaque schematic component graphics behind pins", () => {
+test("renders transparent component fills behind foreground graphics", () => {
const source = [
"|RECORD=31|CUSTOMX=140|CUSTOMY=100",
"|RECORD=1|LOCATION.X=70|LOCATION.Y=50",
@@ -10,7 +10,7 @@ test("renders opaque schematic component graphics behind pins", () => {
"|RECORD=7|OWNERINDEX=1|LOCATIONCOUNT=3|X1=40|Y1=30|X2=100|Y2=30|X3=70|Y3=70|ISSOLID=T|AREACOLOR=16777136",
"|RECORD=8|OWNERINDEX=1|LOCATION.X=70|LOCATION.Y=50|RADIUS=30|SECONDARYRADIUS=20|ISSOLID=T|AREACOLOR=16777136",
"|RECORD=10|OWNERINDEX=1|LOCATION.X=40|LOCATION.Y=30|CORNER.X=100|CORNER.Y=70|ISSOLID=T|AREACOLOR=16777136",
- "|RECORD=14|OWNERINDEX=1|LOCATION.X=40|LOCATION.Y=30|CORNER.X=100|CORNER.Y=70|ISSOLID=T|AREACOLOR=16777136",
+ "|RECORD=14|OWNERINDEX=1|LOCATION.X=40|LOCATION.Y=30|CORNER.X=100|CORNER.Y=70|ISSOLID=T|AREACOLOR=16777136|TRANSPARENT=T",
"|RECORD=34|OWNERINDEX=1|LOCATION.X=40|LOCATION.Y=75|TEXT=U1",
].join("\n")
@@ -32,11 +32,14 @@ test("renders opaque schematic component graphics behind pins", () => {
expect(pinIndex).toBeGreaterThan(bodyIndex)
}
expect(lineIndex).toBeGreaterThan(pinIndex)
+ expect(svg.indexOf('INPUT")
})
-test("preserves transparent component graphic order", () => {
+test("preserves unfilled component graphic order", () => {
const source = [
"|RECORD=31|CUSTOMX=140|CUSTOMY=100",
"|RECORD=1|LOCATION.X=70|LOCATION.Y=50",