An interactive computer graphics algorithm visualization platform for students and educators.
Visualize DDA, Bresenham, circle drawing, polygon filling, and line/polygon clipping β pixel by pixel on a 60Γ60 interactive grid.
Features β’ Algorithms β’ Tech Stack β’ Structure β’ Setup β’ Usage
- Precise pixel-level rendering with coordinate tooltips
- Zoom, pan, and color-coded visual legends
- Real-time canvas updates as algorithms execute
- Play / Pause / Step controls for algorithm animation
- Adjustable speed slider for playback rate
- Decision-point highlighting at each algorithmic step
- Full-featured code editor powered by Monaco (same engine as VS Code)
- Write custom rendering code using the
fillPixel(x, y, color)API - Syntax highlighting, auto-completion, and dark theme
| Role | Capabilities |
|---|---|
| Student | Access shared lessons, step through visualizations, run code in Monaco Editor |
| Educator | Create algorithm presets or code lessons, preview output, share via link, track views |
- Educators create lessons (algorithm presets or custom code)
- Each lesson generates a unique shareable link (
/lesson/:uuid) - Students open the link and see the algorithm or code visualized instantly
- View count tracking for each lesson
- JWT-based authentication with secure password hashing (bcrypt)
- Protected routes with role-based access control
- Persistent login via
localStorage
| Category | Algorithm | Description |
|---|---|---|
| π£ Line Drawing | DDA Line Algorithm | Digital Differential Analyzer for line rasterization |
| Bresenham's Line Algorithm | Integer-only efficient line drawing | |
| π΅ Circle | Midpoint Circle Algorithm | Efficient circle rasterization using midpoint decisions |
| π‘ Polygon Fill | Scanline Fill | Edge-table-based polygon fill using horizontal scanlines |
| Flood Fill (BFS) | Breadth-first region fill from a seed point | |
| Boundary Fill | Recursive boundary-constrained fill algorithm | |
| π’ Clipping | Cohen-Sutherland | Region-code-based line clipping |
| Liang-Barsky | Parametric line clipping algorithm | |
| Sutherland-Hodgman | Polygon clipping against a rectangular window |
| Technology | Purpose |
|---|---|
| React 19 | UI component framework |
| Vite 7 | Fast dev server & build tool |
| React Router 7 | Client-side routing |
| Axios | HTTP client for API calls |
| Monaco Editor | In-browser code editor |
| Zustand | Lightweight state management |
| Tailwind CSS 4 | Utility-first CSS framework |
| Technology | Purpose |
|---|---|
| Express 5 | HTTP server framework |
| MySQL 2 | Relational database driver |
| JSON Web Tokens | Stateless authentication |
| bcryptjs | Password hashing |
| UUID | Unique lesson identifiers |
| dotenv | Environment configuration |
| Nodemon | Dev auto-restart |
Graphics Visualizer/
βββ Client/ # React frontend (Vite)
β βββ src/
β β βββ algorithms/ # 9 CG algorithm implementations
β β β βββ dda.js # DDA Line
β β β βββ bresenham.js # Bresenham Line
β β β βββ midpointCircle.js # Midpoint Circle
β β β βββ scanlineFill.js # Scanline Polygon Fill
β β β βββ floodFill.js # Flood Fill (BFS)
β β β βββ boundaryFill.js # Boundary Fill
β β β βββ cohenSutherland.js # Cohen-Sutherland Clipping
β β β βββ liangBarsky.js # Liang-Barsky Clipping
β β β βββ sutherlandHodgman.js # Sutherland-Hodgman Clipping
β β βββ api/ # API client layer
β β β βββ axiosClient.js # Configured Axios instance
β β β βββ authApi.js # Auth endpoints (signup/login)
β β β βββ lessonApi.js # Lesson CRUD endpoints
β β βββ components/ # Reusable UI components
β β β βββ CanvasGrid.jsx # 60Γ60 pixel grid canvas
β β β βββ CodeEditor.jsx # Monaco code editor wrapper
β β β βββ ControlPanel.jsx # Algorithm controls & playback
β β β βββ ProtectedRoute.jsx # Role-based route guard
β β β βββ nav/ # Navigation bars
β β βββ pages/ # Page-level components
β β β βββ LandingPage.jsx # Public landing page
β β β βββ LoginPage.jsx # Login form
β β β βββ SignupPage.jsx # Signup form with role select
β β β βββ Home.jsx # Student visualizer page
β β β βββ Dashboard.jsx # Educator lesson dashboard
β β βββ App.jsx # Router configuration
β β βββ main.jsx # App entry point
β β βββ index.css # Global styles & design tokens
β βββ package.json
β
βββ Server/ # Express backend
β βββ src/
β β βββ config/
β β β βββ db.js # MySQL connection pool
β β βββ controllers/
β β β βββ auth.controller.js # Signup & login logic
β β β βββ lesson.controller.js # Lesson CRUD logic
β β βββ routes/
β β βββ auth.routes.js # /api/auth/* routes
β β βββ lesson.routes.js # /api/lessons/* routes
β βββ server.js # Express app entry point
β βββ .env # Environment variables
β βββ package.json
β
βββ .gitignore
- Node.js β₯ 18
- MySQL β₯ 8.0
- npm or yarn
git clone https://github.com/AshisChetia/Graphics_visualizer.git
cd Graphics_visualizerOpen MySQL and create the database and tables:
CREATE DATABASE IF NOT EXISTS graphics_visualizer;
USE graphics_visualizer;
-- Users table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('student', 'educator') DEFAULT 'student',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Lessons table
CREATE TABLE lessons (
id VARCHAR(36) PRIMARY KEY,
type VARCHAR(50) NOT NULL DEFAULT 'algorithm',
algorithm VARCHAR(100),
params JSON,
code TEXT,
title VARCHAR(255),
created_by VARCHAR(255),
view_count INT DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);Create a .env file inside the Server/ directory:
PORT=5000
JWT_SECRET=your_jwt_secret_key_here
# Database
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=graphics_visualizer# Install server dependencies
cd Server
npm install
# Install client dependencies
cd ../Client
npm installOpen two terminals:
# Terminal 1 β Start the backend
cd Server
npm run dev# Terminal 2 β Start the frontend
cd Client
npm run devThe app will be running at:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Sign up with the "Student" role
- Navigate to the Visualizer page
- Select an algorithm, configure parameters, and click Generate
- Use Play, Pause, Step, and Reset controls to animate
- Switch to the Code Editor tab to write custom pixel code
- Open shared lesson links from your educator to explore pre-made demos
- Sign up with the "Educator" role
- Navigate to the Dashboard
- Create a new lesson:
- Choose Algorithm Preset β select algorithm + parameters
- Or choose Code Lesson β write custom
fillPixel()code
- Click Preview to see the output before sharing
- Click Create & Get Shareable Link
- Copy the generated link and share it with students
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/signup |
Register a new user |
POST |
/api/auth/login |
Authenticate and get JWT token |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/lessons |
Get all lessons |
POST |
/api/lessons |
Create a new lesson |
GET |
/api/lessons/:uuid |
Get a specific lesson by UUID |
DELETE |
/api/lessons/:uuid |
Delete a lesson |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/health |
Check database connectivity |
This project is licensed under the ISC License.
Made with β€οΈ by Ashis Chetia