A robust, feature-rich drawing application built entirely with p5.js and vanilla JavaScript. This application offers a desktop-class drawing experience directly in the browser with state retention, history management, and a wide array of creative tools.
- Essential Tools: Freehand, Line, Eraser, and Text input.
- Shapes: Draw perfect Squares, Ellipses, Diamonds, and generic Polygons.
- Artistic Brushes:
- Spray Can: For airbrush-style effects.
- Rainbow Brush: Dynamic multi-colored strokes.
- Angle Brush: Calligraphy-style directional strokes.
- Mirror Draw: Symmetrical drawing for mandala-like creations.
- Utility: Highlighters, Laser pointers, and Image insertion.
- Retained Mode Rendering: All elements are stored as objects, allowing for complex manipulation and re-rendering.
- Infinite Panning: Navigate large canvases easily using the middle mouse button.
- Selection & Edit: Select individual elements to move or delete them.
- History System: Robust Undo/Redo (
Ctrl+Z,Ctrl+Y) functionality with deep state snapshots. - Persistence: Your work and tool settings (brush size, color) are automatically saved to
localStorageand restored when you return. - Export: Save your masterpiece instantly as a JPG image.
- Tool Options: Dynamic settings menu for tool-specific configurations (e.g., brush size).
- Color Palettes: Extensive foreground and background color pickers.
- Render Engine: p5.js (Canvas manipulation)
- Core Logic: Vanilla JavaScript (ES6+)
- DOM Manipulation: p5.dom.js & jQuery
- Styling: CSS3 with modern variables and flexbox layouts
/
├── index.html # Entry point and UI structure
├── sketch.js # Main p5.js setup/draw loop and global state
├── toolbox.js # Manager for tool selection and lifecycle
├── history.js # Undo/Redo stack implementation
├── helperFunctions.js # Utility helpers (save, clear, events)
├── tools/ # Individual tool implementations (Freehand, Shapes, etc.)
└── styles/ # Application styling
- Left Click: Draw / Use Tool
- Middle Click (Drag): Pan the Canvas
- Ctrl + Z: Undo
- Ctrl + Y: Redo
- Del: Delete selected element
- Clone this repository.
- Open
index.htmlin your web browser.- Note: For the best experience (and to avoid CORS issues with local images), it is recommended to run this using a local server like Live Server in VS Code or
http-servervia npm.
- Note: For the best experience (and to avoid CORS issues with local images), it is recommended to run this using a local server like Live Server in VS Code or


