-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquareBitmap.php
More file actions
40 lines (31 loc) · 921 Bytes
/
Copy pathSquareBitmap.php
File metadata and controls
40 lines (31 loc) · 921 Bytes
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
<?php
namespace LazyBitmap;
use LazyBitmap\Bitmap;
use LazyBitmap\Pixel;
class SquareBitmap extends Bitmap {
private $relativeSize;
private $width;
private $height;
public function __construct($relativeSize, $width, $height) {
$this->relativeSize = (1 - $relativeSize) / 2;
$this->width = $width;
$this->height = $height;
}
public function getPixel($x, $y) {
if ($this->width * $this->relativeSize <= $x &&
$x < $this->width * (1 - $this->relativeSize) &&
$this->height * $this->relativeSize <= $y &&
$y < $this->height * (1 - $this->relativeSize)
) {
return new Pixel(255, 255, 255);
} else {
return new Pixel;
}
}
public function getWidth() {
return $this->width;
}
public function getHeight() {
return $this->height;
}
}