@arcsin1/pptx-ooxml-geometry
v0.0.2
Published
OOXML geometry runtime primitives for PPTX import and rendering
Readme
@arcsin1/pptx-ooxml-geometry
OOXML / DrawingML 图形几何工具库,用于将 PPTX 中的形状几何转换为可渲染的 SVG 路径。
功能
- 解析
a:custGeom自定义几何路径。 - 按目标宽高缩放并渲染自定义几何为 SVG path。
- 渲染常见
a:prstGeom预设形状。 - 计算 SVG path 的包围盒,支持直线、二次/三次贝塞尔曲线、平滑曲线与旋转椭圆弧。
- 导出 OOXML 角度与 adjustment 的单位常量。
已覆盖矩形、圆角矩形、椭圆、三角形、梯形、平行四边形、菱形、五边形、六边形、五角星、箭头、弧形、圆环、饼图、圆柱、常用流程图、连接线、切角矩形与数学符号等预设形状。
API
import {
parseOoxmlCustomGeometryXml,
renderOoxmlCustomGeometryPath,
renderOoxmlCustomGeometryXml,
renderOoxmlPresetShapePath,
getSvgPathBounds,
supportedOoxmlPresetShapes
} from '@arcsin1/pptx-ooxml-geometry'自定义几何
const geometry = parseOoxmlCustomGeometryXml(customGeometryXml)
const path = geometry
? renderOoxmlCustomGeometryPath(geometry, width, height)
: ''
const pathFromXml = renderOoxmlCustomGeometryXml(customGeometryXml, width, height)预设形状
const path = renderOoxmlPresetShapePath('hexagon', 320, 180)
const shapes = supportedOoxmlPresetShapes()SVG 包围盒
const bounds = getSvgPathBounds(path)
// { minX, minY, width, height }