-
Notifications
You must be signed in to change notification settings - Fork 0
/
paint.php
executable file
·54 lines (46 loc) · 1.15 KB
/
paint.php
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
<?php
namespace PMVC\PlugIn\paint;
use PMVC\PlugIn\image\ImageFile;
use PMVC\PlugIn\image\ImageSize;
use PMVC\PlugIn\image\Coord2D;
use PMVC\PlugIn\color\BaseColor;
\PMVC\l(__DIR__.'/src/ImagePaint.php');
${_INIT_CONFIG}[_CLASS] = __NAMESPACE__.'\paint';
class paint extends \PMVC\PlugIn
{
public function getPaintBySize($w, $h, BaseColor $color = null)
{
$canvas = new ImagePaint(new ImageSize($w, $h));
if (is_null($color)) {
$color = $this->getColor(255,255,255);
}
\PMVC\plug('color')->fill(
$canvas,
$color
);
return $canvas;
}
public function getPaintByFile($f)
{
return new ImagePaint(new ImageFile($f));
}
public function getResource($file)
{
$file = \PMVC\realpath($this->getDir().'resource/'.$file);
if($file){
return $file;
}
}
public function getPoint($x, $y)
{
return new Coord2D($x, $y);
}
public function getColor($r=null, $g=null, $b=null)
{
return \PMVC\plug('color')->getColor(
$r,
$g,
$b
);
}
}