Skip to content

Add SVGExporter with full PAGX-to-SVG conversion support#3317

Open
OnionsYu wants to merge 34 commits intoTencent:mainfrom
OnionsYu:feature/onionsyu_svg_export
Open

Add SVGExporter with full PAGX-to-SVG conversion support#3317
OnionsYu wants to merge 34 commits intoTencent:mainfrom
OnionsYu:feature/onionsyu_svg_export

Conversation

@OnionsYu
Copy link

@OnionsYu OnionsYu commented Mar 12, 2026

Summary

  • Add SVGExporter class implementing full PAGX-to-SVG conversion, including support for fills, strokes, gradients, image patterns, blend modes, Display P3 color space, shadow filters, color matrix/blend filters, masks, clipPaths, text alignment, and custom data attributes.
  • Add export-svg CLI command for exporting PAGX files to SVG format.
  • Extract SVG-specific test cases into PAGXSVGTest.cpp and add roundtrip test suite for CLI export.

Key Changes

  • New files: SVGExporter.h, SVGExporter.cpp, CommandExportSVG.cpp/.h, PAGXSVGTest.cpp
  • Refactored: SVGImporter.cpp (fix pattern import round-trip), PAGXTest.cpp (extract SVG tests), PAGXCliTest.cpp (add CLI roundtrip tests)
  • Internal improvements: SVGWriter class encapsulation, SVGBuilder optimizations, shared def ID counter to avoid collisions in nested writers

Test Plan

  • All existing PAGX tests pass
  • New SVG export roundtrip tests pass
  • CLI export-svg command works correctly

Made with Cursor

OnionsYu added 29 commits March 11, 2026 20:57
…std::clamp, fix prefix check, and reserve P3 style string

Made-with: Cursor
…AGXFile/SaveSVGFile into a single SaveFile helper

Made-with: Cursor
…export

# Conflicts:
#	.codebuddy/skills/pagx/SKILL.md
#	src/cli/main.cpp
#	test/src/PAGXCliTest.cpp
@OnionsYu OnionsYu requested a review from kevingpqi123 as a code owner March 12, 2026 09:19

By default the output file has the same base name as the input with a `.svg` extension
(e.g., `foo.pagx` → `foo.svg`). Use `-o` to override. On success the command prints
`pagx export-svg: wrote <path>` and exits 0; on failure it prints an error and exits 1.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果失败有具体的错误代码的话,也可以返回具体的错误码

}
switch (textBox->paragraphAlign) {
case ParagraphAlign::Middle:
y = textBox->position.y + textBox->size.height / 2 + text->fontSize * 0.35f;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.35是从哪里来的

// Main Export function
//==============================================================================

std::string SVGExporter::ToSVG(const PAGXDocument& doc, const Options& options) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外需要验证一下,pagx转换成svg后,再将svg转换成pagx,二者是否一致。需要保证二者互转信息不跌势,不支持的特性可以考虑额外标记data-前缀的用户参数来标记,目标是避免多次来回转换后信息丢失

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants