This repository has been archived by the owner on Jun 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·128 lines (86 loc) · 2.72 KB
/
app.js
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
var args = require('minimist')(process.argv.slice(2));
var extend = require('yow').extend;
var sprintf = require('yow').sprintf;
var fs = require('fs');
var Matrix = require('pixel-matrix');
var App = function() {
var width = 32;
var height = 32;
if (args.size != undefined) {
var sizes = args.size.split('x');
if (sizes.length == 2) {
args.width = sizes[0];
args.height = sizes[1];
}
}
if (args.width != undefined)
width = parseInt(args.width);
if (args.height != undefined)
height = parseInt(args.height);
var matrix = new Matrix({width:width, height:height});
this.run = function() {
function callback() {
console.log('Done.');
}
if (args.fill) {
var display = matrix.display;
for (var x = 0; x < matrix.width; x++)
for (var y = 0; y < matrix.height; y++)
matrix.display.drawPixel(x, y, 0, 0, 255);
matrix.display.update();
setTimeout(function(){}, 2000);
}
else if (args.rain) {
var options = {};
extend(options, {duration : args.duration});
extend(options, {delay : args.delay});
extend(options, {speed : args.speed});
if (args.hue) {
extend(options, {hue : parseInt(args.hue)});
}
matrix.runRain(options, callback);
}
else if (args.perlin) {
var options = {};
extend(options, {duration : args.duration});
extend(options, {delay : args.delay});
extend(options, {speed : args.speed});
extend(options, {mode : args.mode});
matrix.runPerlin(options, callback);
}
else if (args.image) {
var options = {};
extend(options, {duration : args.duration});
extend(options, {delay : args.delay});
extend(options, {speed : args.speed});
extend(options, {scroll : args.scroll});
extend(options, {pause : args.pause});
extend(options, {iterations : args.iterations});
matrix.runImage(args.image, options, callback);
}
else if (args.animation) {
var options = {};
extend(options, {duration : args.duration});
extend(options, {delay : args.delay});
extend(options, {speed : args.speed});
extend(options, {iterations : args.iterations});
matrix.runAnimation(args.animation, options, callback);
}
else if (args.text) {
var options = {};
extend(options, {duration : args.duration});
extend(options, {delay : args.delay});
extend(options, {speed : args.speed});
extend(options, {textColor : args.textColor});
extend(options, {fontName : args.fontName});
extend(options, {fontSize : args.fontSize});
extend(options, {iterations : args.iterations});
matrix.runText(args.text, options, callback);
}
else {
matrix.runText('Hello World!');
}
};
};
var app = new App();
app.run();