A modern React web application for visualizing and understanding classic computer graphics algorithms with interactive step-through animation and algorithm decision parameters.
View the live application here
- DDA Line Drawing: Digital Differential Analyzer algorithm with decision parameter visualization
- Bresenham Line Drawing: Efficient integer-only line rasterization with error term tracking
- Midpoint Circle Drawing: Efficient circle rasterization algorithm with decision parameter tracking
- Coordinate System: Mathematical coordinate system with proper X/Y axes and labels
- Zoom & Pan:
- Mouse wheel to zoom (0.5x - 3x range, default 1.5x)
- Click and drag to pan the canvas
- Reset view button to return to default centered view
- Animation Controls:
- Play/Pause animation
- Previous/Next buttons for step-through execution
- Real-time step counter and position display
- Decision Parameter Display: For each step, view the calculated decision parameter and the algorithm's decision
- Overlay of ideal mathematical shape (50% opacity) vs. rasterized approximation
- Coordinate labels on each plotted point
- Negative coordinate support (-20 to +20 range)
- Detailed info box showing:
- Total points generated
- Current step number
- Current pixel position (x, y)
- Decision parameter value
- Decision made at this step
- Frontend: React 18, CSS3
- Styling: Custom CSS with Green, Black, and White theme
graphics-simulator/
├── client/ # React frontend
│ ├── public/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── services/ # Algorithm implementations
│ │ ├── styles/ # CSS stylesheets
│ │ ├── App.js
│ │ └── index.js
│ └── package.json
└── package.json
- Node.js (v16 or higher)
- npm or yarn
- Install dependencies:
npm install
cd client && npm installStart the frontend:
npm startOpens at http://localhost:3000
npm run build- Open the application at
http://localhost:3000 - Select an algorithm from the available cards (DDA, Bresenham, or Midpoint Circle)
- Adjust input parameters:
- Line algorithms: Start point (x0, y0) and end point (x1, y1)
- Circle algorithm: Center point (centerX, centerY) and radius
- Range: -20 to +20 for coordinates, 1 to 150 for radius
- Click "Execute Algorithm" to run the algorithm and generate rasterized points
- Use the visualization controls:
- Mouse wheel: Zoom in/out
- Click and drag: Pan the canvas
- Reset View button: Return to centered default view
- Use animation controls to step through:
- Play: Auto-animate through all points
- Pause: Stop the animation
- Previous: Go to previous point
- Next: Go to next point
- Monitor the info box to see:
- Current step and total points
- Pixel coordinates
- Decision parameter and decision logic for each step
Each algorithm displays its decision-making process:
- DDA: Shows the fractional part of coordinates and rounding decision
- Bresenham: Displays the error term and movement decision (Move X, Move Y, or Move X and Y)
- Midpoint Circle: Shows the decision parameter and whether to decrease X or increase Y
- Primary Green: #10b981
- Dark Green: #059669
- Black: #1f2937
- White: #ffffff
- Light Gray: #f3f4f6
MIT License