-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathescapeTime.php
executable file
·68 lines (55 loc) · 1.72 KB
/
escapeTime.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
include('palette.php');
include('paletteLinear.php');
class EscapeTime {
protected $_minX;
protected $_maxX;
protected $_minY;
protected $_maxY;
protected $_imageWidth;
protected $_imageHeight;
protected $_showScale;
protected $_maxIterations;
public function __construct(Array $limits,Array $size, $maximumIterations = 200, $showScale = false) {
list($this->_minX, $this->_maxX, $this->_minY, $this->_maxY) = $limits;
list($this->_imageWidth, $this->_imageHeight) = $size;
$this->_maxIterations = $maximumIterations;
}
public function __destruct() {
imagedestroy($this->_image);
unset($this->_image);
unset($this->_colours);
}
public function setUpImage() {
$this->_image = imagecreate($this->_imageWidth, $this->_imageHeight);
// Load the palette to find colours
$this->_colours = new Palette($this->_maxIterations, $this->_image);
}
public function zoom($factor) {
$this->_minX = $this->_minX / $factor;
$this->_minY = $this->_minY / $factor;
$this->_maxX = $this->_maxX / $factor;
$this->_maxY = $this->_maxY / $factor;
}
public function centre($x, $y) {
$width = $this->_maxX - $this->_minX;
$height = $this->_maxY - $this->_minY;
$this->_minX = $x - $width / 2;
$this->_maxX = $x + $width / 2;
$this->_minY = $y - $height / 2;
$this->_maxY = $y + $height / 2;
}
public function pan($offset) {
$this->_minX = $this->_minX + $offset;
$this->_minY = $this->_minY + $offset;
$this->_maxX = $this->_maxX + $offset;
$this->_maxY = $this->_maxY + $offset;
}
}
if ('cli' != php_sapi_name()) {
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
ob_implicit_flush(1);
}