Commit 16404bc
feat(odf): read the enhanced geometry languages, formulas and path alike
`draw:enhanced-geometry` is what makes a custom shape an arrow, a callout or a
star, and it says so in two small languages: `draw:formula` (20.36) and
`draw:enhanced-path` (19.145). Neither was read, so all 350 of them in the test
corpus rendered as rectangles.
`odf_enhanced_geometry.cpp` implements both as pure functions over strings —
nothing is wired into the element model yet, that is the next change:
- `evaluate_formula` is recursive descent over 20.36: `$N` modifiers, `?name`
equation references resolved through a caller-supplied lookup, the named
view-box values, and `abs sqrt sin cos tan atan min max atan2 if`. The
trigonometric functions take radians; the corpus settles it by writing
`sin(105*(pi/180))`.
- `convert_enhanced_path` turns every command of 19.145 into an svg `d`.
Two things worth knowing about the path conversion. An arc is emitted in
segments of at most a half turn, which means the large-arc flag is never needed
and `U 10800 10800 10800 10800 0 360` — a full turn, which a single svg `A`
cannot express, and 116 of the corpus's commands — still draws. And `F` and `S`
are read and dropped: painting one subpath with a different fill or stroke is
more than one `d` can say.
Tested from string literals; the geometry needs no fixture to exercise.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017XABfEapaADjFQCt1vjmDF1 parent c5ecb74 commit 16404bc
8 files changed
Lines changed: 878 additions & 97 deletions
File tree
- src/odr/internal/odf
- test
- src/internal/odf
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
130 | 135 | | |
131 | 136 | | |
132 | 137 | | |
| |||
0 commit comments