Skip to main content

Function: toSVG()

toSVG(scene, o?): string

Defined in: packages/sporty/src/svg.ts:34

Render a Scene to an SVG string (no DOM; Node and browser). Y is flipped via a <g> transform.

Parameters​

scene​

Scene

o?​

SvgOptions = {}

Returns​

string

Example​

import { surface } from "@sportsdataverse/sporty";
import { toSVG } from "@sportsdataverse/sporty/svg";

// arcs: "svg" writes circles as arc commands and precision trims the digits: a smaller file, the same court
toSVG(surface("basketball", "nba"), { width: 480, background: "#f5f0e1", arcs: "svg", precision: 2 });