Commit 6e02708
authored
[vector_graphics_compiler] support percentage units SVG shape attributes (#10577)
Adds percentage unit support for SVG shape attributes
SVG shapes like `<rect>`, `<circle>`, `<ellipse>`, and `<line>` can have percentage values for their position and size attributes (e.g., width="50%", cx="50%"). Previously
these weren't handled correctly. Easy to test with any image like https://placeholdit.com/600x400/dddddd/999999
This adds:
- Percentage parsing in parseDoubleWithUnits that resolves values against the viewport dimensions
- Viewport width/height getters on SvgParser
- Proper percentage reference handling for all basic shape elements
- Circle radius uses the normalized diagonal per SVG spec
*List which issues are fixed by this PR. You must list at least one issue.*
I'm not sure if it fixes these issues, as they have no description. I can file a new issue if needed.
flutter/flutter#158844
flutter/flutter#158845
## Pre-Review Checklist
**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.1 parent 87ea370 commit 6e02708
File tree
5 files changed
+155
-5
lines changed- packages/vector_graphics_compiler
- lib/src/svg
- test
5 files changed
+155
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
Lines changed: 26 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| 72 | + | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
70 | 95 | | |
71 | 96 | | |
72 | 97 | | |
| |||
Lines changed: 57 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| 221 | + | |
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
| 225 | + | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
| |||
482 | 485 | | |
483 | 486 | | |
484 | 487 | | |
| 488 | + | |
| 489 | + | |
485 | 490 | | |
486 | 491 | | |
| 492 | + | |
487 | 493 | | |
488 | 494 | | |
489 | 495 | | |
| 496 | + | |
490 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
491 | 505 | | |
492 | 506 | | |
| 507 | + | |
493 | 508 | | |
494 | 509 | | |
495 | 510 | | |
| |||
503 | 518 | | |
504 | 519 | | |
505 | 520 | | |
| 521 | + | |
| 522 | + | |
506 | 523 | | |
507 | 524 | | |
| 525 | + | |
508 | 526 | | |
509 | 527 | | |
510 | 528 | | |
| 529 | + | |
511 | 530 | | |
512 | 531 | | |
513 | 532 | | |
| 533 | + | |
514 | 534 | | |
515 | 535 | | |
516 | 536 | | |
| 537 | + | |
517 | 538 | | |
518 | 539 | | |
519 | 540 | | |
520 | 541 | | |
521 | 542 | | |
522 | 543 | | |
523 | 544 | | |
524 | | - | |
525 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
526 | 553 | | |
527 | 554 | | |
528 | 555 | | |
| |||
552 | 579 | | |
553 | 580 | | |
554 | 581 | | |
| 582 | + | |
| 583 | + | |
555 | 584 | | |
556 | 585 | | |
| 586 | + | |
557 | 587 | | |
558 | 588 | | |
559 | 589 | | |
| 590 | + | |
560 | 591 | | |
561 | 592 | | |
562 | 593 | | |
| 594 | + | |
563 | 595 | | |
564 | 596 | | |
565 | 597 | | |
| 598 | + | |
566 | 599 | | |
567 | 600 | | |
568 | 601 | | |
| |||
572 | 605 | | |
573 | 606 | | |
574 | 607 | | |
| 608 | + | |
| 609 | + | |
575 | 610 | | |
576 | 611 | | |
| 612 | + | |
577 | 613 | | |
578 | 614 | | |
579 | 615 | | |
| 616 | + | |
580 | 617 | | |
581 | 618 | | |
582 | 619 | | |
| 620 | + | |
583 | 621 | | |
584 | 622 | | |
585 | 623 | | |
| 624 | + | |
586 | 625 | | |
587 | 626 | | |
588 | 627 | | |
| |||
968 | 1007 | | |
969 | 1008 | | |
970 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
971 | 1014 | | |
972 | 1015 | | |
973 | 1016 | | |
974 | 1017 | | |
975 | | - | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
976 | 1023 | | |
977 | 1024 | | |
978 | 1025 | | |
979 | 1026 | | |
| 1027 | + | |
980 | 1028 | | |
981 | 1029 | | |
982 | 1030 | | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
983 | 1037 | | |
984 | 1038 | | |
985 | 1039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3155 | 3155 | | |
3156 | 3156 | | |
3157 | 3157 | | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
| 3183 | + | |
| 3184 | + | |
| 3185 | + | |
| 3186 | + | |
| 3187 | + | |
| 3188 | + | |
| 3189 | + | |
| 3190 | + | |
| 3191 | + | |
| 3192 | + | |
| 3193 | + | |
| 3194 | + | |
| 3195 | + | |
| 3196 | + | |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
3158 | 3225 | | |
3159 | 3226 | | |
3160 | 3227 | | |
| |||
0 commit comments