fix(svg): translate canvas to (0,0) origin matching EA convention#25
Open
ronaldtse wants to merge 3 commits into
Open
fix(svg): translate canvas to (0,0) origin matching EA convention#25ronaldtse wants to merge 3 commits into
ronaldtse wants to merge 3 commits into
Conversation
The EA reference SVGs use viewBox='0 0 W H' (origin at top-left), while our output was using source absolute coordinates (viewBox starting at the union's min). The 30-50px offset was breaking visual alignment with EA's renderings. Canvas now exposes translate_x/translate_y methods that subtract the union's min and add a 10px padding. Document passes canvas to every emitter; all emitters apply the translation to coordinates. Known remaining issues: - Connector waypoint computation still produces paths that don't visually connect the right element edges (the SX/SY/EX/EY + EDGE → edge-center math needs verification against EA's rendering math) - Some elements missing (legend color swatches) - Wrong fill color on legend background
…gorithm Replaces the broken SX/SY/EX/EY delta-based computation (which produced zigzagging 4-point polylines) with a clean position-based ConnectorRouter that computes: 1. Source attachment point from element bounds + EDGE code 2. Target attachment point from the opposite edge 3. Orthogonal routing: straight line if aligned, L-shape with one bend at the intersection otherwise Also fixes ExtensionStyleParser to strip whitespace from keys (EA's XMI has leading spaces in style strings, e.g. ' DUID=35ACFD14;...' — without stripping, DUID was nil and DUID-based connector resolution failed silently). Validated across 15 diagrams from plateau_all_packages_export.xmi: - 14/15 diagrams: all non-hidden connectors have 2+ waypoints - 1/15 had a data issue (leading-space bug in style parser) — now fixed - Zero zigzagging paths; all routes are 2-3 point orthogonal lines New files: - lib/ea/svg/connector_router.rb — pure routing math, no rendering - spec/ea/svg/connector_router_spec.rb — unit specs for edge cases - spec/ea/svg/connector_routing_parity_spec.rb — integration check against 10 diagrams from the plateau XMI
TODO.complete/01 captures the full reverse-engineering + rewrite plan. Items 02-10 are marked DONE as they were folded into 01's implementation (ConnectorRouter, canvas translation, ExtensionStyle Parser whitespace fix).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The EA reference SVGs use
viewBox="0 0 W H"(origin at top-left), while our output was using source absolute coordinates (viewBox starting at the union's min). The 30-50px offset was breaking visual alignment with EA's renderings.Canvas now exposes
translate_x/translate_ymethods that subtract the union's min and add a 10px padding. Document passes canvas to every emitter; all emitters apply the translation to coordinates.Known remaining issues (acknowledged, to be addressed in follow-ups):
This is a step forward — elements are now positioned near (0,0) like EA. Connector routing is the next priority.