@@ -87,7 +87,7 @@ public override BrushApplicator<TPixel> CreateApplicator<TPixel>(
8787 this . hasSpecialCenterColor ) ;
8888
8989 private static Color CalculateCenterColor ( Color [ ] colors )
90- => new ( colors . Select ( c => ( Vector4 ) c ) . Aggregate ( ( p1 , p2 ) => p1 + p2 ) / colors . Length ) ;
90+ => Color . FromScaledVector ( colors . Select ( c => c . ToScaledVector4 ( ) ) . Aggregate ( ( p1 , p2 ) => p1 + p2 ) / colors . Length ) ;
9191
9292 private static float DistanceBetween ( Vector2 p1 , Vector2 p2 ) => ( p2 - p1 ) . Length ( ) ;
9393
@@ -115,8 +115,8 @@ public Edge(Vector2 start, Vector2 end, Color startColor, Color endColor)
115115 {
116116 this . Start = start ;
117117 this . End = end ;
118- this . StartColor = ( Vector4 ) startColor ;
119- this . EndColor = ( Vector4 ) endColor ;
118+ this . StartColor = startColor . ToScaledVector4 ( ) ;
119+ this . EndColor = endColor . ToScaledVector4 ( ) ;
120120
121121 this . length = DistanceBetween ( this . End , this . Start ) ;
122122 }
@@ -204,7 +204,7 @@ public PathGradientBrushApplicator(
204204 Vector2 [ ] points = edges . Select ( s => s . Start ) . ToArray ( ) ;
205205
206206 this . center = points . Aggregate ( ( p1 , p2 ) => p1 + p2 ) / edges . Count ;
207- this . centerColor = ( Vector4 ) centerColor ;
207+ this . centerColor = centerColor . ToScaledVector4 ( ) ;
208208 this . hasSpecialCenterColor = hasSpecialCenterColor ;
209209 this . centerPixel = centerColor . ToPixel < TPixel > ( ) ;
210210 this . maxDistance = points . Select ( p => p - this . center ) . Max ( d => d . Length ( ) ) ;
@@ -240,9 +240,7 @@ public PathGradientBrushApplicator(
240240 + ( u * this . edges [ 0 ] . EndColor )
241241 + ( v * this . edges [ 2 ] . StartColor ) ;
242242
243- TPixel px = default ;
244- px . FromScaledVector4 ( pointColor ) ;
245- return px ;
243+ return TPixel . FromScaledVector4 ( pointColor ) ;
246244 }
247245
248246 Vector2 direction = Vector2 . Normalize ( point - this . center ) ;
@@ -263,9 +261,7 @@ public PathGradientBrushApplicator(
263261
264262 Vector4 color = Vector4 . Lerp ( edgeColor , this . centerColor , ratio ) ;
265263
266- TPixel pixel = default ;
267- pixel . FromScaledVector4 ( color ) ;
268- return pixel ;
264+ return TPixel . FromScaledVector4 ( color ) ;
269265 }
270266 }
271267
0 commit comments