On this page:
svg:   SVG Rendering for Racket
9.3

svg: SVG Rendering for Racket🔗ℹ

Jens Axel Søgaard <jensaxel@soegaard.net>

Note: The parsers library and documentation were written with the help of Codex.

 (require svg/svg) package: svg

svg/svg turns SVG files or strings into Racket bitmap% images or picts.

The svg/svg Racket library allows you to read SVG documents and then draw them with racket/draw. The library supports many common static SVG features, including shapes, paths, colors, gradients, patterns, clipping, masks, text, images, CSS styles, and several filters. It does not try to run animations or scripts; it renders one still image.

The renderer covers most of static SVG 1.1 and SVG 2 — shapes, paths, gradients and patterns, clipping and masking, markers, text, images, CSS stylesheets (including SVG2’s CSS geometry properties), and a substantial subset of filter effects.

Rendering is built directly on racket/draw’s dc<%> rather than through an intermediate representation.

The main omissions are animations, scripting, and interactivity; this is a static, single-frame renderer. Other gaps are listed in Scope and Known Limitations at the end of this document.

    1 Installation

    2 Quick Start

    3 Top-Level Rendering

    4 Path Data

      4.1 The path-command format

    5 Geometry, Viewports, and Transforms

    6 Paint and Color

    7 Stroke Geometry

    8 CSS Styling

    9 Text

    10 Markers

    11 Images

    12 Filter and Color-Space Utilities

    13 Scope and Known Limitations