portable and performant 2D vector graphics

ctx is fast and portable 32bit C code (it builds and works on 64bit as well), with code paths that are well suited for auto-vectorization by compilers, and use minimal amounts of resources - making it suitable for microcontrollers.
x86-64
Runtime choice of 3 different levels of SIMD support.
arm32
both mcu and cpu's tested on rp2040
tensilica
tested on esp32 and esp32s3
riscv
tested on esp32c3
wasm
built with emscripten
?
if it is a 32bit or 64bit arch; with a C compiler it probably works.
While still being small optional features can be built in like PDF, floating point buffer, CMYK and multi-threaded rendering with automatic partial redraws. The core drawing, event handling and rendering APIs are stable. Demo UIs experiments and tests are included in the git monorepo. The most elaborate test is s0il a graphical UNIX like OS for microcontrollers, with interpreted userland. and Petal Hero for the flow3r badge/instrument.

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.

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.

The interactive backends of ctx are tailored towards low latency rendering of UIs where only a part of the screen changes, like editing text in a terminal or changing the hover state of a button. Ctx records the drawing commands to draw a frame, and before starting to draw computes a hash for a 6x5 grid dividing the buffer being rendered to. Horizontal chunks of tiles with new hashes compared to the previous frame are then scheduled for rendering on threads.

The ctx API still isn't fully covered by the rasterizer, in this feature comparison matrix, the protocol and rasterizer are separate columns.

.ctx-protocolctxcairoskiablend2d
GPU rendering-NNYN
change extent detection-YNNN
CMYK output-YNNN
float output-YNNN
rgb565 output-YYNN
threaded rendering-YNNY
event-handling-Y---
drop-shadowYNNYN
pcm-audio-Y---
PDF-PYN?
stroke-dashYYYYN
stroke-join-miterYNYYY
stroke-end-squareYPYYY
stroke-join-roundYYYYY
stroke-end-roundYYYYY
clippingYYYYN
compositing-groupsYPYYN
blending-modesYPYYY
textYYYYY
perspective-transform texturesYYN?N
perspective-transform pathsYYN?N
RGBA YYYYY
CMYKAYYNNN
linear-gradientYYYYY
radial-gradientYPYYY
conic-gradientNNNYY
mesh-gradientNNY??
bilinear texturesYYYYY
nearest texturesYYYYY

ctx provides abstractions for event injection and dispatch. It provides hit-detection, this allows abstracting over multiple input devices/buttons with a mouse+keyboard abstraction. In the event method callback both absolute and local (At time of callback registration) coordinates are provided. Interactive ctx backends drive event delivery, if you are implementing the callback backend for microcontrollers and external displays you are expected to turn hardware events into interaction events.

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.

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.