A powerful, browser-based infinite canvas application built with Next.js that allows you to draw, create shapes, add text, and images on an unlimited creative workspace.
- Pen Tool: Freehand drawing with customizable colors and stroke widths
- Shapes: Rectangle, Circle, Line, and Arrow tools
- Text Tool: Add text annotations anywhere on the canvas
- Image Upload: Import and place images on your canvas
- Infinite Canvas: Pan and zoom to create unlimited workspace
- Pan: Shift + drag or use the Select tool to navigate
- Zoom: Scroll to zoom in and out
- Grid: Visual grid for alignment and reference
- Color Picker: 10 preset colors plus custom color selector
- Stroke Width: 5 different stroke width options (1px to 8px)
- Real-time Preview: See your drawings as you create them
- Undo/Redo: Full history support with Ctrl+Z / Ctrl+Y shortcuts
- Local Storage: Automatically saves your work in browser storage
- Persistent State: Canvas state persists across browser sessions
- Clear Canvas: Reset your workspace with a single click
v- Select/Pan toolp- Pen toolr- Rectangle toolc- Circle tooll- Line toola- Arrow toolt- Text toolCtrl+Z/Cmd+Z- UndoCtrl+Y/Cmd+Y- RedoShift+Drag- Pan canvasScroll- Zoom in/out
- Node.js 18.x or higher
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd infinite-canvas- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
npm run build
npm start- Next.js 16: React framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS: Utility-first styling
- HTML5 Canvas API: High-performance drawing
- Local Storage API: Client-side data persistence
infinite-canvas/
├── app/
│ ├── components/
│ │ ├── InfiniteCanvas.tsx # Main canvas component
│ │ └── Toolbar.tsx # Tool selection UI
│ ├── types.ts # TypeScript type definitions
│ ├── page.tsx # Main application page
│ └── layout.tsx # Root layout
├── public/ # Static assets
└── package.json # Dependencies
The app uses a custom element system where each drawing (path, shape, text, image) is stored as a typed object. This allows for:
- Easy serialization to localStorage
- Efficient undo/redo operations
- Future extensibility for features like selection and editing
The infinite canvas is implemented using viewport transformations:
- Pan: Translate the viewport origin
- Zoom: Scale the viewport
- All elements are drawn relative to the viewport for smooth performance
- React hooks for UI state
- localStorage for persistence
- History array for undo/redo functionality
Works best in modern browsers:
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
Potential features for future development:
- Element selection and editing
- Multi-select and group operations
- Copy/paste functionality
- Export to PNG/SVG/PDF
- Collaborative editing
- More shape types
- Layers system
- Touch/stylus support optimization
MIT
Contributions are welcome! Please feel free to submit issues or pull requests.