const XMIN = -2.0; const XMAX = 1.0; const YMIN = -1.0; const YMAX = 1.0; function escapes(float $cr, float $ci, int $it): bool { $zr = 0.0; $zi = 0.0; for($i=0; $i<$it; $i++) { $zrtmp = $zr*$zr - $zi*$zi + $cr; $zi = 2*$zr*$zi + $ci; $zr = $zrtmp; if ($zr*$zr + $zi*$zi > 4) { return True; } } return False; } function mandel(int $xstep, int $ystep, int $iters) { $output = ""; for($yc=0; $yc<$ystep; $yc++) { $y = $yc*(YMAX-YMIN)/$ystep + YMIN; for($xc=0; $xc<$xstep; $xc++) { $x = $xc*(XMAX-XMIN)/$xstep + XMIN; if (escapes($x, $y, $iters)) { $output .= ' '; } else { $output .= 'X'; } } $output .= "\n"; } echo $output; } <<__EntryPoint>> function main(): void { $argv = vec(\HH\global_get('argv') as Container<_>); mandel(intval($argv[1]), intval($argv[2]), intval($argv[3])); }