swhitty / SwiftDraw
Showing 1 of 2 files from the diff.

@@ -35,25 +35,40 @@
Loading
35 35
36 36
public extension NSImage {
37 37
38 -
  convenience init?(svgNamed name: String, in bundle: Bundle = Bundle.main) {
38 +
  convenience init?(svgNamed name: String, in bundle: Bundle = .main) {
39 39
    guard let image = Image(named: name, in: bundle) else { return nil }
40 +
    self.init(image)
41 +
  }
42 +
43 +
  @objc(initWithSVGData:)
44 +
  convenience init?(_ data: Data) {
45 +
    guard let image = Image(data: data) else { return nil }
46 +
    self.init(image)
47 +
  }
48 +
49 +
  @objc(initWithContentsOfSVGFile:)
50 +
  convenience init?(contentsOfSVGFile path: String) {
51 +
    guard let image = Image(fileURL: URL(fileURLWithPath: path)) else { return nil }
52 +
    self.init(image)
53 +
  }
54 +
55 +
  @objc(svgNamed:)
56 +
  static func _svgNamed(_ name: String) -> NSImage? {
57 +
    NSImage(svgNamed: name, in: .main)
58 +
  }
40 59
60 +
  @objc(svgNamed:inBundle:)
61 +
  static func _svgNamed(_ name: String, in bundle: Bundle) -> NSImage? {
62 +
    NSImage(svgNamed: name, in: bundle)
63 +
  }
64 +
65 +
  convenience init(_ image: Image) {
41 66
    self.init(size: image.size, flipped: true) { rect in
42 67
      guard let ctx = NSGraphicsContext.current?.cgContext else { return false }
43 68
      ctx.draw(image, in: CGRect(x: 0, y: 0, width: rect.size.width, height: rect.size.height))
44 69
      return true
45 70
    }
46 71
  }
47 -
48 -
  @objc
49 -
  static func svgNamed(_ name: String, inBundle: Bundle) -> NSImage? {
50 -
    NSImage(svgNamed: name, in: inBundle)
51 -
  }
52 -
53 -
  @objc
54 -
  static func svgNamed(_ name: String) -> NSImage? {
55 -
      NSImage(svgNamed: name, in: .main)
56 -
  }
57 72
}
58 73
59 74
public extension Image {
Files Coverage
SwiftDraw 75.96%
Project Totals (59 files) 75.96%
1
ignore:
2
  - "SwiftDrawTests"
3
  - "CommandLine"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading