MCPcopy Create free account
hub / github.com/FastLED/FastLED / plotSoftDot

Function plotSoftDot

examples/Luminova/Luminova.h:85–103  ·  view source on GitHub ↗

draw a small disk ~ strokeWeight; 1..3 pixels radius

Source from the content-addressed store, hash-verified

83
84// draw a small disk ~ strokeWeight; 1..3 pixels radius
85void plotSoftDot(float fx, float fy, float s) {
86 // map s (decays from 5) to a pixel radius 1..3
87 float r = constrain(s * 0.5f, 1.0f, 3.0f);
88 int R = (int)fl::ceilf(r);
89 int cx = (int)fl::roundf(fx);
90 int cy = (int)fl::roundf(fy);
91 float r2 = r * r;
92 for (int dy = -R; dy <= R; ++dy) {
93 for (int dx = -R; dx <= R; ++dx) {
94 float d2 = dx * dx + dy * dy;
95 if (d2 <= r2) {
96 // falloff toward edge
97 float fall = 1.0f - (d2 / (r2 + 0.0001f));
98 uint8_t v = (uint8_t)constrain(255.0f * fall, 0.0f, 255.0f);
99 plotDot(cx + dx, cy + dy, v);
100 }
101 }
102 }
103}
104
105void setup() {
106 CLEDController *controller =

Callers 2

drawMethod · 0.85
loopFunction · 0.85

Calls 3

ceilfFunction · 0.85
roundfFunction · 0.85
plotDotFunction · 0.85

Tested by

no test coverage detected