A polished, zero-dependency 32ร32 pixel art editor โ works in any browser, deployable on GitHub Pages.
๐ Live Demo ยท Features ยท Usage ยท Development ยท License
โจ Features
- 32ร32 canvas โ the classic pixel art grid size
- 16-color palette โ black, white, red, orange, yellow, green, blue, purple, pink, brown, gray, cyan, magenta, dark green, navy, silver
- Click to paint โ left-click draws with the selected color
- Right-click to erase โ instantly sets pixels to white
- Pen size toggle โ 1px, 2px, or 4px brushes
- Fill bucket โ flood-fill algorithm (BFS) for coloring contiguous areas
- Undo โ up to 20 levels of undo history (Ctrl+Z / โ+Z)
- Clear canvas โ reset everything with one click
- Export as PNG โ downloads a clean 32ร32 PNG (no grid lines)
- Grid lines toggle โ show or hide the pixel grid
- Dark theme โ deep blue-purple background with orange accent
- Responsive โ works on desktop and mobile (touch support)
- Keyboard shortcuts โ
Ppen,Eeraser,Gfill,1/2/4pen size,Ctrl+Zundo - Zero dependencies โ single HTML file, no CDN, no build tools
- GitHub Pages ready โ just push and publish
๐ Usage
- Open
index.htmlin any modern browser. - Select a color from the palette.
- Click on the canvas to paint.
- Right-click (or use the eraser tool) to remove pixels.
- Toggle tools: Pen โ๏ธ, Eraser ๐งน, Fill ๐ชฃ.
- Adjust pen size with the 1px / 2px / 4px buttons.
- Hit Undo โฉ๏ธ to step back (up to 20 steps).
- Export your masterpiece with Export PNG ๐ฅ.
โจ๏ธ Keyboard Shortcuts
| Key | Action |
|---|---|
P |
Pen tool |
E |
Eraser tool |
G |
Fill bucket |
1 |
Pen size 1px |
2 |
Pen size 2px |
4 |
Pen size 4px |
Ctrl+Z / โ+Z |
Undo |
๐ง Architecture
flowchart LR
A[User Input] --> B{Input Type}
B -->|Mouse Click| C[getCanvasCoords]
B -->|Touch Event| C
B -->|Keyboard| D[onKeyDown]
C --> E[gridX, gridY]
E --> F{Current Tool}
F -->|Pen| G[Paint: set pixel to currentColor]
F -->|Eraser| H[Erase: set pixel to white]
F -->|Fill| I[Flood Fill BFS]
G --> J[render canvas]
H --> J
I --> J
D --> K{Shortcut}
K -->|P/E/G| L[setTool]
K -->|1/2/4| M[setPenSize]
K -->|Ctrl+Z| N[undo]
J --> O[ctx.clearRect]
O --> P[Loop: fillRect per pixel]
P --> Q[Optional: draw grid lines]
N --> R[Restore snapshot from undoStack]
R --> J
S[Export PNG] --> T[Create 32ร32 offscreen canvas]
T --> U[fillRect each pixel at 1ร1]
U --> V[canvas.toDataURL -> download link]
๐ Project Structure
pixel-art/
โโโ index.html โ Self-contained editor (HTML + CSS + JS)
โโโ README.md โ This file
โโโ LICENSE โ MIT
๐ ๏ธ Development
This is a single HTML file with everything inlined. No build step required.
# Clone the repository git clone https://github.com/soumendrak/pixel-art.git cd pixel-art # Open locally open index.html # or: xdg-open index.html # or: python3 -m http.server 8000 # then visit http://localhost:8000
Making changes
All the code lives in index.html:
- CSS โ in the
<style>block (dark theme, responsive layout) - JavaScript โ in the
<script>block (drawing engine, flood fill, undo system, event handling) - HTML โ semantic layout with ARIA-friendly controls
๐ Deployment to GitHub Pages
- Push this repository to GitHub.
- Go to Settings > Pages.
- Select the
mainbranch as the source. - Your editor will be live at
https://soumendrak.github.io/pixel-art/.
๐ License
MIT ยฉ 2026 โ See LICENSE for details.
Made with ๐งก โ zero frameworks, infinite pixels.