ImagickDraw::pathLineToRelative

(PECL imagick 2, PECL imagick 3)

ImagickDraw::pathLineToRelative β€” РисуСт линию

ОписаниС

public function ImagickDraw::pathLineToRelative(float $x, float $y): bool
Π’Π½ΠΈΠΌΠ°Π½ΠΈΠ΅

Π€ΡƒΠ½ΠΊΡ†ΠΈΡŽ ΠΏΠΎΠΊΠ° Π½Π΅ Π·Π°Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ΠΈΡ€ΠΎΠ²Π°Π»ΠΈ; для знакомства доступСн Ρ‚ΠΎΠ»ΡŒΠΊΠΎ список Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚ΠΎΠ².

РисуСт линию ΠΎΡ‚ Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ Ρ‚ΠΎΡ‡ΠΊΠΈ Π΄ΠΎ Π·Π°Π΄Π°Π½Π½ΠΎΠΉ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Ρ‹ с использованиСм ΠΎΡ‚Π½ΠΎΡΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹Ρ… ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚. Π—Π°Ρ‚Π΅ΠΌ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π° становится Π½ΠΎΠ²ΠΎΠΉ Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ Ρ‚ΠΎΡ‡ΠΊΠΎΠΉ.

Бписок ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ²

x

ΠΠ°Ρ‡Π°Π»ΡŒΠ½Π°Ρ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π° X

y

ΠΠ°Ρ‡Π°Π»ΡŒΠ½Π°Ρ ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π° Y

Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΡ‹Π΅ значСния

Ѐункция Π½Π΅ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ значСния послС выполнСния.

οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 1 note

up
0
Axeia ΒΆ
17 years ago
Hope this of help of anything, I had one hell of a time to draw a simple pie slice, where in GD2 is very easily done with the 'arc' function.. this is a bit harder to do in imagick.

The degrees are a mess, seems like the path, arc and ellipse functions all use a different system.. utterly confusing.
Code below should at least be of help in understanding how it works.

For an example of the output, please see: 
http://www.imagebam.com/image/8e0ca432393602
<?php
    function getPointOnCircumference( $widthOfCircle, $heightOfCircle, $degrees, $x = 0, $y = 0 )
    {
        return array( 
            'x' => $x + ($widthOfCircle/2)  * sin( deg2rad( $degrees ) ),
            'y' => $y + ($heightOfCircle/2) * cos( deg2rad( $degrees ) )
        );
    }
    
    $width  = 200;
    $height = 200;
    $border = 2;
    $x = $width / 2;
    $y = $height / 2;
    $im = new Imagick();
    $im->newImage( $width, $height, "orange", "png" );
    
    
    $draw = new ImagickDraw();
    $draw->setFillColor( 'lime' );
    $draw->setStrokeColor( new ImagickPixel( 'black' ) );
    $draw->setStrokeWidth( 2 );
    $draw->arc( 0, 0, ($width-$border), ($height-$border), 270, 360  ); //270 till 360 degrees
    $im->DrawImage( $draw );
    
    $draw2 = new ImagickDraw();
    $draw2->setFillColor( 'red' );
    $draw2->setStrokeColor( new ImagickPixel( 'black' ) );
    $draw2->setStrokeWidth( 2 );
    $draw2->ellipse( 100, 100, $x-$border, $y-$border, 0, 90 );         //0 till 90 degrees
    $im->DrawImage( $draw2 );
    
    $draw3 = new ImagickDraw();
    $draw3->setFillColor( 'navy' );
    $draw3->setStrokeColor( new ImagickPixel( 'white' ) );
    $draw3->setStrokeWidth( 2 );
    $draw3->pathStart();
      $degrees90  = getPointOnCircumference( $width-2*$border,$height-2*$border, 360  );
      $degrees180 = getPointOnCircumference( $width-2*$border,$height-2*$border, 270 );
      $draw3->pathMoveToRelative( $x, $y ); //Move 'pencil' to middle of image.
      $draw3->pathLineToRelative(  $degrees90['x'],  $degrees90['y'] );
      $draw3->pathEllipticArcRelative( $width-$border, $height-$border, 0, false, true, $degrees180['x'], $degrees180['y']-$y+$border );
    $draw3->pathClose();
    $im->DrawImage( $draw3 );    
    
    header( "Content-Type: image/png" );
    echo $im;
?>