= 20.0 ) $mar = 3.0; $total_area = 0.00 + $width*$height; $img = imagecreatetruecolor($width, $height); $white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); $red = imagecolorallocate($img, 255, 0, 0); $yel = imagecolorallocate($img, 255, 255, 0); $blu = imagecolorallocate($img, 0, 0, 255); $colors = array($red, $yel, $blu); // Here's where the "whiteness" parameter gets used: for ($i = 0; $i < $whiteness; ++$i) $colors[] = $white; $a = array(); // Black lines $b = array(); // Colored-in boxes mond($density, 0, $a, 0, 0, $width, $height, $b); // Even if $maf set to value > 1.00, and whiteness set to 0, // some boxes show up white. They never get into the $boxes // array in mond(), because of $buffer checks or something. imagefill($img, 0, 0, $white); imagesetthickness($img, 4); // Did Piet Mondrian vary line thickness? // Color in boxes, as designated during mond() execution. foreach ($b as $box) { $area = abs($box[0] - $box[2]) * abs($box[1] - $box[3]); $frac = $area/$total_area; $aspect_ratio = abs(floatval($box[0] - $box[2]))/abs(floatval($box[1] - $box[3])); if ($aspect_ratio < 1.0) $aspect_ratio = 1.0/$aspect_ratio; if ($frac <= $maf && $aspect_ratio <= $mar) { imagefilledrectangle( $img, $box[0], $box[1], $box[2], $box[3], $colors[array_rand($colors)] ); } } // Draw in black lines. foreach ($a as $line) { imageline($img, $line[0][0], $line[0][1], $line[1][0], $line[1][1], $black); } imagepng($img); imagedestroy($img); ?>