357 {
360
361
362 auto plotTile = [&](
const CRGB &color,
float px,
float py,
363 bool horiz) {
366 float fx = px - (float)ix;
367 float fy = py - (float)iy;
368 Tile2x2_u8 tile;
369 tile.setOrigin((u16)ix, (u16)iy);
370 if (horiz) {
371
372 tile.at(0, 0) = (
u8)((1.0f - fy) * 255.0f);
373 tile.at(1, 0) = 0;
374 tile.at(0, 1) = (
u8)(fy * 255.0f);
375 tile.at(1, 1) = 0;
376 } else {
377
378 tile.at(0, 0) = (
u8)((1.0f - fx) * 255.0f);
379 tile.at(1, 0) = (
u8)(fx * 255.0f);
380 tile.at(0, 1) = 0;
381 tile.at(1, 1) = 0;
382 }
384 };
385
386
387 constexpr float amp = 0.3f;
388
389
390
391 CRGB xColor(0, 255, 255);
392 float centerY = (float)(h - 1) * 0.5f;
393 float prevPy = 0.0f;
394 for (
int x = 0;
x < w;
x++) {
396 float py = centerY - val * amp * centerY;
397 plotTile(xColor, (
float)
x, py,
true);
399 float dy = py - prevPy;
400 int gap = (int)
fabsf(dy);
401 for (int s = 1; s < gap; s++) {
402 float t = (float)s / (
float)gap;
403 float midY = prevPy + dy *
t;
404 float midX = (float)(
x - 1) +
t;
405 plotTile(xColor, midX, midY, true);
406 }
407 }
408 prevPy = py;
409 }
410
411
412
413 CRGB yColor(255, 255, 0);
414 float centerX = (float)(w - 1) * 0.5f;
415 float prevPx = 0.0f;
416 for (
int y = 0;
y < h;
y++) {
418 float px = centerX + val * amp * centerX;
419 plotTile(yColor, px, (
float)
y,
false);
421 float dx = px - prevPx;
422 int gap = (int)
fabsf(dx);
423 for (int s = 1; s < gap; s++) {
424 float t = (float)s / (
float)gap;
425 float midX = prevPx + dx *
t;
426 float midY = (float)(
y - 1) +
t;
427 plotTile(yColor, midX, midY, false);
428 }
429 }
430 prevPx = px;
431 }
432}
fl::vector< float > mYProf
Per-row values; drives horizontal shift.
fl::vector< float > mXProf
Per-column values; drives vertical shift.
float floorf(float value) FL_NOEXCEPT
float fabsf(float value) FL_NOEXCEPT