BerndK / SvgToXaml

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

Add option to convert to Canvas instead #28

Closed Symbai closed 3 weeks ago

Symbai commented 2 years ago

I have some issues converting some SVG files as I cannot resize them properly. For example download this one https://www.svgrepo.com/svg/350341/gamepad and try to make it 32x32 in your application. Changing height/width of the image won't actuall fill/resize the underlaying DrawingImage to be in this size. Instead its either extremely tiny somewhere in right corner in the image or way too large. It's never properly filled.

The site https://materialdesignicons.com/ gives us the option to use DrawingImage or Canvas. With their XAML I have zero issues on scaling the SVG up/down.

BerndK commented 1 year ago

Hi Sambai, the problem with that file (gamepad) is that the metadata seems to be weird. The file states that it has a size of 800px, the values of the path are between 924 to ~1150 so from this view they are outside the expected canvas. There are 2 issues related clipping: a) the drawing extends the 'page' while only what is on the page shall be visible -> clipping will limit the visible area b) if the icon is 'sysmmetric' like e.g. a quarte circle from 6 to 9 (of a clock) shall be shown in the lower left corner. Usually the icon is centered and fill the available space, so the quarter circle will be too big an centered (it will start top left, circle down to bottom right) - to avoid that the program adds kind of invisible points to have the whole Canvas (-> no sizing and centering happens based on the visible points) - here this will add "F1 M800,800z M0,0z" to the path.

It seems that this (given data and algorithm) does not produce the expected result here. Try to normalize the points, or modify/remove the artificial stuff.

BerndK commented 3 weeks ago

closed due to inactivity