draw a small disk ~ strokeWeight; 1..3 pixels radius
| 83 | |
| 84 | // draw a small disk ~ strokeWeight; 1..3 pixels radius |
| 85 | void 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 | |
| 105 | void setup() { |
| 106 | CLEDController *controller = |