-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
test-duplicate.php
95 lines (65 loc) · 2.68 KB
/
test-duplicate.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
require_once 'lib/all.php';
$iconFileName = "test-suite/data/grey-ball-64.png";
$loader = new WMImageLoader();
$loader->cacheEnabled = true;
$im = imagecreatetruecolor(400, 400);
imagealphablending($im, true);
$bg = imagecolorallocatealpha($im, 128, 128, 0, 0);
imagefill($im, 0, 0, $bg);
function draw_icon($destination, $source, $x, $y)
{
print "$source at $x,$y\n";
imagecopy($destination, $source, $x, $y, 0, 0, imagesx($source), imagesy($source));
print "\n\n\n";
}
/**
* @param $originalIcon
* @return resource
*/
function create_intermediate($originalIcon)
{
$intermediate = imagecreatetruecolor(imagesx($originalIcon) + 10, imagesy($originalIcon) + 10);
imagesavealpha($intermediate, true);
imagealphablending($intermediate, false);
$nothing = imagecolorallocatealpha($intermediate, 128, 0, 0, 127);
imagefill($intermediate, 0, 0, $nothing);
imagecopy($intermediate, $originalIcon, 5, 5, 0, 0, imagesx($originalIcon), imagesy($originalIcon));
return $intermediate;
}
$weathermap_debugging = true;
if (1 == 1) {
$icon = $loader->imagecreatefromfile($iconFileName);
print $icon;
draw_icon($im, $icon, 10, 10);
// should be a cache hit
$icon2 = $loader->imagecreatefromfile($iconFileName);
draw_icon($im, $icon2, 100, 10);
$icon3 = $loader->imagecreatescaledfromfile($iconFileName, 32, 32);
draw_icon($im, $icon3, 200, 10);
// should be a cache hit
$icon4 = $loader->imagecreatescaledfromfile($iconFileName, 32, 32);
draw_icon($im, $icon4, 250, 10);
}
$colour = new WMColour(128, 255, 192);
$colour = new WMColour(64, 128, 96);
$icon5 = $loader->imagecreatescaledcolourizedfromfile($iconFileName, 0, 0, $colour, 'imagecolorize');
draw_icon($im, $icon5, 50, 100);
$icon6 = $loader->imagecreatescaledcolourizedfromfile($iconFileName, 32, 32, $colour, 'imagecolorize');
draw_icon($im, $icon6, 120, 100);
$icon6a = $loader->imagecreatescaledcolourizedfromfile($iconFileName, 32, 32, $colour, 'imagecolorize');
draw_icon($im, $icon6a, 170, 100);
$intermediate = create_intermediate($icon6a);
draw_icon($im, $intermediate, 240, 95);
$weathermap_debugging = false;
if (1 == 1) {
$icon7 = $loader->imagecreatescaledcolourizedfromfile($iconFileName, 0, 0, $colour, 'imagefilter');
draw_icon($im, $icon7, 50, 200);
$icon8 = $loader->imagecreatescaledcolourizedfromfile($iconFileName, 32, 32, $colour, 'imagefilter');
draw_icon($im, $icon8, 120, 200);
$icon8a = $loader->imagecreatescaledcolourizedfromfile($iconFileName, 32, 32, $colour, 'imagefilter');
draw_icon($im, $icon8a, 170, 200);
$intermediate2 = create_intermediate($icon8a);
draw_icon($im, $intermediate2, 240, 195);
}
imagepng($im, "test.png");