defnotmid

Projects / 02

ovg

Odin vector graphics. A 2D vector canvas that started as a port of femtovg (the nanovg lineage) and grew well beyond it.

  • Odin
  • MIT
  • software rasterizer
  • SDL_GPU · Vulkan / Metal / D3D12
  • oglyph + ocurves + oicut + Odin vendor
35 seconds of ovg at 60 fps, on process music after Steve Reich's Music for 18 Musicians, in E major at 104 BPM. Every frame is an onimite script drawn by ovg: an SVG animated by element id, SVG filter primitives, blend modes, masks, clip paths and focal gradients, ligatures and Arabic shaping, and the GPU/software parity scene. ovg's demo/ at e730fd5d, rendered by onimite v0.0.60. Samples, all CC0: VS Chamber Orchestra 2: Community Edition and the Versilian Community Sample Library's upright piano, by Versilian Studios.

By the numbers

of the resvg test suite
88.5%
1037 files; the curated 53 all pass
GPU vs software parity
1–2/255
every parity scene, RX 9070 XT, Vulkan (RADV)
shaping differences from HarfBuzz
0
104,545 cases over oglyph's corpora, 40 downloaded fonts included
CSS blend modes
16
plus patterns, masks and clip paths

Figures from the ovg README (tools/svg_suite, tools/sdlgpu_parity); shaping from oglyph v0.0.5's tools/shape_corpus against libharfbuzz 14.6.0, re-run 2026-10-24.

What's in it

  1. 01The femtovg core

    Paths, strokes, gradients, image paints, scissoring, compositing, render-to-image and antialiased fills, recorded as commands for a backend.

  2. 02Layers

    Group opacity, clip paths, alpha and luminance masks, 16 blend modes and patterns, each sized to its content.

  3. 03SVG filters

    Blur, drop shadow, offset, flood, composite, merge, blend and colour matrix, with filter regions and linearRGB.

  4. 04SVG import

    svg_parse / svg_draw with CSS styling, <use>, gradients, patterns, masks, filters and text, plus per-element overrides for animation.

  5. 05Lottie import

    After Effects (Bodymovin) animations: precomps, mattes, masks, trim paths and eased keyframes.

  6. 06Real text and vector art

    OpenType shaping by oglyph, HarfBuzz's rules in native Odin (ligatures, kerning, mark positioning, Arabic, Indic and the other complex scripts), bidi, variable fonts at a chosen instance, per-glyph font fallback and multi-style layout. Every glyph, fill and stroke is drawn on the GPU by the exact area of each pixel its curves cover, computed by ocurves, under any transform: one instanced draw per run, no tessellation.

  7. 07Dashes

    Dash arrays, offsets and pathLength, enough to draw shapes on stroke by stroke.

  8. 08Custom shaders

    Register compiled SkSL (from oksl) and run it as a layer, with image, video or group children.

  9. 09Record anywhere, play on the GPU

    A recording canvas builds a frame's commands on any thread; the GPU thread plays them back, so frames build in parallel.

Two backends, one picture

The software backend is the pixel reference. It evaluates the fragment shader's formulas, computes the same exact coverage and samples textures exactly like the GPU, so the SDL_GPU backend (Vulkan on Linux, Metal on macOS) can be diffed against it scene by scene. ovg reads fonts and shapes text through oglyph, computes coverage and path booleans through ocurves, and decodes images (and writes PNGs) through oicut; the only other dependency is SDL3, from Odin's own vendor packages, for the GPU path.

Use it

import vg "deps:ovg"   // -collection:deps=.. (the directory holding ovg, oglyph, ocurves and oicut)
import image "deps:oicut/image"

sw: vg.Software_Backend
vg.software_backend_init(&sw)
c: vg.Canvas
vg.canvas_init(&c, vg.software_backend(&sw))

vg.set_size(&c, 640, 360)
vg.clear_rect(&c, 0, 0, 640, 360, vg.WHITE)

p: vg.Path
vg.path_rounded_rect(&p, 40, 40, 200, 120, 16)
vg.fill_path(&c, &p, vg.paint_linear_gradient(40, 40, 240, 160, vg.rgb(255, 80, 0), vg.rgb(0, 60, 255)))
stroke := vg.paint_color(vg.BLACK)
stroke.stroke.line_width = 3
vg.stroke_path(&c, &p, stroke)

vg.flush(&c)
image.write_png("out.png", sw.pixels, int(sw.width), int(sw.height))

The family