예제 #1
0
파일: gd.php 프로젝트: nicksagona/PopPHP
<?php

require_once '../../bootstrap.php';
use Pop\Color\Space\Rgb;
use Pop\Image\Gd;
try {
    $points = array(array('x' => 320, 'y' => 50), array('x' => 400, 'y' => 100), array('x' => 420, 'y' => 200), array('x' => 280, 'y' => 320), array('x' => 200, 'y' => 180));
    $image = new Gd('new-image.jpg', 640, 480, new Rgb(255, 0, 0));
    $image->setFillColor(new Rgb(0, 0, 255))->setStrokeColor(new Rgb(255, 255, 255))->setStrokeWidth(3)->drawPolygon($points)->output();
    // Calling the destructor destroys the image resource as well
    unset($image);
} catch (\Exception $e) {
    echo $e->getMessage();
}
예제 #2
0
 public function testAddPolygon()
 {
     $i = new Gd(__DIR__ . '/../tmp/test.jpg');
     $points = array(array('x' => 320, 'y' => 50), array('x' => 400, 'y' => 100), array('x' => 420, 'y' => 200), array('x' => 280, 'y' => 320), array('x' => 200, 'y' => 180));
     $i->setStrokeColor(new Rgb(0, 0, 0))->drawPolygon($points);
     $i->setBackgroundColor(new Rgb(255, 0, 0));
     $i->drawPolygon($points);
     $i->setFillColor(new Rgb(255, 0, 0));
     $i->drawPolygon($points);
     $this->assertEquals(640, $i->getWidth());
 }