An interactive logic gate simulator built with TypeScript and PixiJS. Design, visualize, and simulate digital logic circuits directly in your browser.
Logic Gate Simulator is a web-based application that allows you to build and simulate digital logic circuits. It provides an intuitive drag-and-drop interface for placing logic gates, switches, bulbs, and wires on an infinite canvas. The simulation runs in real-time, allowing you to see how signals propagate through your circuit.
- Logic Gates: AND, OR, NOT, NAND, NOR, XOR, XNOR, and BUFFER gates
- Input/Output Components: Switches (toggleable inputs) and Bulbs (visual outputs)
- Clock Signal: Built-in clock component with adjustable tick rate
- Wire Connections: Connect components with wires to create circuits
- Real-time Simulation: Watch your circuit operate in real-time
- Pan & Zoom: Navigate large circuits with an infinite canvas
- Selection Tools: Select, copy, paste, and delete components
- Import/Export: Save and load your circuit designs
- Rotation: Rotate gates to fit your circuit layout
- Node.js (v18 or higher recommended)
- npm (comes with Node.js)
-
Clone the repository:
git clone https://github.com/baitato/Logic-Gate-Simulator.git cd Logic-Gate-Simulator -
Install dependencies:
npm install
Start the development server with hot reload:
npm run devor
npm startThe application will be available at http://localhost:5173 (or the next available port).
Build the application for production:
npm run buildPreview the production build:
npm run previewnpm run deploy- Place Components: Select a component from the toolbox on the left side and click on the canvas to place it
- Connect Components: Click on connection points to create wires between components
- Toggle Switches: Click on switches to toggle their state (ON/OFF)
- Rotate Gates: Use the rotation widget to orient gates as needed
- Pan Canvas: Click and drag on empty space to pan the view
- Zoom: Use the scroll wheel to zoom in/out
- Select Components: Click and drag to create a selection box
- Copy/Paste: Use Ctrl+C and Ctrl+V to copy and paste selected components
- Delete: Select components and press Delete to remove them
- Import/Export: Use the import/export tools to save and load circuits
- TypeScript - Type-safe JavaScript
- PixiJS - 2D WebGL renderer for high-performance graphics
- pixi-viewport - Pan and zoom functionality
- @pixi/ui - UI components (ScrollBox)
- Vite - Fast build tool and development server
src/
├── main.ts # Application entry point
├── core/ # Core application modules
│ ├── AppInitializer.ts # Initialization phases
│ ├── ApplicationWrapper.ts
│ ├── Grid.ts # Canvas grid
│ ├── ViewportWrapper.ts # Pan/zoom viewport
│ └── simulator/ # Simulation engine
├── models/ # Component models
│ ├── logic-gate/ # Gate implementations
│ ├── Bulb.ts
│ ├── Switch.ts
│ ├── Wire.ts
│ └── ...
├── services/ # Application services
│ ├── ConnectionService.ts
│ ├── CopyPasteService.ts
│ ├── PlacementService.ts
│ └── ...
├── tools/ # Toolbox and tools
├── enums/ # TypeScript enums
├── types/ # TypeScript type definitions
└── utils/ # Utility functions
Try the simulator online: https://baitato.github.io/Logic-Gate-Simulator/
This project is licensed under the MIT License.
Contributions, issues, and feature requests are welcome!