Skip to content

pantoken / design/swatches/src / toSvg

Fungsi: toSvg()

toSvg(swatches, options?): string

Eksperimental

Hasilkan helaian spesimen SVG berkumpulan bagi contoh warna.

Parameter

swatches

hanya-baca Swatch[]

Palet (contohnya dari toSwatches).

options?

ToSvgOptions = {}

ToSvgOptions.

Mengembalikan

string

Dokumen SVG sebagai rentetan.

Contoh

Hasilkan helaian spesimen untuk README

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

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

Spesimen hanya palet teras, dengan tajuk dan grid yang lebih lebar

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 });