-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyse.php
More file actions
161 lines (116 loc) · 4.58 KB
/
analyse.php
File metadata and controls
161 lines (116 loc) · 4.58 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
namespace Spectroscope;
// register to file the timestamp for this operation
include("register_operation.php");
// Turn off output buffering
ini_set('output_buffering', 'off');
// Turn off PHP output compression
ini_set('zlib.output_compression', false);
//Flush (send) the output buffer and turn off output buffering
//ob_end_flush();
while (@ob_end_flush());
// Implicitly flush the buffer(s)
ini_set('implicit_flush', true);
ob_implicit_flush(true);
//prevent apache from buffering it for deflate/gzip
//header("Content-type: text/plain");
header('Cache-Control: no-cache'); // recommended to prevent caching of event data.
require_once"vendor/autoload.php";
// require_once"css_color_parser.php";
// require_once"css_color_object.php";
use Danmichaelo\Coma\ColorDistance,
Danmichaelo\Coma\sRGB;
$color1 = new sRGB(255, 255, 255);
$color2 = new sRGB(73, 187, 187);
$color3 = new sRGB(1, 255, 255);
$color4 = new sRGB(255, 0, 255);
?>
<div style="display:block;width: 10px;height: 10px;background-color: rgb(255,255,255);"></div>
<div style="display:block;width: 10px;height: 10px;background-color: rgb(73, 187, 187);"></div>
<div style="display:block;width: 10px;height: 10px;background-color: rgb(1, 255, 255);"></div>
<div style="display:block;width: 10px;height: 10px;background-color: rgb(255, 0, 255);"></div>
<?php
$cd = new ColorDistance;
$cie94 = $cd->cie94($color1, $color2);
echo 'The CIE94 ∆E is ' . $cie94 . ' between ' . $color1->toHex() . ' and ' . $color2->toHex() . '.<br><br>';
$cd = new ColorDistance;
$cie94 = $cd->cie94($color1, $color3);
echo 'The CIE94 ∆E is ' . $cie94 . ' between ' . $color1->toHex() . ' and ' . $color3->toHex() . '.<br><br>';
$cd = new ColorDistance;
$cie94 = $cd->cie94($color1, $color4);
echo 'The CIE94 ∆E is ' . $cie94 . ' between ' . $color1->toHex() . ' and ' . $color4->toHex() . '.<br><br>';
$cd = new ColorDistance;
$cie76 = $cd->cie76($color1, $color2);
echo 'The CIE76 ∆E is ' . $cie76 . ' between ' . $color1->toHex() . ' and ' . $color2->toHex() . '.<br><br>';
$colors = [
new sRGB(102, 102, 102),
new sRGB(73, 187, 187),
new sRGB(14, 233, 1),
new sRGB(217, 89, 142),
new sRGB(2, 5, 19),
new sRGB(88, 130, 29),
new sRGB(156, 0, 210),
new sRGB(45, 10, 210),
new sRGB(24, 10, 110),
new sRGB(46, 10, 190),
new sRGB(7, 10, 170),
new sRGB(156, 40, 100),
];
$results = array();
$cd = new ColorDistance;
$white = new sRGB(255,0,255);
foreach ($colors as $color) {
//$color = new sRGB($color);
$diff = $cd->cie76($white,$color);
$results[] = [
"difference" => $diff,
"color" => $color->toHex(),
"light-diff" => $cd->cie76(new sRGB(255,255,255),$color),
"dark-diff" => $cd->cie76(new sRGB(0,0,0),$color),
"red-diff" => $cd->cie76(new sRGB(255,0,0),$color),
"green-diff" => $cd->cie76(new sRGB(0,255,0),$color),
"blue-diff" => $cd->cie76(new sRGB(0,0,255),$color),
];
?><br><div style="display:block;width: 30px;height: 30px;background-color: <?php echo $color->toHex();?>;"></div><?php
echo "The color ".$color->toHex()."is ".round(($color->r/255)*100,2)."% red<br><br>";
# code...
//var_dump($color->r);
}
//asort($results);
var_dump($results);
foreach ($results as $result) {
?><div style="display:block;width: 30px;height: 30px;background-color: <?php echo $result["color"];?>;"></div><?php
}
?>
<!DOCTYPE html>
<html>
<head>
<title>CSS Parser</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<img id="logo" src="newer-logo.png">
</header><pre>
<?php
$url = "testserver.dev";
//$url = "dr.dk";
//$url = "https://abetterhealthcareplan.com/";
$parser = new CssParser();
$result = $parser->analyse($url);
var_dump($result);die();
echo "Files: ".count($result["files"]) ."<br>";
// var_dump($result);die();
// var_dump(count($result["files"]));
foreach ($result["files"] as $name => $file) {
//var_dump($file["selectors"]);
echo "<br>File name: ". $name . "<br>";
echo "Selectors: ". count($file["selectors"]) ."<br>";
echo "Declarations: ". count($file["declarations"]) ."<br>";
# code...
}
?>
</pre>
</body>
</html>