(PECL imagick 2.0.0)
Sets the fill rule to use while drawing polygons
bool ImagickDraw::setFillRule ( int $fill_rule )
Sets the fill rule to use while drawing polygons.
Parameters:
fill_rule
FILLRULE_ constant
Returns:
No value is returned.
This function is currently not documented; only its argument list is available.
Examples:
ImagickDraw::setFillRule()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <?php function setFillRule( $fillColor , $strokeColor , $backgroundColor ) { $draw = new \ImagickDraw(); $draw ->setStrokeWidth(1); $draw ->setStrokeColor( $strokeColor ); $draw ->setFillColor( $fillColor ); $fillRules = [\Imagick::FILLRULE_NONZERO, \Imagick::FILLRULE_EVENODD]; $points = 11; $size = 150; $draw ->translate(175, 160); for ( $x = 0; $x < 2; $x ++) { $draw ->setFillRule( $fillRules [ $x ]); $draw ->pathStart(); for ( $n = 0; $n < $points * 2; $n ++) { if ( $n >= $points ) { $angle = fmod ( $n * 360 * 4 / $points , 360) * pi() / 180; } else { $angle = fmod ( $n * 360 * 3 / $points , 360) * pi() / 180; } $positionX = $size * sin( $angle ); $positionY = $size * cos ( $angle ); if ( $n == 0) { $draw ->pathMoveToAbsolute( $positionX , $positionY ); } else { $draw ->pathLineToAbsolute( $positionX , $positionY ); } } $draw ->pathClose(); $draw ->pathFinish(); $draw ->translate(325, 0); } $image = new \Imagick(); $image ->newImage(700, 320, $backgroundColor ); $image ->setImageFormat( "png" ); $image ->drawImage( $draw ); header( "Content-Type: image/png" ); echo $image ->getImageBlob(); } ?> |
Please login to continue.