@@ -168,34 +168,35 @@ function getOblongPath(size) {
168
168
return getChamferedRectPath ( size , Math . min ( size [ 0 ] , size [ 1 ] ) / 2 , 0 , 0 ) ;
169
169
}
170
170
171
- function getPolygonsPath ( polygons ) {
172
- var combinedPath = new Path2D ( ) ;
173
- for ( var polygon of polygons ) {
174
- var path = new Path2D ( ) ;
175
- for ( var vertex of polygon ) {
176
- path . lineTo ( ...vertex )
171
+ function getPolygonsPath ( shape ) {
172
+ if ( shape . path2d ) {
173
+ return shape . path2d ;
174
+ }
175
+ if ( shape . svgpath ) {
176
+ shape . path2d = new Path2D ( shape . svgpath ) ;
177
+ } else {
178
+ var combinedPath = new Path2D ( ) ;
179
+ for ( var polygon of shape . polygons ) {
180
+ var path = new Path2D ( ) ;
181
+ for ( var vertex of polygon ) {
182
+ path . lineTo ( ...vertex )
183
+ }
184
+ path . closePath ( ) ;
185
+ combinedPath . addPath ( path ) ;
177
186
}
178
- path . closePath ( ) ;
179
- combinedPath . addPath ( path ) ;
187
+ shape . path2d = combinedPath ;
180
188
}
181
- return combinedPath ;
189
+ return shape . path2d ;
182
190
}
183
191
184
192
function drawPolygonShape ( ctx , shape , color ) {
185
193
ctx . save ( ) ;
186
194
ctx . fillStyle = color ;
187
- if ( ! shape . path2d ) {
188
- if ( shape . svgpath ) {
189
- shape . path2d = new Path2D ( shape . svgpath ) ;
190
- } else {
191
- shape . path2d = getPolygonsPath ( shape . polygons ) ;
192
- }
193
- }
194
195
if ( ! shape . svgpath ) {
195
196
ctx . translate ( ...shape . pos ) ;
196
197
ctx . rotate ( deg2rad ( - shape . angle ) ) ;
197
198
}
198
- ctx . fill ( shape . path2d ) ;
199
+ ctx . fill ( getPolygonsPath ( shape ) ) ;
199
200
ctx . restore ( ) ;
200
201
}
201
202
@@ -360,10 +361,10 @@ function drawZones(canvas, layer, color, highlight) {
360
361
ctx . lineJoin = "round" ;
361
362
for ( var zone of pcbdata . zones [ layer ] ) {
362
363
if ( ! zone . path2d ) {
363
- zone . path2d = getPolygonsPath ( zone . polygons ) ;
364
+ zone . path2d = getPolygonsPath ( zone ) ;
364
365
}
365
366
if ( highlight && highlightedNet != zone . net ) continue ;
366
- ctx . lineWidth = zone . width ;
367
+ ctx . lineWidth = zone . width ? zone . width : 0 ;
367
368
ctx . fill ( zone . path2d ) ;
368
369
ctx . stroke ( zone . path2d ) ;
369
370
}
@@ -422,12 +423,13 @@ function drawBackground(canvasdict) {
422
423
clearCanvas ( canvasdict . bg ) ;
423
424
clearCanvas ( canvasdict . fab ) ;
424
425
clearCanvas ( canvasdict . silk ) ;
425
- drawEdgeCuts ( canvasdict . bg , canvasdict . transform . s ) ;
426
426
427
427
drawNets ( canvasdict . bg , canvasdict . layer , false ) ;
428
428
drawModules ( canvasdict . bg , canvasdict . layer ,
429
429
canvasdict . transform . s * canvasdict . transform . zoom , false ) ;
430
430
431
+ drawEdgeCuts ( canvasdict . bg , canvasdict . transform . s ) ;
432
+
431
433
var style = getComputedStyle ( topmostdiv ) ;
432
434
var edgeColor = style . getPropertyValue ( '--silkscreen-edge-color' ) ;
433
435
var polygonColor = style . getPropertyValue ( '--silkscreen-polygon-color' ) ;
0 commit comments