Weihnachtsbaum: nur grüner Kegel mit roten Kugeln, Grün heller
Kein Stern, kein Schnee, keine bunten Kugeln mehr; der Kegel geht über alle fünf Etagen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
92d507fb0d
commit
e2fc97fc68
2 files changed
+9
-63
No files matched your search
+8
-62
@@ -3,74 +3,20 @@
|
||||
|
||||
#include "fx.h"
|
||||
|
||||
// --- Weihnachtsbaum: grüner Kegel mit Kugeln, Stern an der Spitze, leiser Schnee --
|
||||
// --- Weihnachtsbaum: grüner Kegel über alle Etagen mit ein paar roten Kugeln -----
|
||||
|
||||
static bool isTree(int x, int y, int z) {
|
||||
float d = distAxis(x, y);
|
||||
switch (z) {
|
||||
case 1: return d <= 2.3f; // 21 LEDs
|
||||
case 2: return d <= 2.0f; // 13 LEDs
|
||||
case 3: return d <= 1.0f; // 5 LEDs
|
||||
default: return false; // unten Stamm, oben Stern
|
||||
}
|
||||
}
|
||||
|
||||
struct Bauble {
|
||||
uint8_t x, y, z, phase;
|
||||
CRGB color;
|
||||
};
|
||||
static Bauble baubles[10];
|
||||
|
||||
static void placeBauble(Bauble &b) {
|
||||
static const CRGB COLORS[] = {CRGB(255, 0, 0), CRGB(255, 170, 0), CRGB(0, 60, 255), CRGB(200, 0, 160), CRGB(255, 255, 255)};
|
||||
do {
|
||||
b.x = random8(CUBE_SIZE);
|
||||
b.y = random8(CUBE_SIZE);
|
||||
b.z = random8(1, 4);
|
||||
} while (!isTree(b.x, b.y, b.z) || (b.x == 2 && b.y == 2 && b.z < 3)); // nicht im Stamm-Inneren
|
||||
b.color = COLORS[random8(5)];
|
||||
b.phase = random8();
|
||||
static const float RADIUS[] = {2.3f, 2.0f, 1.5f, 1.0f, 0.0f}; // 21, 13, 9, 5, 1 LEDs
|
||||
return distAxis(x, y) <= RADIUS[z];
|
||||
}
|
||||
|
||||
void renderTree(uint32_t now) {
|
||||
static uint32_t lastMove = 0;
|
||||
if (fresh) {
|
||||
fresh = false;
|
||||
for (Bauble &b : baubles) placeBauble(b);
|
||||
lastMove = now;
|
||||
}
|
||||
if (now - lastMove > 1500) { // ab und zu wandert ein Licht
|
||||
lastMove = now;
|
||||
placeBauble(baubles[random8(10)]);
|
||||
}
|
||||
|
||||
static const uint8_t BAUBLES[][3] = {{4, 1, 0}, {1, 4, 0}, {0, 1, 0}, {3, 3, 1}, {2, 0, 1}, {1, 3, 2}, {3, 2, 3}};
|
||||
FastLED.clear();
|
||||
at(2, 2, 0) = CRGB(brightness / 2, brightness / 5, 0); // Stamm
|
||||
FOR_XYZ {
|
||||
if (!isTree(x, y, z)) continue;
|
||||
uint8_t n = inoise8(x * 60, y * 60, z * 60 + now / 12);
|
||||
at(x, y, z) = CHSV(96, 255, scale8(brightness, 140 + n / 3));
|
||||
}
|
||||
for (Bauble &b : baubles) {
|
||||
uint8_t v = 110 + scale8(sin8(now / 6 + b.phase), 145);
|
||||
at(b.x, b.y, b.z) = CRGB(b.color).nscale8(scale8(highlight, v));
|
||||
}
|
||||
// Stern: Mitte hell und funkelnd, die Zacken abwechselnd
|
||||
uint8_t tw = sin8(now / 3);
|
||||
at(2, 2, TOP) = CRGB(highlight, scale8(highlight, 200), scale8(highlight, tw / 3));
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
static const int8_t DX[] = {1, -1, 0, 0}, DY[] = {0, 0, 1, -1};
|
||||
uint8_t v = scale8(highlight, 80 + scale8(sin8(now / 4 + i * 64), 120));
|
||||
at(2 + DX[i], 2 + DY[i], TOP) = CRGB(v, scale8(v, 170), 0);
|
||||
}
|
||||
if (random8() < 4) at(2, 2, TOP) = CRGB::White;
|
||||
|
||||
// leiser Schnee rundherum
|
||||
if (random8() < 6) spawnParticle(rnd(0, TOP), rnd(0, TOP), TOP + 0.4f, 0, 0, -rnd(0.015f, 0.025f), CRGB(brightness, brightness, brightness));
|
||||
moveParticles(0, 1, 0);
|
||||
for (const Particle &p : particles) {
|
||||
int x = lroundf(p.x), y = lroundf(p.y), z = lroundf(p.z);
|
||||
if (p.life && !isTree(x, y, z) && !(x == 2 && y == 2)) plot(p.x, p.y, p.z, p.color);
|
||||
FOR_XYZ if (isTree(x, y, z)) at(x, y, z) = CRGB(0, highlight, 0);
|
||||
for (uint8_t i = 0; i < 7; i++) {
|
||||
uint8_t glow = 180 + scale8(sin8(now / 20 + i * 37), 75); // langsames Glimmen
|
||||
at(BAUBLES[i][0], BAUBLES[i][1], BAUBLES[i][2]) = CRGB(scale8(highlight, glow), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user