22// Licensed under the Apache License, Version 2.0.
33
44using System ;
5- using System . Buffers ;
65using System . Collections . Generic ;
76using System . Linq ;
87using System . Numerics ;
9- using System . Threading ;
108using SixLabors . ImageSharp . Drawing . Utilities ;
11- using SixLabors . ImageSharp . Memory ;
129using SixLabors . ImageSharp . PixelFormats ;
1310
1411namespace SixLabors . ImageSharp . Drawing . Processing
@@ -114,7 +111,7 @@ private static Color CalculateCenterColor(Color[] colors)
114111
115112 private static float DistanceBetween ( PointF p1 , PointF p2 ) => ( ( Vector2 ) ( p2 - p1 ) ) . Length ( ) ;
116113
117- private struct Intersection
114+ private readonly struct Intersection
118115 {
119116 public Intersection ( PointF point , float distance )
120117 {
@@ -189,7 +186,7 @@ private sealed class PathGradientBrushApplicator<TPixel> : BrushApplicator<TPixe
189186
190187 private readonly TPixel transparentPixel ;
191188
192- private ThreadLocalBlenderBuffers < TPixel > blenderBuffers ;
189+ private readonly ThreadLocalBlenderBuffers < TPixel > blenderBuffers ;
193190
194191 private bool isDisposed ;
195192
@@ -218,7 +215,7 @@ public PathGradientBrushApplicator(
218215 this . centerColor = ( Vector4 ) centerColor ;
219216 this . hasSpecialCenterColor = hasSpecialCenterColor ;
220217 this . centerPixel = centerColor . ToPixel < TPixel > ( ) ;
221- this . maxDistance = points . Select ( p => ( Vector2 ) ( p - this . center ) ) . Max ( d => d . Length ( ) ) ;
218+ this . maxDistance = points . Select ( p => p - this . center ) . Max ( d => d . Length ( ) ) ;
222219 this . transparentPixel = Color . Transparent . ToPixel < TPixel > ( ) ;
223220 this . blenderBuffers = new ThreadLocalBlenderBuffers < TPixel > ( configuration . MemoryAllocator , source . Width ) ;
224221 }
@@ -259,15 +256,15 @@ public PathGradientBrushApplicator(
259256 var direction = Vector2 . Normalize ( point - this . center ) ;
260257 Vector2 end = point + ( direction * this . maxDistance ) ;
261258
262- ( Edge edge , Vector2 point ) ? isc = this . FindIntersection ( point , end ) ;
259+ ( Edge Edge , Vector2 Point ) ? isc = this . FindIntersection ( point , end ) ;
263260
264261 if ( ! isc . HasValue )
265262 {
266263 return this . transparentPixel ;
267264 }
268265
269- Vector2 intersection = isc . Value . point ;
270- Vector4 edgeColor = isc . Value . edge . ColorAt ( intersection ) ;
266+ Vector2 intersection = isc . Value . Point ;
267+ Vector4 edgeColor = isc . Value . Edge . ColorAt ( intersection ) ;
271268
272269 float length = DistanceBetween ( intersection , this . center ) ;
273270 float ratio = length > 0 ? DistanceBetween ( intersection , point ) / length : 0 ;
@@ -327,7 +324,7 @@ protected override void Dispose(bool disposing)
327324 this . isDisposed = true ;
328325 }
329326
330- private ( Edge edge , Vector2 point ) ? FindIntersection (
327+ private ( Edge Edge , Vector2 Point ) ? FindIntersection (
331328 PointF start ,
332329 PointF end )
333330 {
@@ -350,7 +347,7 @@ protected override void Dispose(bool disposing)
350347 }
351348 }
352349
353- return closestEdge != null ? ( closestEdge , closestIntersection ) : ( ( Edge edge , Vector2 point ) ? ) null ;
350+ return closestEdge != null ? ( closestEdge , closestIntersection ) : ( ( Edge Edge , Vector2 Point ) ? ) null ;
354351 }
355352
356353 private static bool FindPointOnTriangle ( Vector2 v1 , Vector2 v2 , Vector2 v3 , Vector2 point , out float u , out float v )
0 commit comments