@@ -157,7 +157,9 @@ extension LayerTree.Builder {
157157 let stroke : LayerTree . Color
158158
159159 if state. strokeWidth > 0.0 {
160- stroke = LayerTree . Color. create ( from: state. stroke) . withAlpha ( state. strokeOpacity) . maybeNone ( )
160+ stroke = LayerTree . Color
161+ . create ( from: state. stroke, current: state. color)
162+ . withAlpha ( state. strokeOpacity) . maybeNone ( )
161163 } else {
162164 stroke = . none
163165 }
@@ -170,7 +172,9 @@ extension LayerTree.Builder {
170172 }
171173
172174 func makeFillAttributes( with state: State ) -> LayerTree . FillAttributes {
173- let fill = LayerTree . Color. create ( from: state. fill. makeColor ( ) ) . withAlpha ( state. fillOpacity) . maybeNone ( )
175+ let fill = LayerTree . Color
176+ . create ( from: state. fill. makeColor ( ) , current: state. color)
177+ . withAlpha ( state. fillOpacity) . maybeNone ( )
174178
175179 if case . url( let patternId) = state. fill,
176180 let element = svg. defs. patterns. first ( where: { $0. id == patternId. fragment } ) {
@@ -186,7 +190,9 @@ extension LayerTree.Builder {
186190 }
187191
188192 static func makeTextAttributes( with state: State ) -> LayerTree . TextAttributes {
189- let fill = LayerTree . Color. create ( from: state. fill. makeColor ( ) ) . withAlpha ( state. fillOpacity) . maybeNone ( )
193+ let fill = LayerTree . Color
194+ . create ( from: state. fill. makeColor ( ) , current: state. color)
195+ . withAlpha ( state. fillOpacity) . maybeNone ( )
190196 return LayerTree . TextAttributes (
191197 color: fill,
192198 fontName: state. fontFamily,
@@ -232,7 +238,7 @@ extension LayerTree.Builder {
232238 func makeGradientStops( for element: DOM . LinearGradient ) -> [ LayerTree . Gradient . Stop ] {
233239 return element. stops. map {
234240 LayerTree . Gradient. Stop ( offset: $0. offset,
235- color: LayerTree . Color ( $0. color) ,
241+ color: LayerTree . Color. create ( from : $0. color, current : . none ) ,
236242 opacity: $0. opacity)
237243 }
238244 }
@@ -241,6 +247,7 @@ extension LayerTree.Builder {
241247 struct State {
242248 var opacity : DOM . Float
243249 var display : DOM . DisplayMode
250+ var color : DOM . Color
244251
245252 var stroke : DOM . Color
246253 var strokeWidth : DOM . Float
@@ -261,6 +268,7 @@ extension LayerTree.Builder {
261268 //default root SVG element state
262269 opacity = 1.0
263270 display = . inline
271+ color = . keyword( . black)
264272
265273 stroke = . none
266274 strokeWidth = 1.0
@@ -284,6 +292,7 @@ extension LayerTree.Builder {
284292
285293 state. opacity = attributes. opacity ?? 1.0
286294 state. display = attributes. display ?? existing. display
295+ state. color = attributes. color ?? existing. color
287296
288297 state. stroke = attributes. stroke ?? existing. stroke
289298 state. strokeWidth = attributes. strokeWidth ?? existing. strokeWidth
@@ -297,7 +306,7 @@ extension LayerTree.Builder {
297306 state. fillRule = attributes. fillRule ?? existing. fillRule
298307
299308 state. fontFamily = attributes. fontFamily ?? existing. fontFamily
300- state. fontSize = attributes. fontSize ?? existing. fontSize
309+ state. fontSize = attributes. fontSize ?? existing. fontSize
301310
302311 return state
303312 }
0 commit comments