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

Method drawDot

src/fl/fx/2d/flowfield.cpp.hpp:163–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void FlowFieldFloat::drawDot(float cx, float cy, float diam,
164 u8 cr, u8 cg, u8 cb) {
165 int w = (int)getWidth();
166 int h = (int)getHeight();
167 float rad = diam * 0.5f;
168 int x0 = fl::max(0, (int)floorf(cx - rad - 1.0f));
169 int x1 = fl::min(w - 1, (int)ceilf(cx + rad + 1.0f));
170 int y0 = fl::max(0, (int)floorf(cy - rad - 1.0f));
171 int y1 = fl::min(h - 1, (int)ceilf(cy + rad + 1.0f));
172 for (int y = y0; y <= y1; y++) {
173 for (int x = x0; x <= x1; x++) {
174 float dx = (x + 0.5f) - cx;
175 float dy = (y + 0.5f) - cy;
176 float dist = sqrtf(dx * dx + dy * dy);
177 float cov = clampf(rad + 0.5f - dist, 0.0f, 1.0f);
178 if (cov <= 0.0f)
179 continue;
180 float inv = 1.0f - cov;
181 int i = idx(y, x);
182 mR[i] = mR[i] * inv + cr * cov;
183 mG[i] = mG[i] * inv + cg * cov;
184 mB[i] = mB[i] * inv + cb * cov;
185 }
186 }
187}
188
189void FlowFieldFloat::drawAALine(float x0, float y0, float x1, float y1,
190 float t, float colorShift) {

Callers

nothing calls this directly

Calls 12

maxFunction · 0.85
floorfFunction · 0.85
ceilfFunction · 0.85
sqrtfFunction · 0.85
floorFunction · 0.85
ceilFunction · 0.85
sqrtFunction · 0.85
clampFunction · 0.85
s16x16Class · 0.50
to_intMethod · 0.45
rawMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected