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