Skip to content

Commit f546c92

Browse files
committed
Add support for S_RECT drawsegment
Fixes #180
1 parent 1d37950 commit f546c92

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

DATAFORMAT.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,18 @@ attribute.
122122
{
123123
"type": "segment",
124124
"start": [x, y],
125-
"end": end,
125+
"end": [x, y],
126+
"width": width,
127+
}
128+
```
129+
130+
### rect
131+
132+
```js
133+
{
134+
"type": "rect",
135+
"start": [x, y], // coordinates of opposing corners
136+
"end": [x, y],
126137
"width": width,
127138
}
128139
```

InteractiveHtmlBom/ecad/kicad.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ def parse_draw_segment(self, d):
4646
pcbnew.S_ARC: "arc",
4747
pcbnew.S_POLYGON: "polygon",
4848
pcbnew.S_CURVE: "curve",
49+
pcbnew.S_RECT: "rect",
4950
}.get(d.GetShape(), "")
5051
if shape == "":
5152
self.logger.info("Unsupported shape %s, skipping", d.GetShape())
5253
return None
5354
start = self.normalize(d.GetStart())
5455
end = self.normalize(d.GetEnd())
55-
if shape == "segment":
56+
if shape in ["segment", "rect"]:
5657
return {
5758
"type": shape,
5859
"start": start,

InteractiveHtmlBom/web/render.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ function drawedge(ctx, scalefactor, edge, color) {
132132
ctx.moveTo(...edge.start);
133133
ctx.lineTo(...edge.end);
134134
}
135+
if (edge.type == "rect") {
136+
ctx.moveTo(...edge.start);
137+
ctx.lineTo(edge.start[0], edge.end[1]);
138+
ctx.lineTo(...edge.end);
139+
ctx.lineTo(edge.end[0], edge.start[1]);
140+
ctx.lineTo(...edge.start);
141+
}
135142
if (edge.type == "arc") {
136143
ctx.arc(
137144
...edge.start,
@@ -363,7 +370,7 @@ function drawModules(canvas, layer, scalefactor, highlight) {
363370
function drawBgLayer(layername, canvas, layer, scalefactor, edgeColor, polygonColor, textColor) {
364371
var ctx = canvas.getContext("2d");
365372
for (var d of pcbdata[layername][layer]) {
366-
if (["segment", "arc", "circle", "curve"].includes(d.type)) {
373+
if (["segment", "arc", "circle", "curve", "rect"].includes(d.type)) {
367374
drawedge(ctx, scalefactor, d, edgeColor);
368375
} else if (d.type == "polygon") {
369376
drawPolygonShape(ctx, d, polygonColor);

0 commit comments

Comments
 (0)