Repository navigation
fix(path): reflect the previous group of a repeated S or T and read exponents with a plus sign - #1187
Open
SwastikTripathi wants to merge 1 commit into
Conversation
…xponents with a plus sign
This branch has not been deployed
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.
Two small problems in the SVG path parser (
src/tool/path.ts), whichcreateFromString()/extendFromString()and ECharts'path://symbols and custom graphics go through.Repeated
S/Tgroups. A command letter can be followed by several groups of numbers, and each group is a command of its own.prevCmdwas only updated once per command letter, so the second group of anSorTchecked the command before the letter instead of the first group. After a non-curve command it then didn't reflect the first group's control point:The second segment should start with the control point
(30, -10)(the reflection of(10, 10)about(20, 0)), but used the current point(20, 0). Same forM0 0 T10 10 20 0, where the secondTdrew a straight line instead of a curve. After aC(orQ) the old code happened to give the right result, soc ... s ... spaths were fine.prevCmdis now also set after each group.Exponent with a plus sign.
numberRegacceptede-5but note+5, so1e+2was read as the two numbers1and2and shifted every value after it. JavaScript writes large numbers that way (String(1e21)is"1e+21"). The exponent sign is now[-+]?.Added
test/ut/spec/tool/path.test.ts, which compares the bounding rect of each path with the same shape written with explicitC/Qcommands or plain numbers. Both tests fail before the change;npm testpasses (70 tests) and eslint is clean onpath.ts.