Skip to main content

Grid-based vector layout engine — CSS Grid layout to SVG/PNG

Project description

LatticeSVG

基于 CSS Grid 的矢量布局引擎,输出高质量 SVG/PNG。

安装

pip install latticesvg

# 如需 PNG 输出
pip install latticesvg[png]

快速开始

from latticesvg import GridContainer, TextNode, ImageNode, Renderer

grid = GridContainer(style={
    "width": "800px",
    "padding": "20px",
    "background-color": "#ffffff",
    "grid-template-columns": ["200px", "1fr"],
    "gap": "20px",
})

title = TextNode("实验报告", style={
    "font-size": "24px",
    "font-weight": "bold",
    "color": "#333333",
    "justify-self": "center",
})
grid.add(title, row=1, col=1)

grid.layout(available_width=800)

renderer = Renderer()
renderer.render(grid, "report.svg")

依赖

  • Python ≥ 3.8
  • drawsvg — SVG 生成
  • freetype-py — 文本测量
  • cairosvg(可选)— PNG 转换

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

latticesvg-0.1.0.tar.gz (802.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

latticesvg-0.1.0-py3-none-any.whl (96.4 kB view details)

Uploaded Python 3

File details

Details for the file latticesvg-0.1.0.tar.gz.

File metadata

  • Download URL: latticesvg-0.1.0.tar.gz
  • Upload date:
  • Size: 802.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for latticesvg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a50ab0dc783c87f5554d7a16f90ed24bd299b5bd40ef53450b971153070b2f98
MD5 1c0eef678db7a460013b8adf76c7868b
BLAKE2b-256 f2b40c70823960f7695f633e6886a5afa3a7b4b3534fc444162b4d9a686be1c4

See more details on using hashes here.

File details

Details for the file latticesvg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: latticesvg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 96.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for latticesvg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca49f835589526a7290e9533bc60fefcd8e1bf87656d1c52b9587985ac88f846
MD5 231f4d3e16b85936d55b16d9457bdec0
BLAKE2b-256 d72e84c2fed9b7ff1bac51167823aca43678ae15ffad289dfcf944d5db0d79f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page