Skip to content

pantoken / design/swatches/src / toSvg

函式: toSvg()

toSvg(swatches, options?): string

實驗性

將色票渲染為分組的 SVG 樣本表。

參數

swatches

唯讀 Swatch[]

調色盤(例如來自 toSwatches)。

options?

ToSvgOptions = {}

ToSvgOptions.

回傳

string

SVG 文件的字串表示。

範例

為 README 渲染樣本表

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

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

僅展示核心調色盤的樣本,附標題與較寬的格線

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