dousi9215 2015-10-21 16:16
浏览 41

PHP-Imagick:创建一个具有三维效果的圆圈

test 3D ball

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.

crude attempt

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改
    • ¥20 wireshark抓不到vlan
    • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
    • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持