forked from vesteraas/node-pitft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircles.js
42 lines (30 loc) · 1.02 KB
/
circles.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
var pitft = require("../pitft");
var fb = pitft("/dev/fb1"); // Returns a framebuffer in direct mode. See the clock.js example for double buffering mode
// Clear the screen buffer
fb.clear();
var xMax = fb.size().width;
var yMax = fb.size().height;
for (var n=0; n<250; n++) {
var x, y, radius, r, g, b;
x = parseInt(Math.random() * xMax, 10);
y = parseInt(Math.random() * yMax, 10);
radius = parseInt(Math.random() * yMax / 2, 10);
// Create a random color
r = Math.random();
g = Math.random();
b = Math.random();
fb.color(r, g, b);
fb.circle(x, y, radius, false, 1); // Draw an outlined circle with a 1 pixel wide border
}
fb.clear();
for (var n=0; n<250; n++) {
var x, y, radius, r, g, b;
x = parseInt(Math.random() * xMax, 10);
y = parseInt(Math.random() * yMax, 10);
radius = parseInt(Math.random() * yMax / 2, 10);
r = Math.random();
g = Math.random();
b = Math.random();
fb.color(r, g, b);
fb.circle(x, y, radius, true); // Draw a filled circle
}