@@ -297,7 +297,7 @@ function drawPadHole(ctx, pad, padHoleColor) {
297
297
ctx . restore ( ) ;
298
298
}
299
299
300
- function drawFootprint ( ctx , layer , scalefactor , footprint , padColor , padHoleColor , outlineColor , highlight , outline ) {
300
+ function drawFootprint ( ctx , layer , scalefactor , footprint , colors , highlight , outline ) {
301
301
if ( highlight ) {
302
302
// draw bounding box
303
303
if ( footprint . layer == layer ) {
@@ -306,32 +306,32 @@ function drawFootprint(ctx, layer, scalefactor, footprint, padColor, padHoleColo
306
306
ctx . translate ( ...footprint . bbox . pos ) ;
307
307
ctx . rotate ( deg2rad ( - footprint . bbox . angle ) ) ;
308
308
ctx . translate ( ...footprint . bbox . relpos ) ;
309
- ctx . fillStyle = padColor ;
309
+ ctx . fillStyle = colors . pad ;
310
310
ctx . fillRect ( 0 , 0 , ...footprint . bbox . size ) ;
311
311
ctx . globalAlpha = 1 ;
312
- ctx . strokeStyle = padColor ;
312
+ ctx . strokeStyle = colors . pad ;
313
313
ctx . strokeRect ( 0 , 0 , ...footprint . bbox . size ) ;
314
314
ctx . restore ( ) ;
315
315
}
316
316
}
317
317
// draw drawings
318
318
for ( var drawing of footprint . drawings ) {
319
319
if ( drawing . layer == layer ) {
320
- drawDrawing ( ctx , scalefactor , drawing . drawing , padColor ) ;
320
+ drawDrawing ( ctx , scalefactor , drawing . drawing , colors . pad ) ;
321
321
}
322
322
}
323
323
// draw pads
324
324
if ( settings . renderPads ) {
325
325
for ( var pad of footprint . pads ) {
326
326
if ( pad . layers . includes ( layer ) ) {
327
- drawPad ( ctx , pad , padColor , outline ) ;
327
+ drawPad ( ctx , pad , colors . pad , outline ) ;
328
328
if ( pad . pin1 && settings . highlightpin1 ) {
329
- drawPad ( ctx , pad , outlineColor , true ) ;
329
+ drawPad ( ctx , pad , colors . outline , true ) ;
330
330
}
331
331
}
332
332
}
333
333
for ( var pad of footprint . pads ) {
334
- drawPadHole ( ctx , pad , padHoleColor ) ;
334
+ drawPadHole ( ctx , pad , colors . padHole ) ;
335
335
}
336
336
}
337
337
}
@@ -348,18 +348,32 @@ function drawFootprints(canvas, layer, scalefactor, highlight) {
348
348
var ctx = canvas . getContext ( "2d" ) ;
349
349
ctx . lineWidth = 3 / scalefactor ;
350
350
var style = getComputedStyle ( topmostdiv ) ;
351
- var padColor = style . getPropertyValue ( '--pad-color' ) ;
352
- var padHoleColor = style . getPropertyValue ( '--pad-hole-color' ) ;
353
- var outlineColor = style . getPropertyValue ( '--pin1-outline-color' ) ;
354
- if ( highlight ) {
355
- padColor = style . getPropertyValue ( '--pad-color-highlight' ) ;
356
- outlineColor = style . getPropertyValue ( '--pin1-outline-color-highlight' ) ;
351
+
352
+ var colors = {
353
+ pad : style . getPropertyValue ( '--pad-color' ) ,
354
+ padHole : style . getPropertyValue ( '--pad-hole-color' ) ,
355
+ outline : style . getPropertyValue ( '--pin1-outline-color' ) ,
357
356
}
357
+
358
358
for ( var i = 0 ; i < pcbdata . footprints . length ; i ++ ) {
359
359
var mod = pcbdata . footprints [ i ] ;
360
360
var outline = settings . renderDnpOutline && pcbdata . bom . skipped . includes ( i ) ;
361
- if ( ! highlight || highlightedFootprints . includes ( i ) ) {
362
- drawFootprint ( ctx , layer , scalefactor , mod , padColor , padHoleColor , outlineColor , highlight , outline ) ;
361
+ var h = highlightedFootprints . includes ( i ) ;
362
+ var d = darkenedFootprints . has ( i ) ;
363
+ if ( highlight ) {
364
+ if ( h && d ) {
365
+ colors . pad = style . getPropertyValue ( '--pad-color-highlight-both' ) ;
366
+ colors . outline = style . getPropertyValue ( '--pin1-outline-highlight-both' ) ;
367
+ } else if ( h ) {
368
+ colors . pad = style . getPropertyValue ( '--pad-color-highlight' ) ;
369
+ colors . outline = style . getPropertyValue ( '--pin1-outline-color-highlight' ) ;
370
+ } else if ( d ) {
371
+ colors . pad = style . getPropertyValue ( '--pad-color-highlight-darkened' ) ;
372
+ colors . outline = style . getPropertyValue ( '--pin1-outline-color-highlight-darkened' ) ;
373
+ }
374
+ }
375
+ if ( h || d || ! highlight ) {
376
+ drawFootprint ( ctx , layer , scalefactor , mod , colors , highlight , outline ) ;
363
377
}
364
378
}
365
379
}
@@ -469,7 +483,7 @@ function drawHighlightsOnLayer(canvasdict, clear = true) {
469
483
if ( clear ) {
470
484
clearCanvas ( canvasdict . highlight ) ;
471
485
}
472
- if ( highlightedFootprints . length > 0 ) {
486
+ if ( darkenedFootprints . size > 0 || highlightedFootprints . length > 0 ) {
473
487
drawFootprints ( canvasdict . highlight , canvasdict . layer ,
474
488
canvasdict . transform . s * canvasdict . transform . zoom , true ) ;
475
489
}
0 commit comments