GitHub

A polished, zero-dependency 32ร—32 pixel art editor โ€” works in any browser, deployable on GitHub Pages.

MIT License Build Zero Dependencies PRs Welcome

๐ŸŒ 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 โ€” P pen, E eraser, G fill, 1/2/4 pen size, Ctrl+Z undo
  • Zero dependencies โ€” single HTML file, no CDN, no build tools
  • GitHub Pages ready โ€” just push and publish

๐Ÿš€ Usage

  1. Open index.html in any modern browser.
  2. Select a color from the palette.
  3. Click on the canvas to paint.
  4. Right-click (or use the eraser tool) to remove pixels.
  5. Toggle tools: Pen โœ๏ธ, Eraser ๐Ÿงน, Fill ๐Ÿชฃ.
  6. Adjust pen size with the 1px / 2px / 4px buttons.
  7. Hit Undo โ†ฉ๏ธ to step back (up to 20 steps).
  8. 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]
Loading

๐Ÿ“ 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

  1. Push this repository to GitHub.
  2. Go to Settings > Pages.
  3. Select the main branch as the source.
  4. 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.

Read the original on github.com โ†—