function gauss($x, $sigma, $mu) { $x_mu = $x - $mu; $y = (1 /($sigma * sqrt(2*pi())))*exp ( - pow($x -$mu, 2) /(2*pow($sigma,2))); return $y; } function norm($ar,$k) { if(is_array($ar)) { $max = max($ar); foreach($ar as $key =>$val) $out[$key] = (int) floor($k *($val / $max)); return $out; } } $img = imagecreatetruecolor(256,256); $res =15000; $sigma = 50; for($k =0; $k < 256; $k++) { for($g =0; $g < 256; $g++) { $w = $g; if( $w < 90) { $ar['red'][$w] = 0 ; } elseif($w >= 90 && $w < 180) { $ar['red'][$w] = floor(100*$res*gauss($w, 30, 90)); } elseif($w >= 180) { $ar['red'][$w] = floor($res*gauss($w, 30, 255)); } $ar['green'][$w] = floor($res*gauss($w, 50, 126)); $ar['blue'][$w] = floor($res*gauss($w, 50, 190)); } $ar['red'] = norm( $ar['red'], 255); $ar['green'] = norm( $ar['green'], 255); $ar['blue'] = norm( $ar['blue'], 255); foreach($ar['red'] as $key => $val ) { if($key <= 90) { $color = imagecolorallocate($img, 255, $ar['green'][$key], $ar['blue'][$key]); } else { $color = imagecolorallocate($img, $val, $ar['green'][$key] , $ar['blue'][$key]); } imagesetpixel($img, $k, $key, $color); } } header("Content-type: image/png"); imagepng($img);