EtheaDev / SVGIconImageList

Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
321 stars 93 forks source link

Exponentials #230

Closed birbilis closed 2 years ago

birbilis commented 2 years ago

was looking at forks to see if they have fixes/additions that were never contributed back to the original repo

Noted this: https://github.com/EtheaDev/SVGIconImageList/commit/bc735d78d3003915a179ea5967ea0552dd9e167c

it's not compared correctly (probably due to different line endings) online by GitHub, but you could download the changed file and compare with WinMerge or similar

the commit comment says: " Correct TSVGPath.SeparateValues method to properly handle exponential values" and some differences I noted are related to "hasExp" local variable, that was added at "function TSVGPath.SeparateValues(const ACommand: Char; const S: string): TStrings;", see: image and image

didn't check if that code and the use-case (e.g. if indeed exponential numeric form is supported in SVG spec) is correct, could ask its author

birbilis commented 2 years ago

btw, all other forks had nothing useful

birbilis commented 2 years ago

seems exponential form of numbers is allowed by the SVG spec indeed: https://lists.w3.org/Archives/Public/www-svg/1999Nov/0027.html

quote:

In other words, can I write 3.450000e-004 instead of 0.000345

Yes, you can (although superfluous trailing and leading zeros should ideally be omitted to minimise file size. Only use the precision that is needed for the task). So in your example above, 3.45e-4 `

they also point to this grammar: https://www.w3.org/1999/08/WD-SVG-19990812/paths.html#PathDataBNF (this is for Path Data, but probably exponential number form is allowed elsewhere too where one can pass a floating point number - not sure if those can also be in exponential format, probably yes)

carloBarazzetta commented 2 years ago

TSVG is the first and older engine used: it is not maintained by the original author (Martin Walter) and is present only for backward compatibility...