-
-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathImage.drawing.phpt
More file actions
38 lines (24 loc) · 1.12 KB
/
Image.drawing.phpt
File metadata and controls
38 lines (24 loc) · 1.12 KB
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
<?php
/**
* Test: Nette\Utils\Image drawing.
* @phpExtension gd
*/
declare(strict_types=1);
use Nette\Utils\Image;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$size = 300;
$image = Image::fromBlank($size, $size);
$image->filledRectangle(0, 0, $size - 1, $size - 1, Image::rgb(255, 255, 255));
$image->rectangle(0, 0, $size - 1, $size - 1, Image::rgb(0, 0, 0));
$radius = 150;
$image->filledEllipse(100, 75, $radius, $radius, Image::rgb(255, 255, 0, 75));
$image->filledEllipse(120, 168, $radius, $radius, Image::rgb(255, 0, 0, 75));
$image->filledEllipse(187, 125, $radius, $radius, Image::rgb(0, 0, 255, 75));
$image->copyResampled($image, 200, 200, 0, 0, 80, 80, $size, $size);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.1.png'), $image->toString(Image::PNG, 0));
// palette-based image
$image = Image::fromFile(__DIR__ . '/images/logo.gif');
$image->filledEllipse(100, 50, 50, 50, Image::rgb(255, 255, 0, 75));
$image->filledEllipse(100, 150, 50, 50, Image::rgb(255, 255, 0, 75));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.2.png'), $image->toString(Image::PNG, 0));