feat: hypno-rings
parent
fcaf5cf510
commit
3bfbe37a15
12
apps.json
12
apps.json
|
|
@ -350,6 +350,18 @@
|
||||||
{"name":"*pparrot","url":"party-parrot-icon.js","evaluate":true}
|
{"name":"*pparrot","url":"party-parrot-icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{ "id": "rings",
|
||||||
|
"name": "Hypno Rings",
|
||||||
|
"icon": "rings.png",
|
||||||
|
"description": "Experiment with trippy rings, press buttons for change",
|
||||||
|
"tags": "rings,hypnosis,psychadelic",
|
||||||
|
"type":"app",
|
||||||
|
"storage": [
|
||||||
|
{"name":"+hrings","url":"hypno-rings.json"},
|
||||||
|
{"name":"-hrings","url":"hypno-rings.js"},
|
||||||
|
{"name":"*hrings","url":"hypno-rings-icon.js","evaluate":true}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "blescan",
|
"id": "blescan",
|
||||||
"name": "BLE Scanner",
|
"name": "BLE Scanner",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
class Ring {
|
||||||
|
constructor() {
|
||||||
|
this.alive = true;
|
||||||
|
this.radius = 0;
|
||||||
|
this.color = [
|
||||||
|
Math.random() > 0.5 ? 1 : 0, Math.random() > 0.5 ? 1 : 0, Math.random() > 0.5 ? 1 : 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const LIMIT = 10;
|
||||||
|
const RADIUS_LIMIT = 240;
|
||||||
|
const pool = [];
|
||||||
|
let RANDOM = 0;
|
||||||
|
let BUFFER = 0;
|
||||||
|
let BUFFER_SPREAD = 20;
|
||||||
|
|
||||||
|
const animate = () => {
|
||||||
|
if (pool.length < LIMIT && BUFFER === 0) {
|
||||||
|
const available = pool.filter(ring => !ring.alive);
|
||||||
|
const newRing = available.length ? available[0] : new Ring();
|
||||||
|
pool.push(newRing);
|
||||||
|
BUFFER = BUFFER_SPREAD;
|
||||||
|
}
|
||||||
|
g.clear();
|
||||||
|
if (BUFFER > 0) BUFFER--;
|
||||||
|
for (const ring of pool) {
|
||||||
|
if (ring.radius > RADIUS_LIMIT) {
|
||||||
|
ring.radius = 0;
|
||||||
|
ring.alive = false;
|
||||||
|
} else {
|
||||||
|
if (RANDOM) g.setColor(ring.color[0], ring.color[1], ring.color[2]);
|
||||||
|
else g.setColor(1, 1, 1);
|
||||||
|
g.drawCircle(120, 120, ring.radius++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setTimeout(animate, 1000/60);
|
||||||
|
};
|
||||||
|
|
||||||
|
setWatch(() => (BUFFER_SPREAD += 5), BTN1, {repeat: true});
|
||||||
|
setWatch(() => (RANDOM = !RANDOM), BTN2, {repeat: true});
|
||||||
|
setWatch(() => (BUFFER_SPREAD -= 5), BTN3, {repeat: true});
|
||||||
|
|
||||||
|
animate();
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"name":"Hypno Rings","type":"app",
|
||||||
|
"icon":"*hrings",
|
||||||
|
"src":"-hrings"
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Loading…
Reference in New Issue