@@ -46,8 +46,7 @@ public void HorizontalLinearGradientBrushReturnsUnicolorColumns()
4646 int width = 500 ;
4747 int height = 10 ;
4848 int lastColumnIndex = width - 1 ;
49-
50-
49+
5150 string path = TestEnvironment . CreateOutputDirectory ( "Fill" , "LinearGradientBrush" ) ;
5251 using ( var image = new Image < Rgba32 > ( width , height ) )
5352 {
@@ -81,15 +80,14 @@ public void HorizontalLinearGradientBrushReturnsUnicolorColumns()
8180 }
8281 }
8382 }
84-
83+
8584 [ Fact ]
8685 public void VerticalLinearGradientBrushReturnsUnicolorColumns ( )
8786 {
8887 int width = 10 ;
8988 int height = 500 ;
9089 int lastRowIndex = height - 1 ;
91-
92-
90+
9391 string path = TestEnvironment . CreateOutputDirectory ( "Fill" , "LinearGradientBrush" ) ;
9492 using ( var image = new Image < Rgba32 > ( width , height ) )
9593 {
@@ -99,7 +97,7 @@ public void VerticalLinearGradientBrushReturnsUnicolorColumns()
9997 new SixLabors . Primitives . Point ( 0 , 500 ) ,
10098 new LinearGradientBrush < Rgba32 > . ColorStop ( 0 , Rgba32 . Red ) ,
10199 new LinearGradientBrush < Rgba32 > . ColorStop ( 1 , Rgba32 . Yellow ) ) ;
102-
100+
103101 image . Mutate ( x => x . Fill ( unicolorLinearGradientBrush ) ) ;
104102 image . Save ( $ "{ path } /verticalRedToYellow.png") ;
105103
@@ -108,13 +106,13 @@ public void VerticalLinearGradientBrushReturnsUnicolorColumns()
108106 Rgba32 columnColor23 = sourcePixels [ 0 , 23 ] ;
109107 Rgba32 columnColor42 = sourcePixels [ 0 , 42 ] ;
110108 Rgba32 columnColor333 = sourcePixels [ 0 , 333 ] ;
111-
109+
112110 for ( int i = 0 ; i < width ; i ++ )
113111 {
114112 // check first and last column, these are known:
115113 Assert . Equal ( Rgba32 . Red , sourcePixels [ i , 0 ] ) ;
116114 Assert . Equal ( Rgba32 . Yellow , sourcePixels [ i , lastRowIndex ] ) ;
117-
115+
118116 // check the random colors:
119117 Assert . Equal ( columnColor23 , sourcePixels [ i , 23 ] ) ;
120118 Assert . Equal ( columnColor42 , sourcePixels [ i , 42 ] ) ;
@@ -123,7 +121,7 @@ public void VerticalLinearGradientBrushReturnsUnicolorColumns()
123121 }
124122 }
125123 }
126-
124+
127125 [ Theory ]
128126 [ InlineData ( 0 , 0 , 499 , 499 ) ]
129127 [ InlineData ( 0 , 499 , 499 , 0 ) ]
@@ -134,8 +132,7 @@ public void DiagonalLinearGradientBrushReturnsUnicolorColumns(
134132 {
135133 int size = 500 ;
136134 int lastIndex = size - 1 ;
137-
138-
135+
139136 string path = TestEnvironment . CreateOutputDirectory ( "Fill" , "LinearGradientBrush" ) ;
140137 using ( var image = new Image < Rgba32 > ( size , size ) )
141138 {
@@ -145,7 +142,7 @@ public void DiagonalLinearGradientBrushReturnsUnicolorColumns(
145142 new SixLabors . Primitives . Point ( endX , endY ) ,
146143 new LinearGradientBrush < Rgba32 > . ColorStop ( 0 , Rgba32 . Red ) ,
147144 new LinearGradientBrush < Rgba32 > . ColorStop ( 1 , Rgba32 . Yellow ) ) ;
148-
145+
149146 image . Mutate ( x => x . Fill ( unicolorLinearGradientBrush ) ) ;
150147 image . Save ( $ "{ path } /diagonalRedToYellowFrom{ startX } _{ startY } .png") ;
151148
@@ -155,16 +152,20 @@ public void DiagonalLinearGradientBrushReturnsUnicolorColumns(
155152 Assert . Equal ( Rgba32 . Red , sourcePixels [ startX , startY ] ) ;
156153 Assert . Equal ( Rgba32 . Yellow , sourcePixels [ endX , endY ] ) ;
157154
155+ for ( int i = 0 ; i < size ; i ++ )
156+ {
157+ // it's diagonal, so for any (a, a) on the gradient line, for all (a-x, b+x) - +/- depending on the diagonal direction - must be the same color)
158+ }
158159 }
159160 }
160161 }
161-
162+
162163 [ Theory ]
163164 [ InlineData ( "a" , 0 , 0 , 499 , 499 , new [ ] { 0f , .2f , .5f , .9f } , new [ ] { 0 , 0 , 1 , 1 } ) ]
164165 [ InlineData ( "b" , 0 , 499 , 499 , 0 , new [ ] { 0f , 0.2f , 0.5f , 0.9f } , new [ ] { 0 , 1 , 2 , 3 } ) ]
165166 [ InlineData ( "c" , 499 , 499 , 0 , 0 , new [ ] { 0f , 0.7f , 0.8f , 0.9f } , new [ ] { 0 , 1 , 2 , 0 } ) ]
166167 [ InlineData ( "d" , 0 , 0 , 499 , 499 , new [ ] { 0f , .5f , 1f } , new [ ] { 0 , 1 , 3 } ) ]
167- public void ArbitraryLinearGradientsProduceImages_VisualCheckOnly (
168+ public void ArbitraryLinearGradientsProduceImagesVisualCheckOnly (
168169 string filenameSuffix ,
169170 int startX , int startY ,
170171 int endX , int endY ,
@@ -178,20 +179,17 @@ public void ArbitraryLinearGradientsProduceImages_VisualCheckOnly(
178179 Rgba32 . Yellow ,
179180 Rgba32 . Red
180181 } ;
181-
182+
182183 var colorStops = new LinearGradientBrush < Rgba32 > . ColorStop [ stopPositions . Length ] ;
183184 for ( int i = 0 ; i < stopPositions . Length ; i ++ )
184185 {
185186 colorStops [ i ] = new LinearGradientBrush < Rgba32 > . ColorStop (
186187 stopPositions [ i ] ,
187188 colors [ stopColorCodes [ i ] ] ) ;
188189 }
189-
190-
190+
191191 int size = 500 ;
192- int lastIndex = size - 1 ;
193-
194-
192+
195193 string path = TestEnvironment . CreateOutputDirectory ( "Fill" , "LinearGradientBrush" ) ;
196194 using ( var image = new Image < Rgba32 > ( size , size ) )
197195 {
@@ -200,17 +198,9 @@ public void ArbitraryLinearGradientsProduceImages_VisualCheckOnly(
200198 new SixLabors . Primitives . Point ( startX , startY ) ,
201199 new SixLabors . Primitives . Point ( endX , endY ) ,
202200 colorStops ) ;
203-
201+
204202 image . Mutate ( x => x . Fill ( unicolorLinearGradientBrush ) ) ;
205203 image . Save ( $ "{ path } /arbitraryGradient_{ filenameSuffix } .png") ;
206-
207- using ( PixelAccessor < Rgba32 > sourcePixels = image . Lock ( ) )
208- {
209- for ( int i = 0 ; i < size ; i ++ )
210- {
211- // it's diagonal, so for any (a, a) on the gradient line, for all (a-x, b+x) - +/- depending on the diagonal direction - must be the same color)
212- }
213- }
214204 }
215205 }
216206 }
0 commit comments