#include "corner.h" #include "prototypes.h" #include "tools.h" Corner::Corner(Edge* new_e1, Edge* new_e2): e1(new_e1), e2(new_e2) { } void Corner::draw() { for(uint16_t led: this->_leds) { leds[led] = this->color; } } void Corner::loop() { if (color_blend_state < 255) { this->color = blend(this->source_color, this->target_color, color_blend_state); color_blend_state++; if (color_blend_state == 255) { LOGln("I am %p and have %d long neighbours:", this, _long_neighbours.size()); for(Corner* c1 : _long_neighbours) { c1->blend_to(this->target_color, this->effect_id); } LOGln("long neighbours done."); //LOGln("Address of my short neighbours: %p", &_short_neighbours); //delay(10); LOGln("I am %p and have %d short neighbours:", this, _short_neighbours.size()); for(Corner* c2 : _short_neighbours) { if (c2==nullptr) continue; LOGln("c2: %p", c2); c2->blend_to(this->target_color, this->effect_id); } LOGln("short neighbours done."); } } this->draw(); } void Corner::blend_to(CRGB target, uint16_t eid) { LOGln("blendTo called. Corner: %p, target: %d,%d,%d, eid: %d", this, target.r, target.g, target.b, eid); if (eid==0) { this->effect_id = random16(); LOGln("Set effect_id to %d", this->effect_id); } else { if (this->effect_id == eid) { return; } } this->source_color = this->color; this->target_color = target; this->color_blend_state = 0; } void Corner::add_led(uint16_t led) { _leds.push_back(led); } void Corner::merge_leds(Corner* c) { for(uint16_t led : c->_leds) { _leds.push_back(led); } }