BerndK / SvgToXaml

Smart Tool to view svg-files and convert them to xaml for use in .NET
Other
886 stars 164 forks source link

Whole numbers written as fractions #12

Closed mennowo closed 5 years ago

mennowo commented 5 years ago

Hello, I have noticed that sometimes drawings (icons) I make in Inkscape, when converted, have numbers like "15.999999" or so. Although not in itself bad, this leads to unexpected behaviour when using DrawingImages as icons in WPF, where they are drawn incorrectly, or e.g. when used in a menu, the normal selection background color will not show up as expected. I fixed this in 2016 (https://github.com/mennowo/SvgToXaml/commit/97af57f41d0c3c2e27cdf31fddd109549c45147c) and updated the fix now. I'll do a PR, so you can decide wether or not to integrate this. See the attached file, that will have many 15.999999 values when converted using the current version. SortByType.zip Greets, Menno

BerndK commented 5 years ago

Hi Menno, I checked your file. The original SVG file contains already the unwanted inaccuracy: viewBox="0 0 15.999999 15.999999" As the SvgToXaml wants to be minimal invasive, it is not designed to modify the content. So you are free to write a tool that beautifies SVG-files. You can also use your branch, but I won't integrate that into the tool, sorry for that. Just as a not: if using lots of regular expressions, I would use precompiled instances (static). I would expect that it is a performance issue if you use lots of regexps without precompiling them (and reuse the generated code classes dynamically compiled by the framework). Perhaps the framework might be smart enough to cache the regexps if you use the same string again - did not investigate this. regards, Bernd.

mennowo commented 5 years ago

Hey @BerndK , thanks for your reply. I'm sorry I did not check that myself! If Inkscape delivers this input, than yes, it is logical for SvgToXaml to deliver that output. I will try out if making the source bigger (ie. 256x256) resolves this. It seems somewhat odd that Inkscape outputs 15.999999 while I have set page width/height to 16, and than snapped the image to the page borders. Maybe it want to keep the content just within the page in that case. Thanks again, greets, Menno

BerndK commented 5 years ago

Hi, not quite sure if this is also related to your problem. There was another issue that causes that a comma was used instead of a point like "15,999999". Perhaps this caused problems on your site.. This happened only on systems that uses a comma as decimal separator. Has been fixed in current source.

Cheers, Bernd.

mennowo commented 5 years ago

Ah, that could also be. I did notice the presence of both comma's and points, as is apparent from my code to change fractions into whole numbers. I'll check out if this fixes the issue. Would be nice to be able to use the main branch.