array(0xff, 0x00, 0x00), 1 => array(0xff, 0x80, 0x00), 2 => array(0xff, 0xff, 0x00), 3 => array(0x00, 0xff, 0x00), 4 => array(0x00, 0x00, 0xff), 5 => array(0x00, 0xff, 0xff), 6 => array(0xff, 0x00, 0xff)); foreach ($colors as &$color) { $color = imagecolorallocate($newimage,$color[0],$color[1],$color[2]); } echo "Assigning pi\n"; $pi = "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679" ."8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196" ."4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273" ."7245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094" ."3305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912" ."9833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132" ."000568127145263560827785"; //from http://www.exploratorium.edu/pi/Pi10-6.html echo "Digits of Pi available: " . strlen($pi); $length_of_pi = strlen($pi); for($i = 0; $i < $length_of_pi; $i++) { $current_pixel_y = floor($i/25); $current_pixel_x = $i % 25; $colorindex = $pi[$i] % 7; $new_x = $current_pixel_x * 10; $new_y = $current_pixel_y * 10; $end_x = $new_x + 10; $end_y = $new_y + 10; imagefilledrectangle($newimage,$new_x,$new_y,$end_x,$end_y,$colors[$colorindex]); } imagepng($newimage,"C:\\Users\\Nic\\Desktop\\new-pi.png"); imagedestroy($newimage);