@@ -43,7 +43,7 @@ public static void AddQuietZone(QRCodeData qrCode)
43
43
/// <param name="versionStr">The bit array containing the version information.</param>
44
44
public static void PlaceVersion ( QRCodeData qrCode , BitArray versionStr )
45
45
{
46
- var size = qrCode . ModuleMatrix . Count ; // The size of the QR code matrix.
46
+ var size = qrCode . ModuleMatrix . Count ;
47
47
48
48
// Loop through each module position intended for version information, placed adjacent to the separators.
49
49
for ( var x = 0 ; x < 6 ; x ++ )
@@ -214,7 +214,7 @@ public static void PlaceDataWords(QRCodeData qrCode, BitArray data, List<Rectang
214
214
if ( up )
215
215
{
216
216
y = size - yMod ; // Calculate y for upward direction.
217
- // Place data if within data length, current position is not blocked, and leftward column is in bounds.
217
+ // Place data if within data length, current position is not blocked, and leftward column is in bounds.
218
218
if ( index < count && ! IsBlocked ( new Rectangle ( x , y , 1 , 1 ) , blockedModules ) )
219
219
qrCode . ModuleMatrix [ y ] [ x ] = data [ index ++ ] ;
220
220
if ( index < count && x > 0 && ! IsBlocked ( new Rectangle ( x - 1 , y , 1 , 1 ) , blockedModules ) )
@@ -223,7 +223,7 @@ public static void PlaceDataWords(QRCodeData qrCode, BitArray data, List<Rectang
223
223
else
224
224
{
225
225
y = yMod - 1 ; // Calculate y for downward direction.
226
- // Similar checks and data placement for the downward direction.
226
+ // Similar checks and data placement for the downward direction.
227
227
if ( index < count && ! IsBlocked ( new Rectangle ( x , y , 1 , 1 ) , blockedModules ) )
228
228
qrCode . ModuleMatrix [ y ] [ x ] = data [ index ++ ] ;
229
229
if ( index < count && x > 0 && ! IsBlocked ( new Rectangle ( x - 1 , y , 1 , 1 ) , blockedModules ) )
@@ -284,7 +284,7 @@ public static void ReserveVersionAreas(int size, int version, List<Rectangle> bl
284
284
public static void PlaceDarkModule ( QRCodeData qrCode , int version , List < Rectangle > blockedModules )
285
285
{
286
286
// Place the dark module, which is always required to be black.
287
- qrCode . ModuleMatrix [ 4 * version + 9 ] [ 8 ] = true ; // Calculated position for the dark module based on the version
287
+ qrCode . ModuleMatrix [ 4 * version + 9 ] [ 8 ] = true ;
288
288
// Block the dark module area to prevent overwriting during further QR code generation steps.
289
289
blockedModules . Add ( new Rectangle ( 8 , 4 * version + 9 , 1 , 1 ) ) ;
290
290
}
@@ -296,7 +296,7 @@ public static void PlaceDarkModule(QRCodeData qrCode, int version, List<Rectangl
296
296
/// <param name="blockedModules">A list of rectangles representing areas that must not be overwritten. This is updated with the areas occupied by the finder patterns.</param>
297
297
public static void PlaceFinderPatterns ( QRCodeData qrCode , List < Rectangle > blockedModules )
298
298
{
299
- var size = qrCode . ModuleMatrix . Count ; // Get the size of the QR code matrix.
299
+ var size = qrCode . ModuleMatrix . Count ;
300
300
301
301
// Loop to place three finder patterns in the top-left, top-right, and bottom-left corners of the QR code.
302
302
for ( var i = 0 ; i < 3 ; i ++ )
@@ -399,9 +399,6 @@ public static void PlaceTimingPatterns(QRCodeData qrCode, List<Rectangle> blocke
399
399
/// <summary>
400
400
/// Determines if two rectangles intersect with each other.
401
401
/// </summary>
402
- /// <param name="r1">The first rectangle.</param>
403
- /// <param name="r2">The second rectangle to check for intersection with the first.</param>
404
- /// <returns>True if the rectangles intersect; otherwise, false.</returns>
405
402
private static bool Intersects ( Rectangle r1 , Rectangle r2 )
406
403
{
407
404
// Check if any part of the rectangles overlap.
@@ -413,16 +410,15 @@ private static bool Intersects(Rectangle r1, Rectangle r2)
413
410
/// </summary>
414
411
/// <param name="r1">The rectangle to check.</param>
415
412
/// <param name="blockedModules">The list of rectangles representing blocked areas.</param>
416
- /// <returns>True if the rectangle is blocked; otherwise, false.</returns>
417
413
private static bool IsBlocked ( Rectangle r1 , List < Rectangle > blockedModules )
418
414
{
419
415
// Iterate through the list of blocked modules to check for any intersection.
420
416
foreach ( var blockedMod in blockedModules )
421
417
{
422
418
if ( Intersects ( blockedMod , r1 ) )
423
- return true ; // Return true if an intersection is found, indicating the area is blocked.
419
+ return true ;
424
420
}
425
- return false ; // Return false if no intersections are found, indicating the area is not blocked.
421
+ return false ;
426
422
}
427
423
}
428
424
}
0 commit comments