Skip to content

About

A lightweight pixel art editor built with C++17 and SDL2

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

TinyCanvas

screenshot

Build C++ SDL2 CMake License

A lightweight pixel art editor built with C++17 and SDL2.

Build

Prerequisites

  • CMake 3.16+
  • C++17 compiler (GCC 7+, Clang 5+, MSVC 2017+)
  • SDL2 2.0.5+

Install SDL2

macOS

brew install sdl2

Ubuntu/Debian

sudo apt update
sudo apt install libsdl2-dev

Arch Linux

sudo pacman -S sdl2

Windows

vcpkg install sdl2:x64-windows

Compile & Run

cd pixel-art-editor
mkdir build && cd build
cmake ..
make -j
./TinyCanvas

# Custom canvas size
./TinyCanvas 64 64

Controls

Drawing Tools

Key Tool Description
P Pencil Freehand pixel drawing
E Eraser Remove pixels with background color
L Line Draw straight lines between two points
R Rectangle Draw rectangular outlines
C Circle Draw circular outlines from center
F Fill Flood fill connected regions
I Color Picker Sample color from canvas

View & Navigation

Input Action
Scroll Wheel Zoom in/out (1x - 128x)
Middle-Click Drag Pan canvas (works anywhere)
Right-Click Drag Pan canvas (on canvas area)
Space or Cmd/Ctrl+0 Fit canvas to view
+ / = Zoom in
- Zoom out
G Toggle pixel grid overlay
F11 or Cmd/Ctrl+Enter Toggle fullscreen

Color & Editing

Input Action
Left-Click Palette Set foreground color
Right-Click Palette Set background color
X Swap foreground/background colors
Left-Click Canvas Draw/apply tool with foreground color

File Operations

Keys Action
Cmd/Ctrl + S Save as BMP (artwork.bmp)
Cmd/Ctrl + O Load BMP file
Cmd/Ctrl + N Clear canvas (new artwork)

History

Keys Action
Cmd/Ctrl + Z Undo (up to 100 steps)
Cmd/Ctrl + Shift + Z Redo

Advanced Usage

Custom Canvas Size

Launch with specific dimensions:

./TinyCanvas 128 64    # 128x64 canvas
./TinyCanvas 16 16     # Tiny 16x16 icon

File Format

  • Export: Saves to artwork.bmp in current directory
  • Import: Loads any BMP file and resizes canvas to match
  • Format: Standard Windows BMP (RGBA32) with alpha channel

Performance

  • 60 FPS rendering with VSync
  • Efficient flood fill with BFS and bounds checking
  • Delta time compensation for consistent zoom/pan
  • Full undo history under 10MB for typical canvases

Project Structure

pixel-art-editor/
├── src/
│   ├── main.cpp          # Entry point
│   ├── editor.h/cpp      # Main editor logic & rendering
│   ├── canvas.h/cpp      # Canvas operations & drawing algorithms
│   ├── types.h           # Core structs (Color, Point, Tool enum)
│   └── font.h            # 5x7 bitmap font for UI text
├── CMakeLists.txt        # Build configuration
├── .gitignore            # Git ignore rules
└── README.md

Building from Source

Debug Build

cmake -DCMAKE_BUILD_TYPE=Debug ..
make

Release Build (Optimized)

cmake -DCMAKE_BUILD_TYPE=Release ..
make
./TinyCanvas

Clean Build

rm -rf build/
mkdir build && cd build
cmake ..
make

Troubleshooting

SDL2 Not Found

If CMake cannot find SDL2, ensure it's installed and pkg-config can locate it:

pkg-config --modversion sdl2

About

A lightweight pixel art editor built with C++17 and SDL2

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages