tsoding/olive.c
FreeSimple 2D Graphics Library for C
FreeFree tier
About tsoding/olive.c
Olive.c is a simple, dependency-free 2D graphics library for C that renders pixels into a user-provided memory buffer. It is a single-header, stb-style library that works by simply copying the olive.c file into your project. The library provides basic drawing primitives such as fills and circles, and is designed for low-level pixel manipulation. It does not handle display; users must output the pixels (e.g., to a PNG file via stb_image_write or display via SDL, terminal ASCII art, or WebAssembly). The name is pronounced 'olivets' and is Ukrainian for 'pencil'. Note: the library is a work in progress and may change without notice.
Key Features
No external dependencies – renders pixel-by-pixel into a memory buffer
Single-header library (stb-style): copy-paste olive.c and #include it
Supports multiple output platforms via demos: SDL, terminal ASCII art, and WebAssembly (WASM)
Provides basic drawing primitives (fill, circle) with alpha blending
Works with stb_image_write to export PNG images
Open source with permissive license (MIT implied)
Pros & Cons
Pros
- No dependencies – extremely easy to integrate into any C project
- Simple and lightweight codebase
- Open source with permissive license
- Multiple demo output platforms (SDL, terminal, WASM) help get started quickly
- Transparent pixel handling with alpha blending functions
Cons
- Work in progress – API may change without notice
- No built-in display – requires additional code to show or save the image
- Alpha channel must be initialized carefully to avoid transparent results
- Limited high-level features compared to full-fledged graphics libraries
Best For
Creating 2D graphics and images programmatically in CEducational projects for learning low-level graphics programmingPrototyping simple games or visualizationsGenerating pixel-based art or flags (e.g., Flag of Japan example)
FAQ
How do I integrate olive.c into my project?
Simply copy the olive.c file into your project and #include it. To use the implementation, define OLIVEC_IMPLEMENTATION before inclusion in exactly one source file.
Does olive.c handle displaying the image?
No, the library only fills a pixel memory buffer. You are responsible for displaying or saving the pixels (e.g., using SDL, terminal ASCII art, or writing to a PNG file via stb_image_write).
What does the name 'olive.c' mean?
It is pronounced 'olivets' and is Ukrainian for 'pencil' (олівець).