<?php

echo "=== ISO/IEC 18004 Mask Patterns ===\n\n";

echo "Pattern 0: (row + column) % 2 == 0\n";
echo "Pattern 1: row % 2 == 0\n";
echo "Pattern 2: column % 3 == 0\n";
echo "Pattern 3: (row + column) % 3 == 0\n";
echo "Pattern 4: (floor(row/2) + floor(column/3)) % 2 == 0\n";
echo "Pattern 5: (row * column) % 2 + (row * column) % 3 == 0\n";
echo "Pattern 6: ((row * column) % 2 + (row * column) % 3) % 2 == 0\n";
echo "Pattern 7: ((row + column) % 2 + (row * column) % 3) % 2 == 0\n\n";

// According to our Format Information, we're using Pattern 2
// Pattern 2 = "column % 3 == 0" 

// Let's check which pattern Python uses (Pattern 0)
echo "Python uses Pattern 0: (row + column) % 2 == 0\n";
echo "We use Pattern 2: column % 3 == 0\n\n";

// Both are valid patterns! The issue is our mask application might be wrong
// Let's visualize Pattern 2
echo "Pattern 2 visualization (column % 3 == 0):\n";
echo "  Col: 0 1 2 3 4 5 6 7 8\n";
for ($r = 0; $r < 5; $r++) {
    echo "Row $r: ";
    for ($c = 0; $c < 9; $c++) {
        echo ($c % 3 === 0 ? '1' : '0') . ' ';
    }
    echo "\n";
}

echo "\nExpected: Vertical stripes at columns 0, 3, 6, ...\n";

