Skip to content

Conversation

@swhitty
Copy link
Owner

@swhitty swhitty commented Feb 19, 2025

Adds SwiftUI SVGView allowing SVGs to be drawn directly to SwiftUI views via Canvas API.

var body: some View {
    SVGView("sample.svg", bundle: .main)
        .aspectRatio(contentMode: .fit)
}

or it is faster to pass SVG instances which are much faster to draw as all parsing and draw commands are cached internally.

let cached = SVG(data: "<svg>...</svg>".data(using: .utf8)!)

var body: some View {
    SVGView(cached)
        .aspectRatio(contentMode: .fit)
}

Note: SVGView is only available on platforms where Canvas is available (macOS 12, iOS 15 etc).

@codecov
Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 84.70%. Comparing base (a3553a4) to head (51cd546).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
SwiftDraw/SVGView.swift 0.00% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
- Coverage   84.97%   84.70%   -0.27%     
==========================================
  Files          78       79       +1     
  Lines        7219     7242      +23     
==========================================
  Hits         6134     6134              
- Misses       1085     1108      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@swhitty swhitty merged commit b008e11 into main Feb 19, 2025
17 of 19 checks passed
@swhitty swhitty deleted the SVGView branch February 19, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants