swhitty / SwiftDraw

Swift library and command line tool to convert SVGs into SFSymbol, PNG, PDF and Swift source code.
zlib License
423 stars 51 forks source link

Support absolute units for any position, size or coordinate #45

Closed swhitty closed 4 months ago

swhitty commented 4 months ago

Any SVG position, size or coordinate can be specified with a unit (absolute or relative). This PR adds support for absolute units that can be explicated converted to pixels using predefined constants.:

<?xml version="1.0" encoding="utf-8"?>   
<svg height="10cm" width="10cm" xmlns="http://www.w3.org/2000/svg">
    <rect width="10cm" height="10cm" fill="snow" />
    <polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
</svg>

units-cm

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 96.15385% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.18%. Comparing base (b917e2a) to head (57a2676).

Files Patch % Lines
SwiftDraw/DOM.swift 96.42% 1 Missing :warning:
SwiftDraw/Parser.XML.Scanner.swift 95.83% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #45 +/- ## ========================================== + Coverage 84.07% 84.18% +0.11% ========================================== Files 77 77 Lines 5437 5488 +51 ========================================== + Hits 4571 4620 +49 - Misses 866 868 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.