From 4d347a840cd411bd627e868190520fc7c952ded8 Mon Sep 17 00:00:00 2001 From: Paul Falstad Date: Sun, 27 Oct 2024 14:46:03 -0700 Subject: [PATCH] fix 7 seg in common cathode/anode mode in printable mode (#100) --- .../lushprojects/circuitjs1/client/SevenSegElm.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/com/lushprojects/circuitjs1/client/SevenSegElm.java b/src/com/lushprojects/circuitjs1/client/SevenSegElm.java index 0316de3a..67c4e3d5 100644 --- a/src/com/lushprojects/circuitjs1/client/SevenSegElm.java +++ b/src/com/lushprojects/circuitjs1/client/SevenSegElm.java @@ -278,9 +278,10 @@ void stepFinished() { } void setColor(Graphics g, int p) { + boolean whiteBkg = sim.printableCheckItem.getState(); if (diodeDirection == 0) { g.setColor(pins[p].value ? Color.red : - sim.printableCheckItem.getState() ? lightgray : darkred); + whiteBkg ? lightgray : darkred); return; } // 10mA current = max brightness @@ -289,9 +290,11 @@ void setColor(Graphics g, int p) { w = 255*(1+.2*Math.log(w)); if (w > 255) w = 255; - if (w < 30) - w = 30; - Color cc = new Color((int) w, 0, 0); + double minw = (whiteBkg) ? 5 : 30; + if (w < minw) + w = minw; + int wi = (int) w; + Color cc = whiteBkg ? new Color(255, 255-wi, 255-wi) : new Color(wi, 0, 0); g.setColor(cc); } int getPostCount() { return pinCount; }