perf: simplify stroke outlines before PDF export
Each stroke mesh has about 16 points per pen sample, and every one of them went into the PDF as a polygon point: a full handwritten page (1650 strokes) took 2.9 s to export, and PNG export and copying a selection as an image took as long, because both go through the PDF. The outline is now simplified with a closed Douglas-Peucker that measures against segments, at most 0.01 mm from the drawn outline. The same page now takes 0.44 s (PNG 0.55 s), the PDF shrinks from 10.7 MB to 1.4 MB, and the rendered PNG differs only in edge anti-aliasing (max 21/255). INK_NOTES_EXACT_OUTLINES=1 exports every point as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
330c29193f
commit
955eaa4095
4 files changed
+161
-17
No files matched your search
@@ -195,7 +195,7 @@ Each page has its own history (`history.rs`): adding, removing, replacing and mo
|
||||
2. **PDF** (fallback only): imported PDF page as an image, if it cannot be taken over as vectors.
|
||||
3. **Images:** inserted images (at most 300 dpi).
|
||||
4. **Text:** text boxes as real text with embedded font (searchable, copyable). Each box lives in its own coordinate system that a transformation matrix maps onto its corners.
|
||||
5. **Ink:** strokes as filled polygons, shapes as paths. Semi-transparent strokes (highlighter) get a graphics state with opacity (`ca`/`CA`); printpdf cannot create such states, so `add_alpha_states` adds them to the page resources with `lopdf` after saving. Each stroke is a single path and therefore does not cover itself twice.
|
||||
5. **Ink:** strokes as filled polygons, shapes as paths. Semi-transparent strokes (highlighter) get a graphics state with opacity (`ca`/`CA`); printpdf cannot create such states, so `add_alpha_states` adds them to the page resources with `lopdf` after saving. Each stroke is a single path and therefore does not cover itself twice. The outline of a stroke is simplified before export (`geometry::simplify_closed_outline`, at most 0.01 mm away from the drawn one): the mesh has about 16 points per pen sample, and with all of them a full page took seconds to export. `INK_NOTES_EXACT_OUTLINES=1` exports every point as before.
|
||||
|
||||
Imported PDF pages are then placed under the page as a form XObject (`pdf_merge.rs`), so they stay vector graphics. Page titles become bookmarks.
|
||||
|
||||
|
||||
Reference in new issue
Block a user