ra4king / CircuitSim

Basic Circuit Simulator
https://ra4king.github.io/CircuitSim
BSD 3-Clause "New" or "Revised" License
76 stars 27 forks source link

Draw fake wires between port and gate when one input is bubbled #80

Closed ausbin closed 1 year ago

ausbin commented 1 year ago

Some work at addressing #79. This draws a fake wire to avoids dead space between port and gate that confused students in lecture today.

Not perfect, since this can cause some weird situations as shown at the very bottom below:

image

ausbin commented 1 year ago

Also, with OR gates you have the fake wire dangling off particularly noticably:

image

Pulkit suggested fixing the last example above in the original post by drawing a line like this:

image

Hmm...

ausbin commented 1 year ago

I'm curious what you think of this, Roi (and @pulkitgupta1217). This is what I have:

image

The left is not perfect because a student might think the black line is a wire. Moving the line over 3 pixels (half the width of a port) helps, but it looks really weird on an AND gate, almost like an optical illusion:

image

pulkitgupta1217 commented 1 year ago

I'm wondering if the tile can always be 1 unit wider than the symbol as is what happens whenever you bubble a port (right side of figure 1 in the previous comment). This way, theres never any ambiguity regarding whether there is just a line or a wire connecting other points. (As I understand, this would change the size of non-bubbled gates and thus re-introduce the issue of breaking existing circuits)

Secondly, to help curb confusions, the visual lines connecting the dot (port) to either the gate body or the bar line (vertical in graphics) can be black and thin like the bar-line itself. This way wires terminate at nodes. (I know this is not what I suggested in the issue, but I think after seeing how it looks when done out for wide gates, having colored wires pass through nodes isn't very neat)

ra4king commented 1 year ago

I played around with this and I would like to propose a middle ground between @pulkitgupta1217's and @ausbin's proposals.

Because making this width change could break older save files, we'll need to introduce this "legacy" mode via version checking and a hidden property. I chose the limit of 5 because that's how many inputs comfortably fit on the side of a gate today.

@ausbin your current PR is fine as is, I can make the additional changes myself in a follow-up commit (since I've already made them locally :) )