Skip to content

pantoken / design/swatches/src / toSvg

Hàm: toSvg()

toSvg(swatches, options?): string

Thử nghiệm

Kết xuất mẫu màu thành một bảng mẫu SVG được nhóm.

Tham số

swatches

chỉ đọc Swatch[]

Bảng màu (ví dụ từ toSwatches).

options?

ToSvgOptions = {}

ToSvgOptions.

Trả về

string

Tài liệu SVG dưới dạng chuỗi.

Các ví dụ

Kết xuất một bảng mẫu cho README

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

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

Chỉ làm mẫu bảng màu cốt lõi, kèm tiêu đề và lưới rộng hơn

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