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