4) { break; } $Z_img = 2 * $Z_real * $Z_img + $K_img; $Z_real = $Z_real2 - $Z_img2 + $K_real; $iteration++; } $rgb = ($iteration == $maxIterations) ? [0, 0, 0] : smoothColor($iteration, $maxIterations, $Z_real, $Z_img, $colors, $bands, $brightnessFactor); $colorSum[0] += $rgb[0]; $colorSum[1] += $rgb[1]; $colorSum[2] += $rgb[2]; } } $finalColor = [ (int)($colorSum[0] / ($samples * $samples)), (int)($colorSum[1] / ($samples * $samples)), (int)($colorSum[2] / ($samples * $samples)) ]; $color = imagecolorallocate($gd, $finalColor[0], $finalColor[1], $finalColor[2]); imagesetpixel($gd, $x, $y, $color); } } header('Content-Type: image/png'); imagepng($gd); imagedestroy($gd); ?>