swhitty / SwiftDraw

@@ -241,7 +241,7 @@
Loading
241 241
        return gradient
242 242
    }
243 243
244 -
    func makeGradient(for element: DOM.RadialGradient) -> LayerTree.Gradient? {
244 +
    func makeGradient(for element: DOM.RadialGradient) -> LayerTree.RadialGradient? {
245 245
        var gradient = LayerTree.Gradient(start: Point(0, 0), end: Point(1, 1))
246 246
        if let id = element.href?.fragment,
247 247
           let reference = svg.defs.linearGradients.first(where: { $0.id == id }) {
@@ -260,7 +260,13 @@
Loading
260 260
            return nil
261 261
        }
262 262
263 -
        return gradient
263 +
        return LayerTree.RadialGradient(
264 +
            gradient: gradient,
265 +
            center: LayerTree.Point(element.cx ?? 0.5, element.cy ?? 0.5),
266 +
            radius: LayerTree.Float(element.r ?? 0.5),
267 +
            endCenter: LayerTree.Point(element.fx ?? 0.5, element.fy ?? 0.5),
268 +
            endRadius: LayerTree.Float(element.fr ?? 0.5)
269 +
        )
264 270
    }
265 271
266 272
    func makeGradientStops(for element: DOM.LinearGradient) -> [LayerTree.Gradient.Stop] {

@@ -227,7 +227,7 @@
Loading
227 227
                commands.append(.pushState)
228 228
                commands.append(.setClip(path: path))
229 229
230 -
                let converted = apply(colorConverter: colorConverter, to: fillGradient)
230 +
                let converted = apply(colorConverter: colorConverter, to: fillGradient.gradient)
231 231
                let gradient = provider.createGradient(from: converted)
232 232
                let pathBounds = provider.getBounds(from: shape)
233 233
                let center = provider.createPoint(from: pathBounds.center)
@@ -235,7 +235,7 @@
Loading
235 235
                let y = (pathBounds.center.y - pathBounds.origin.y)
236 236
                let radius = provider.createFloat(from: sqrt(x*x+y*y))
237 237
238 -
                if !fillGradient.transform.isEmpty {
238 +
                if !fillGradient.gradient.transform.isEmpty {
239 239
                   // commands.append(contentsOf: renderCommands(forTransforms: fillGradient.transform))
240 240
                }
241 241

@@ -69,6 +69,14 @@
Loading
69 69
            case objectBoundingBox
70 70
        }
71 71
    }
72 +
73 +
    struct RadialGradient: Hashable {
74 +
        var gradient: Gradient
75 +
        var center: Point
76 +
        var radius: Float
77 +
        var endCenter: Point
78 +
        var endRadius: Float
79 +
    }
72 80
}
73 81
74 82
private extension LayerTree.Color {

@@ -107,7 +107,7 @@
Loading
107 107
            self.opacity = opacity
108 108
        }
109 109
110 -
        init(radial gradient: Gradient, rule: FillRule, opacity: Float) {
110 +
        init(radial gradient: RadialGradient, rule: FillRule, opacity: Float) {
111 111
            self.fill = .radialGradient(gradient)
112 112
            self.rule = rule
113 113
            self.opacity = opacity
@@ -117,7 +117,7 @@
Loading
117 117
            case color(Color)
118 118
            case pattern(Pattern)
119 119
            case linearGradient(Gradient)
120 -
            case radialGradient(Gradient)
120 +
            case radialGradient(RadialGradient)
121 121
        }
122 122
    }
123 123
Files Coverage
SwiftDraw 75.61%
Project Totals (64 files) 75.61%
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