@@ -97,42 +97,42 @@ extension LayerTree.Builder {
9797 }
9898
9999 static func createLine( from segment: DOM . Path . Segment , last point: Point ) -> Path . Segment ? {
100- guard case . line( let l ) = segment else { return nil }
100+ guard case let . line( x , y , space ) = segment else { return nil }
101101
102- let p = Point ( l . x, l . y)
102+ let p = Point ( x, y)
103103
104- switch l . space {
104+ switch space {
105105 case . relative: return . line( to: p. absolute ( from: point) )
106106 case . absolute: return . line( to: p)
107107 }
108108 }
109109
110110 static func createHorizontal( from segment: DOM . Path . Segment , last point: Point ) -> Path . Segment ? {
111- guard case . horizontal( let h ) = segment else { return nil }
111+ guard case let . horizontal( x , space ) = segment else { return nil }
112112
113- switch h . space {
114- case . relative: return . line( to: Point ( h . x + point. x , point. y) )
115- case . absolute: return . line( to: Point ( h . x, point. y) )
113+ switch space {
114+ case . relative: return . line( to: Point ( x + point. x , point. y) )
115+ case . absolute: return . line( to: Point ( x, point. y) )
116116 }
117117 }
118118
119119 static func createVertical( from segment: DOM . Path . Segment , last point: Point ) -> Path . Segment ? {
120- guard case . vertical( let v ) = segment else { return nil }
120+ guard case let . vertical( y , space ) = segment else { return nil }
121121
122- switch v . space {
123- case . relative: return . line( to: Point ( point. x , v . y + point. y) )
124- case . absolute: return . line( to: Point ( point. x, v . y) )
122+ switch space {
123+ case . relative: return . line( to: Point ( point. x , y + point. y) )
124+ case . absolute: return . line( to: Point ( point. x, y) )
125125 }
126126 }
127127
128128 static func createCubic( from segment: DOM . Path . Segment , last point: Point ) -> Path . Segment ? {
129- guard case . cubic( let c ) = segment else { return nil }
129+ guard case let . cubic( x1 , y1 , x2 , y2 , x , y , space ) = segment else { return nil }
130130
131- let p = Point ( c . x, c . y)
132- let cp1 = Point ( c . x1, c . y1)
133- let cp2 = Point ( c . x2, c . y2)
131+ let p = Point ( x, y)
132+ let cp1 = Point ( x1, y1)
133+ let cp2 = Point ( x2, y2)
134134
135- switch c . space {
135+ switch space {
136136 case . relative: return . cubic( to: p. absolute ( from: point) ,
137137 control1: cp1. absolute ( from: point) ,
138138 control2: cp2. absolute ( from: point) )
@@ -141,17 +141,17 @@ extension LayerTree.Builder {
141141 }
142142
143143 static func createCubicSmooth( from segment: DOM . Path . Segment , last point: Point , previous control: Point ) -> Path . Segment ? {
144- guard case . cubicSmooth( let c ) = segment else { return nil }
144+ guard case let . cubicSmooth( x2 , y2 , x , y , space ) = segment else { return nil }
145145
146146 let delta = Point ( point. x - control. x,
147147 point. y - control. y)
148148
149- let p = Point ( c . x, c . y)
149+ let p = Point ( x, y)
150150 let cp1 = Point ( point. x + delta. x,
151151 point. y + delta. y)
152- let cp2 = Point ( c . x2, c . y2)
152+ let cp2 = Point ( x2, y2)
153153
154- switch c . space {
154+ switch space {
155155 case . relative: return . cubic( to: p. absolute ( from: point) ,
156156 control1: cp1,
157157 control2: cp2. absolute ( from: point) )
@@ -160,12 +160,12 @@ extension LayerTree.Builder {
160160 }
161161
162162 static func createQuadratic( from segment: DOM . Path . Segment , last point: Point ) -> Path . Segment ? {
163- guard case . quadratic( let q ) = segment else { return nil }
163+ guard case let . quadratic( x1 , y1 , x , y , space ) = segment else { return nil }
164164
165- var p = Point ( q . x, q . y)
166- var cp1 = Point ( q . x1, q . y1)
165+ var p = Point ( x, y)
166+ var cp1 = Point ( x1, y1)
167167
168- if q . space == . relative {
168+ if space == . relative {
169169 p = p. absolute ( from: point)
170170 cp1 = cp1. absolute ( from: point)
171171 }
@@ -191,15 +191,15 @@ extension LayerTree.Builder {
191191 }
192192
193193 static func createQuadraticSmooth( from segment: DOM . Path . Segment , last point: Point , previous control: Point ) -> Path . Segment ? {
194- guard case . quadraticSmooth( let q ) = segment else { return nil }
194+ guard case let . quadraticSmooth( x , y , space ) = segment else { return nil }
195195
196196 let delta = Point ( point. x - control. x,
197197 point. y - control. y)
198198
199199 let cp1 = Point ( point. x + delta. x,
200200 point. y + delta. y)
201-
202- let final = q . space == . absolute ? Point ( q . x, q . y) : Point ( q . x, q . y) . absolute ( from: point)
201+
202+ let final = space == . absolute ? Point ( x, y) : Point ( x, y) . absolute ( from: point)
203203 let cpX = ( final. x - point. x) * Float( 1.0 / 3.0 )
204204 let cp2 = Point ( cp1. x + cpX,
205205 cp1. y)
@@ -208,24 +208,24 @@ extension LayerTree.Builder {
208208 }
209209
210210 static func createArc( from segment: DOM . Path . Segment , last point: Point ) -> [ Path . Segment ] ? {
211- guard case . arc( let a ) = segment else { return nil }
211+ guard case let . arc( rx , ry , rotate , large , sweep , x , y , space ) = segment else { return nil }
212212
213213 let p : Point
214214
215- switch a . space {
216- case . relative: p = Point ( a . x, a . y) . absolute ( from: point)
217- case . absolute: p = Point ( a . x, a . y)
215+ switch space {
216+ case . relative: p = Point ( x, y) . absolute ( from: point)
217+ case . absolute: p = Point ( x, y)
218218 }
219219
220220 let curves = makeCubic ( from: point, to: p,
221- large: a . large, sweep: a . sweep,
222- rx: LayerTree . Float ( a . rx) ,
223- ry: LayerTree . Float ( a . ry) ,
224- rotation: LayerTree . Float ( a . rotate) )
221+ large: large, sweep: sweep,
222+ rx: LayerTree . Float ( rx) ,
223+ ry: LayerTree . Float ( ry) ,
224+ rotation: LayerTree . Float ( rotate) )
225225
226226 return curves. map { . cubic( to: $0. p, control1: $0. cp1, control2: $0. cp2) }
227227 }
228-
228+
229229 static func createClose( from segment: DOM . Path . Segment ) -> Path . Segment ? {
230230 guard case . close = segment else { return nil }
231231 return . close
0 commit comments