-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented rendering for OrGate #1237
Conversation
rren8957
commented
Mar 23, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const p1 = this.p1; | ||
const p2 = this.p2; | ||
const c = this.c; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's changed this to const { p1, p2, c } = this;
-- more succinct !
@@ -24,6 +25,7 @@ export class DigitalCircuitView extends CircuitView { | |||
if (!this.assemblers) { | |||
this.assemblers = { | |||
"ANDGate": new ANDGateAssembler(this.circuit, this, this.selections, this.sim), | |||
"ORGate": new ORGateAssembler(this.circuit, this, this.selections, this.sim), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: put an extra space before the new
so that it's vertically aligned with the others
import {SelectionsManager} from "core/internal/impl/SelectionsManager"; | ||
import {CircuitView} from "core/internal/view/CircuitView"; | ||
import {PortAssembler} from "core/internal/view/PortAssembler"; | ||
import {QuadCurve} from "core/internal/view/rendering/prims/QuadCurve"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing
import {DigitalComponentInfo} from "digital/internal/DigitalComponents"; | ||
import {DigitalSim} from "digital/internal/sim/DigitalSim"; | ||
import {Assembler} from "core/internal/view/Assembler"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: need 2 blank lines between imports and code
const transform = this.view.componentTransforms.get(gate.id)!; | ||
|
||
const selected = this.selections.has(gate.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can put these outside of the loop since they don't depend on i
…rcuits/OpenCircuits into renr_ORGateRendering
…rcuits/OpenCircuits into renr_ORGateRendering
It's always rendered blurrily on my end for some reason so I could have missed some other visual issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ANDGate": new ANDGateAssembler(this.circuit, this, this.selections, this.sim), | ||
"ORGate": new ORGateAssembler(this.circuit, this, this.selections, this.sim), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please re-order the assemblers as they were
"outputs": () => ({ origin: V(0.5, 0), dir: V(1.1, 0) }), | ||
"inputs": (index, total) => { | ||
const spacing = 0.5 - this.options.defaultBorderWidth/2; | ||
return { origin: V(-0.43, spacing*((total-1)/2 - index)), dir: V(-1.3, 0), stroke: {color: "black", size: 1, lineCap: "round"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Format on multiple lines please, like:
return {
origin: V(...),
dir: V(...),
stroke: {...}
};
}, | ||
}); | ||
|
||
this.portAssemblerV2 = new PortAssembler(circuit, view, selections, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the old code for all the math for the positioners, it shouldnt be this complicated, and you shouldn't need two different ones
|
||
const c = V(-l, d); | ||
|
||
if (numInputs <= 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary ?
} | ||
|
||
const numInputs = this.getNumInputs(gate); | ||
if (numInputs % 2 === 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need two positioners, you can use total
in the positioner to check if it's even or odd and return a different position based on that
Fixed visual issues for input port of size 7 and 8. I didn't exactly used the old code but I did simplify the code to only have 1 positioner/portAssembler.
…OpenCircuits into renr_ORGateRendering