I am using PHP-Imagick and am trying to create a circle that would appear as a 3-Dimensional object eg. a ball. Given above is a rough example of what I am trying to achieve. Given below is a crude attempt of what I have gotten so far.
Below is the code that produced the image above. I need help to solve two obvious mistakes in the image. First, there is this another circle protruding from the highlight area. Second, the gradient is really bad around left of the circle.
$background = new Imagick();
$background->newImage(800,560,new ImagickPixel('#212121'));
$orb = new ImagickDraw();
for($i = 250; $i > 0; $i--){ //create the biggest circle first and then keep painting smaller circles over it.
$orb->push();
$blue = 350 - $i > 255 ? 255 : 350 - $i;
$red = 250 - $i;
$green = 250 - $i;
$color = 'rgba(' .$red. ',' .$green. ',' .$blue. ', 1)';
$orb->setFillColor($color);
$orb->ellipse( $i + 150 < 260 ? 260 : $i + 150,
$i + 30 < 210 ? 210 : $i + 30,
$i,
$i,
0, 360 );
$orb->pop();
}
$background->drawImage($orb);
$background->setImageFormat( "png" ); // set the image format to png
header("Content-Type: image/png"); // Output the image
echo $background;
I realize that the code is unscalable with fixed values and everything but this is the best I could do. Please help me correct it.