refactor: modularize into ES6 modules
Split monolithic index.html into: - js/constants.js - gate config, colors, dimensions - js/state.js - shared application state - js/gates.js - evaluation logic, port geometry - js/renderer.js - canvas drawing - js/waveform.js - GTKWave-style signal viewer - js/simulation.js - clock tick engine - js/events.js - mouse, keyboard, UI handlers - js/app.js - entry point - css/style.css - all styles
This commit is contained in:
32
js/state.js
Normal file
32
js/state.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// Shared application state — single source of truth
|
||||
export const state = {
|
||||
// Circuit
|
||||
gates: [],
|
||||
connections: [],
|
||||
nextId: 1,
|
||||
|
||||
// Interaction
|
||||
placingGate: null,
|
||||
dragging: null,
|
||||
dragOffset: { x: 0, y: 0 },
|
||||
connecting: null,
|
||||
hoveredGate: null,
|
||||
hoveredPort: null,
|
||||
mouseX: 0,
|
||||
mouseY: 0,
|
||||
|
||||
// Waveform
|
||||
waveformVisible: false,
|
||||
waveformHeight: 220,
|
||||
recording: true,
|
||||
waveData: {}, // { gateId: [{ t, value }] }
|
||||
timeStep: 0,
|
||||
waveZoom: 20, // pixels per time step
|
||||
waveScroll: 0,
|
||||
resizingWave: false,
|
||||
|
||||
// Simulation
|
||||
simRunning: false,
|
||||
simInterval: null,
|
||||
simSpeed: 500 // ms per tick
|
||||
};
|
||||
Reference in New Issue
Block a user