Skip to content

pantoken / design/swatches/src / toSvg

Funktion: toSvg()

toSvg(swatches, options?): string

Experimentell

Farbproben als gruppiertes SVG-Musterblatt rendern.

Parameter

swatches

schreibgeschützt Swatch[]

Die Palette (z. B. aus toSwatches).

options?

ToSvgOptions = {}

ToSvgOptions.

Rückgabe

string

Das SVG-Dokument als Zeichenkette.

Beispiele

Ein Musterblatt für ein README rendern

ts
import { writeFileSync } from "node:fs";
import { swatches, toSvg } from "@pantoken/swatches";

writeFileSync("palette.svg", toSvg(swatches));

Nur die Kernpalette mustern, mit Titel und breiterem Raster

ts
import { swatches, toSvg } from "@pantoken/swatches";

const core = swatches.filter((s) => !s.name.startsWith("primitive-"));
const svg = toSvg(core, { title: "Instructure core colors", columns: 8 });