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-protocol | ctx | cairo | skia | blend2d |
---|---|---|---|---|---|
GPU rendering | - | N | N | Y | N |
change extent detection | - | Y | N | N | N |
CMYK output | - | Y | N | N | N |
float output | - | Y | N | N | N |
rgb565 output | - | Y | Y | N | N |
threaded rendering | - | Y | N | N | Y |
event-handling | - | Y | - | - | - |
drop-shadow | Y | N | N | Y | N |
pcm-audio | - | Y | - | - | - |
- | P | Y | N | ? | |
stroke-dash | Y | Y | Y | Y | N |
stroke-join-miter | Y | N | Y | Y | Y |
stroke-end-square | Y | P | Y | Y | Y |
stroke-join-round | Y | Y | Y | Y | Y |
stroke-end-round | Y | Y | Y | Y | Y |
clipping | Y | Y | Y | Y | N |
compositing-groups | Y | P | Y | Y | N |
blending-modes | Y | P | Y | Y | Y |
text | Y | Y | Y | Y | Y |
perspective-transform textures | Y | Y | N | ? | N |
perspective-transform paths | Y | Y | N | ? | N |
RGBA | Y | Y | Y | Y | Y |
CMYKA | Y | Y | N | N | N |
linear-gradient | Y | Y | Y | Y | Y |
radial-gradient | Y | P | Y | Y | Y |
conic-gradient | N | N | N | Y | Y |
mesh-gradient | N | N | Y | ? | ? |
bilinear textures | Y | Y | Y | Y | Y |
nearest textures | Y | Y | Y | Y | Y |
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.
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.