ImagickDraw::affine

(PECL imagick 2, PECL imagick 3)

ImagickDraw::affineGeçerli homojen koordinatlar matrisini ayarlar

Açıklama

public function ImagickDraw::affine(array $matris): bool

Belirtilen matrise göre homojen koordinatlar matrisini ayarlar.

Bağımsız Değişkenler

matris

Bir dizi olarak homojen koordinatlar matrisi (Affine matrix).

Dönen Değerler

Hiçbir değer dönmez.

Örnekler

Örnek 1 - ImagickDraw::affine() örneği

<?php
function affine($strokeColor, $fillColor, $backgroundColor) {

    $draw = new \ImagickDraw();

    $draw->setStrokeWidth(1);
    $draw->setStrokeOpacity(1);
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);

    $draw->setStrokeWidth(2);

    $PI = 3.141592653589794;
    $angle = 60 * $PI / 360;

    // Çizim koordinatlarını ölçekle.
    $affineScale = array("sx" => 1.75, "sy" => 1.75, "rx" => 0, "ry" => 0, "tx" => 0, "ty" => 0);

    // Çizim koordinatlarını kırp
    $affineShear = array("sx" => 1, "sy" => 1, "rx" => sin($angle), "ry" => -sin($angle), "tx" => 0, "ty" => 0);

    // Çizim koordinatlarını döndür. Kırpma koordinatları matrisi
    // yanlış ölçeklendirilmiş çizimler üretir.
    $affineRotate = array("sx" => cos($angle), "sy" => cos($angle), "rx" => sin($angle), "ry" => -sin($angle), "tx" => 0, "ty" => 0,);

    // Çizimi dönüştür
    $affineTranslate = array("sx" => 1, "sy" => 1, "rx" => 0, "ry" => 0, "tx" => 30, "ty" => 30);

    // Tanımlı homojen koordinatlar matrisi
    $affineIdentity = array("sx" => 1, "sy" => 1, "rx" => 0, "ry" => 0, "tx" => 0, "ty" => 0);

    $examples = [$affineScale, $affineShear, $affineRotate, $affineTranslate, $affineIdentity,];

    $count = 0;

    foreach ($examples as $example) {
        $draw->push();
        $draw->translate(($count % 2) * 250, intval($count / 2) * 250);
        $draw->translate(100, 100);
        $draw->affine($example);
        $draw->rectangle(-50, -50, 50, 50);
        $draw->pop();
        $count++;
    }

    // Çizim komutlarının işlenebileceği bir görüntü nesnesi oluştur
    $image = new \Imagick();
    $image->newImage(500, 750, $backgroundColor);
    $image->setImageFormat("png");

    // ImagickDraw nesnesindeki çizim komutlarını görüntüye işle
    $image->drawImage($draw);

    // Görüntüyü tarayıcıya gönder
    header("Content-Type: image/png");
    echo $image->getImageBlob();
}

?>

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top