1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
This file is part of WideImage. |
4
|
|
|
|
5
|
|
|
WideImage is free software; you can redistribute it and/or modify |
6
|
|
|
it under the terms of the GNU Lesser General Public License as published by |
7
|
|
|
the Free Software Foundation; either version 2.1 of the License, or |
8
|
|
|
(at your option) any later version. |
9
|
|
|
|
10
|
|
|
WideImage is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
GNU Lesser General Public License for more details. |
14
|
|
|
|
15
|
|
|
You should have received a copy of the GNU Lesser General Public License |
16
|
|
|
along with WideImage; if not, write to the Free Software |
17
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18
|
|
|
|
19
|
|
|
* @package Tests |
20
|
|
|
**/ |
21
|
|
|
|
22
|
|
|
namespace Test\WideImage; |
23
|
|
|
|
24
|
|
|
use WideImage\WideImage; |
25
|
|
|
use Test\WideImage_TestCase; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @package Tests |
29
|
|
|
*/ |
30
|
|
|
class CanvasTest extends WideImage_TestCase |
31
|
|
|
{ |
32
|
|
|
public function testCreate() |
33
|
|
|
{ |
34
|
|
|
$img = WideImage::createTrueColorImage(10, 10); |
35
|
|
|
|
36
|
|
|
$canvas1 = $img->getCanvas(); |
37
|
|
|
$this->assertInstanceOf('WideImage\\Canvas', $canvas1); |
38
|
|
|
|
39
|
|
|
$canvas2 = $img->getCanvas(); |
40
|
|
|
$this->assertSame($canvas1, $canvas2); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testMagicCallDrawRectangle() |
44
|
|
|
{ |
45
|
|
|
$img = WideImage::createTrueColorImage(10, 10); |
46
|
|
|
$canvas = $img->getCanvas(); |
47
|
|
|
$canvas->filledRectangle(1, 1, 5, 5, $img->allocateColorAlpha(255, 0, 0, 64)); |
|
|
|
|
48
|
|
|
$this->assertRGBAt($img, 3, 3, array('red' => 255, 'green' => 0, 'blue' => 0, 'alpha' => 64)); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|