A lightweight 2D raster graphics and canvas library written in C.
Warning
Kanvas is under active development. The API is unstable and may change without notice.
- Image-backed canvases
- Drawable primitives
- Alpha compositing
- PNG and PPM import/export
- Retained-mode rendering
#include <kvs/kvs.h>
int main(void)
{
kvs_canvas *canvas = kvs_canvas_create(KVS_SIZE(800, 600));
kvs_drawable *rect = kvs_drawable_rect(KVS_SIZE(200, 100));
kvs_drawable_set_color(rect, kvs_color_from_hex_rgba(0xFF000080));
kvs_canvas_add(canvas, rect, KVS_POS(100, 100));
kvs_drawable_set_color(rect, kvs_color_from_hex_rgba(0x00FF0080));
kvs_canvas_add(canvas, rect, KVS_POS(200, 150));
kvs_drawable_set_color(rect, kvs_color_from_hex_rgba(0x00FFFF80));
kvs_canvas_add(canvas, rect, KVS_POS(225, 175));
kvs_canvas_render(canvas);
kvs_image *out = kvs_canvas_export_to_image(canvas);
kvs_image_write_png(out, "output.png");
kvs_image_destroy(out);
kvs_canvas_destroy(canvas);
kvs_drawable_destroy(rect);
return 0;
}This should result in the following image:

See examples/ for more.
libpng(optional, disable withKVS_ENABLE_PNG=OFF)
makeOr manually with CMake:
cmake -B build -S .
cmake --build buildEarly development. The API is unstable and tests are still being written.
-
Image drawables- (optional) Use
state.coloras tint
- (optional) Use
-
Basic color parsing-
RGBA -
RGB -
Hexadecimal
-
-
Drawable bounding boxes -
Rasterize per drawable instead of per pixel -
Moving from LinkedList to Array for Canvas Nodes
-
Error handling
- Error messages
- Error types
- Error handling helper macros and functions
- (optional)
errnointegration
-
Add tests
- Basic tests
- Mandatory tests
- Stability tests
- ABI tests
- Additional tests
-
Add color constants
- Basic common color constants
- (optional) Additional color constants
-
Improve documentation and examples
-
Blending mode support
- Normal blending
- Additive blending
- Multiply blending
- Configurable blending
-
Clipping/scissor regions
-
Image format support
-
PNG- Add more detailed PNG metadata
- JPEG
- (optional) BMP
-
-
Introduce format-aware color representation
- Generic pixel format abstraction
- RGBA8888 support
- RGB888 support
-
Add pixel storage format support
- BGRA8888
- RGB565
- GRAY8
- Configurable pixel storage format
-
Add color space support
-
sRGB - (optional) Linear RGB
- Configurable color space
-
-
Add color model support
-
RGB - HSL
- HSV
- (optional) Grayscale
- (optional) CMYK
- Configurable color model
-
-
Drawable scaling
- Nearest scaling
- Bilinear scaling
- (optional) Bicubic scaling
- Configurable scaling
-
Text drawables
-
FreeTypeintegration -
HarfBuzzshaping
-
-
Stabilization
- Stabilize the naming convention
- Stabilize the standards
- Stabilize the codebase
- Stabilize the ABI
- (optional) Stabilize the Build System
-
Boolean drawable operations
- Union operations
- Subtract operations
- Intersection operations
- Masking operations
-
Optimizations
- Basic optimizations
- Developer experience optimizations
- Performance optimizations
- (optional) Profiling
Licensed under the Apache License 2.0.
See LICENSE.