interactive 2D vector graphics protocol

ctx is an interactive 2D vector graphics protocol, providing remote backends and process multiplexing integrated with a terminal emulator/window manager; providing an end-to-end vector rendering framework suitable for serial links. It aims for rendering quality and performance with minimal footprint and resource usage, suitable for bare-metal use on 32bit microcontrollers without additional dependencies and scaling to handling PDF, floating point buffer, CMYK and multi-threaded rendering. The core drawing, event handling and rendering APIs are stable, and many features can be reduced or dropped when targeting resource limited microcontroller. Demo UIs experiments and tests are included in the git monorepo.

The ctx rasterizer is fast, portable and compact with a wide range of supported pixel encodings from 1bit to 32bit per pixel, in grayscale, RGB and CMYK. For microcontrollers using C or micropython. ctx renders to lower bitdepth RGB332, RGB565 variants as well as 1,2 and 4 bit per pixel grayscale is handled. Combined with floating point pixel encoding support and color management ctx scales to meet GEGL and GIMPs needs.

ctx provides abstractions for event injection and dispatch. It provides hit-detection, this allows abstracting over multiple input devices/buttons with a mouste+keyboard abstraction. In the event method callback both absolute and local (At time of callback registration) coordinates are provided.

The same API can also be used for writing applications that run inside the ctx terminal, which provides escape sequences that enable drawing 2D vector graphics both inline, and for full-window applications taking over the terminal using the ctx protocol, or even on webpages using webassembly, for now single threaded - and without the potential acceleration through reuse of the rasterizer of the HTML5 Canvas.

The ctx renderer is written in portable C, without inline assembly or SIMD intrinsics - but is still fast (and can make good use of cpu capabilities known by the C compiler, thus making the same code work across x86 32 and 64bit, ARM on MCUs and SBCs, tensilica, RISC-V and other compilers with a modern toolchain. The single threaded rendering performance rendering performance is often better than engines with more dedicated/manual SIMD handling.

Below is ctx compiled to WASM with emscripten (without SIMD support). Operating on a 640x480 canvas.

license and funding

ctx is available under LGPLv3+ you can encourage continued development of ctx and dissimilar technologies by financially supporting me, Øyvind Kolås who is doing independent pro-bono R&D through patreon and similar. If my income through such sources is above 4000USD per month for a year, or if someone does a one time payment of the equivalent amount for the time I invested in ctx over the last few years, ctx could become available under under the ISC license.