-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhypnocube_spaz2.php
More file actions
102 lines (67 loc) · 2.03 KB
/
Copy pathhypnocube_spaz2.php
File metadata and controls
102 lines (67 loc) · 2.03 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
<?PHP
//define('DEBUG_ON', TRUE);
require_once("hypnocube.class.php");
echo "program starting...\n";
$hypnocube = new HypnoCube();
$hypnocube->setFPS(60);
$hypnocube->login();
$a = 0.00;
$frame = 0;
// set initial values
$rotate_speed['x'] = 0.10;//0.3;//
$rotate_speed['y'] = 0.01;//0.021111;//0.05;
$rotate_speed['z'] = 0.00;//0.01;//0.02;
$rot['x'] = 0.0;
$rot['y'] = 0.0;
$rot['z'] = 0.0;
// make bubbles
$bubbles = array();
$bubbles_count = 5;
for ($i= 0; $i < $bubbles_count; $i++){
$bubble = array ('x' => (float) mt_rand(0,2500), 'y' => (float) mt_rand(0,2500), 'z' => (float) mt_rand(-2500,2500), 'c' => mt_rand(1,3));
//+ 1500
// super rare white
if (mt_rand (1,50) == 1) $bubble['c'] = 4;
$bubbles[] = $bubble;
}
for (;;){
$frame ++;
$a += 0.05;
$color = array (mt_rand(0,15), mt_rand(0,15),mt_rand(0,15));
for ($xled = 0; $xled < 4; $xled++){
for ($yled = 0; $yled < 4; $yled++){
for ($zled = 0; $zled < 4; $zled++){
if ($frame == 1){
$matrix[$xled][$yled][$zled] = array (0,0,0);
}
$pixel = $color;
$matrix[$xled][$yled][$zled] = array ((int) $pixel[0], (int) $pixel[1], (int) $pixel[2]);
}
}
}
$hypnocube->setMatrix($matrix);
$hypnocube->sendFrame();
$hypnocube->flipFrame();
}
function rotate($P0, $rot){
$xcos = cos($rot['x']);
$xsin = sin($rot['x']);
$ycos = cos($rot['y']);
$ysin = sin($rot['y']);
$zcos = cos($rot['z']);
$zsin = sin($rot['z']);
$P['x'] = $P0['x'] * $zcos - $P0['y'] * $zsin;
$P['y'] = $P0['x'] * $zsin + $P0['y'] * $zcos;
$new_y = $P['y'];
$P['y'] = $new_y * $xcos - $P0['z'] * $xsin;
$P['z'] = $new_y * $xsin + $P0['z'] * $xcos;
$new_x = $P['x'];
$new_z = $P['z'];
$P['z'] = $new_z * $ycos - $new_x * $ysin;
$P['x'] = $new_z * $ysin + $new_x * $ycos;
return $P;
}
// triangle wave
/*$rf = abs(($a % 60) - 30) - 15;
$bf = abs(( ($a + 7) % 60) - 30) - 15;
$gf = abs(( ($a + 28) % 60) - 30) - 15;