aldrin

👩‍🦰 Aldrin

Simple 2D Computer Graphics Library in C.

It stores some color codes of pixels in memory (called canvas here) and you are free to use this pixels wherever you want. You can write the pixels to .ppm file or build .c code to .wasm and display the pixels on JavaScript Canvas. Keep reading to see examples on both platforms.

Visit orhanemree/aldrin.js to WebAssembly version.

Visit orhanemree/aldrin.py to Python wrapper.

Visit Playground to try online.

Visit Editor to try online editor project made with Aldrin.

Quick Start

Hello, World! of Pixels

#include <stdint.h>
#include "src/aldrin.c"

#define WIDTH 160
#define HEIGHT 90

static uint32_t pixels[WIDTH*HEIGHT];

int main() {
    Aldrin_Canvas ac = { pixels, WIDTH, HEIGHT };
    aldrin_fill(ac, 0xff00ff);
    aldrin_save_ppm(ac, "img/hello_world.ppm");
    return 0;
}

Output should look something like this:

Note that: aldrin_save_ppm() function generates .ppm output (see /img/hello_world.ppm). The output converted to .png format to be displayed here.

Build

Examples

Running Tests

Documentation

References

License