forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsoleBanner3.php
More file actions
81 lines (61 loc) · 1.72 KB
/
Copy pathconsoleBanner3.php
File metadata and controls
81 lines (61 loc) · 1.72 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
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<textarea id="output" style="width: 1400px; height: 600px"></textarea>
<br />
<input type="button" id="grab" value="Grab" />
<input type="button" id="refresh" value="Refresh" />
<script type="text/javascript">
var game = new Phaser.Game(50, 31, Phaser.CANVAS, '', { preload: preload, create: create });
function preload() {
game.load.image('piccie', 'assets/bd/burd.png');
}
var logo;
var args;
function create() {
logo = game.add.sprite(0, 0, 'piccie');
document.getElementById('grab').onclick = canvasToConsole;
document.getElementById('refresh').onclick = refreshConsole;
}
function refreshConsole () {
args[0] = document.getElementById('output').value;
console.clear();
console.log.apply(console, args);
console.log(args.toString());
}
function canvasToConsole () {
var txt = "";
var prev;
args = [""];
var lfb = game.renderer.context.getImageData(0, 0, game.width, game.height).data;
for (var i = 0, j = 0; i < 1500; i++, j++)
{
if (!(i % 50)) // if(i && !(i % 50)) if don't like to start with a "\n"
txt += prev = "\n";
var col = "background: rgb(" + [lfb[j++], lfb[j++], lfb[j++]] + ")";
if (col == prev)
{
txt += " ";
}
else
{
txt += "%c ";
args.push(col);
prev = col;
}
}
args[0] = txt;
document.getElementById('output').innerText = args[0];
console.clear();
console.log.apply(console, args);
// console.log(args[0]);
}
</script>
</body>
</html>