[class用于在用户栏上呈现数据。
效果很好,但我想澄清一下。在此过程中,数据会叠加在图像上,并且clone
和Imagick
都应使用ImagickDraw
-保存以前的叠加层。
private function createImage($file): Imagick
{
$this->Imagick = new Imagick(__DIR__.'/Draw/Images/'.$file);
return $this->Imagick;
}
[C0的用法示例:
clone
最后结果是这样的:
private function drawRank(): Imagick
{
$image = clone $this->Imagick;
$rank = $this->createImage(self::RANK_IMAGE);
$rank->cropImage(32, 32, 0, $this->vector[$this->interface->rank_id]);
$image->compositeImage($rank, Imagick::COMPOSITE_DEFAULT, 64, 18);
return $image;
}
这有多正确?我对此方法表示怀疑。这是正常做法吗?
错误逻辑:
private function call()
{
$this->Imagick = $this->createImage(self::BACKGROUND_IMAGE[$this->l]);
$this->Imagick = $this->drawRank();
$this->Imagick = $this->drawingProfile();
header('Content-Type: image/'.$this->Imagick->getImageFormat());
echo $this->Imagick;
}
尝试这种方式
A=1
A=2
A=3
here A=3, value 1 and 2 are lost !
然后用CompositeImage组成最终图像
$im1 = $this->createImage(self::BACKGROUND_IMAGE[$this->l]);
$im2 = $this->drawRank();
$im3 = $this->drawingProfile();