If the code hasn't been touched in this long, its probably release-worthy.
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Figments.h>
|
||||
#include <ArduinoLog.h>
|
||||
#include <Perfcounter.h>
|
||||
|
||||
class Blob {
|
||||
uint16_t m_pos;
|
||||
uint8_t m_pos;
|
||||
int8_t m_velocity;
|
||||
uint8_t m_hue;
|
||||
int16_t m_brightness;
|
||||
@ -49,13 +51,26 @@ public:
|
||||
}
|
||||
|
||||
void render(Display* display) const {
|
||||
PerfCounter _("blobRender");
|
||||
const uint8_t width = 25;
|
||||
//Log.notice("get coords");
|
||||
auto map = display->coordinateMapping();
|
||||
// Grab the physical pixel we'll start with
|
||||
PhysicalCoordinates startPos = map->virtualToPhysicalCoords({m_pos, 0});
|
||||
PhysicalCoordinates endPos = map->virtualToPhysicalCoords({m_pos + width, 0});
|
||||
uint8_t scaledWidth = std::abs(endPos.x - startPos.x);
|
||||
//PhysicalCoordinates startPos = map->virtualToPhysicalCoords({m_pos, m_pos});
|
||||
//PhysicalCoordinates endPos = map->virtualToPhysicalCoords({m_pos + width, m_pos});
|
||||
Surface sfc{display, {m_pos, m_pos}, {qadd8(m_pos, width), qadd8(m_pos, width)}};
|
||||
sfc.paintShader([=](CRGB& pixel, const VirtualCoordinates& coords, const PhysicalCoordinates, const VirtualCoordinates& surfaceCoords) {
|
||||
uint8_t pixelMod = std::min(surfaceCoords.y, surfaceCoords.x);
|
||||
pixelMod = surfaceCoords.x;
|
||||
// Blobs desaturate and dim towards their edges
|
||||
uint8_t saturation = lerp8by8(0, m_brightness, pixelMod);
|
||||
uint8_t val = lerp8by8(0, m_brightness, pixelMod);
|
||||
CHSV blobColor(m_hue, m_saturation, val);
|
||||
|
||||
//PhysicalCoordinates pos{startPos.x + (i*m_fadeDir), startPos.y};
|
||||
|
||||
pixel += blend(CRGB(blobColor), pixel, 80);
|
||||
});
|
||||
/*uint8_t scaledWidth = std::abs(endPos.x - startPos.x);
|
||||
|
||||
//Log.notice("blob w=%d x=%d", scaledWidth, startPos.x);
|
||||
for(uint8_t i = 0;i < scaledWidth; i++) {
|
||||
@ -66,10 +81,10 @@ public:
|
||||
//CHSV blobColor(m_hue, m_saturation, quadwave8((i / (double)scaledWidth) * m_brightness));
|
||||
CHSV blobColor(m_hue, m_saturation, quadwave8(val));
|
||||
|
||||
PhysicalCoordinates pos{startPos.x + (i*m_fadeDir), 0};
|
||||
PhysicalCoordinates pos{startPos.x + (i*m_fadeDir), startPos.y};
|
||||
|
||||
CRGB src(display->pixelAt(pos));
|
||||
display->pixelAt(pos) = blend(CRGB(blobColor), src, 200);
|
||||
}
|
||||
display->pixelAt(pos) = blend(CRGB(blobColor), src, 140);
|
||||
}*/
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user