Skip to content

Color logic gate pins by logical state (high/low)#288

Open
esaruoho wants to merge 1 commit intopfalstad:v3-devfrom
esaruoho:color-logic-by-state
Open

Color logic gate pins by logical state (high/low)#288
esaruoho wants to merge 1 commit intopfalstad:v3-devfrom
esaruoho:color-logic-by-state

Conversation

@esaruoho
Copy link
Copy Markdown

@esaruoho esaruoho commented Mar 3, 2026

Summary

  • Adds a toggleable "Color Logic Pins by State" option in Other Options (persisted via localStorage, off by default)
  • When enabled, logic gate and chip pin leads are colored based on whether the pin voltage is above or below the logic threshold: high pins show in the positive color (green by default), low pins show in the neutral color (gray by default)
  • Makes signal propagation visually traceable through logic circuits without affecting the existing voltage-gradient coloring system for wires and non-logic elements

Affected elements

  • GateElm (AND, OR, XOR, NAND, NOR, XNOR and all subclasses)
  • ChipElm (all digital chips: flip-flops, counters, shift registers, etc.)
  • InverterElm
  • TriStateElm
  • DelayBufferElm

Implementation details

  • New CircuitElm.colorLogicPins static boolean field, loaded from localStorage on startup
  • New CircuitElm.setLogicPinColor(g, volts, threshold) helper method that either applies logic-state coloring or falls back to the standard setVoltageColor() when the option is disabled
  • Each logic element's draw() method uses setLogicPinColor() instead of setVoltageColor() for pin leads, with the element's own threshold (typically highVoltage * 0.5)
  • Non-digital ChipElm subclasses (e.g. OpAmpElm) continue to use standard voltage coloring
  • No changes to wire coloring or non-logic elements

Test plan

  • Open a logic circuit (e.g. any circuit with AND/OR/NOT gates)
  • Verify pins display using normal voltage-gradient coloring by default
  • Open Other Options, enable "Color Logic Pins by State"
  • Verify HIGH pins turn the positive color (green) and LOW pins turn the neutral color (gray)
  • Verify digital chips (flip-flops, counters) also show logic-state coloring
  • Verify non-logic elements (resistors, capacitors, op-amps) are unaffected
  • Verify the setting persists across page reloads (localStorage)
  • Verify toggling the option off restores normal voltage coloring

Addresses sharpie7#369.

🤖 Generated with Claude Code

Logic gate and chip pins are colored based on whether they are
above or below the logic threshold: high pins show in the positive
color, low pins show in the neutral color. Makes signal propagation
visually traceable in logic circuits.

This is a toggleable option ("Color Logic Pins by State") in
Other Options, persisted via localStorage. When disabled (the
default), pins use the existing voltage-gradient coloring.

Affected elements: GateElm (AND, OR, XOR, NAND, NOR, XNOR),
ChipElm (all digital chips), InverterElm, TriStateElm, and
DelayBufferElm.

Addresses sharpie7#369.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pfalstad
Copy link
Copy Markdown
Owner

pfalstad commented Mar 7, 2026

why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants