909 {
910 PixelT* pixels =
canvas.pixels;
913
914
919
923
924 fl::i32 dx8 = fx1 - fx0;
925 fl::i32 dy8 = fy1 - fy0;
926
927
928 fl::i32 gradient = (dx8 == 0) ? 0 : ((dy8 << 8) / dx8);
929
930
931 fl::i32 xend = (fx0 + 128) & ~0xFF;
932 fl::i32 yend = fy0 + ((gradient * (xend - fx0)) >> 8);
933 fl::i32 xgap = 256 - ((fx0 + 128) & 0xFF);
934 int xpxl1 = xend >> 8;
935 int ypxl1 = yend >> 8;
937
938
939 fl::i32 xend2 = (fx1 + 128) & ~0xFF;
940 fl::i32 yend2 = fy1 + ((gradient * (xend2 - fx1)) >> 8);
941 fl::i32 xgap2 = (fx1 + 128) & 0xFF;
942 int xpxl2 = xend2 >> 8;
943 int ypxl2 = yend2 >> 8;
945
946
947 {
948 fl::u8 b1 =
static_cast<fl::u8>(((255 - yfrac1) * xgap) >> 8);
950 if (steep) {
951 PixelT c =
color; c.nscale8(b1);
953 c =
color; c.nscale8(b2);
955 } else {
956 PixelT c = color; c.nscale8(b1);
958 c = color; c.nscale8(b2);
960 }
961 }
962
963
964 {
965 fl::u8 b1 =
static_cast<fl::u8>(((255 - yfrac2) * xgap2) >> 8);
967 if (steep) {
968 PixelT c = color; c.nscale8(b1);
970 c = color; c.nscale8(b2);
972 } else {
973 PixelT c = color; c.nscale8(b1);
975 c = color; c.nscale8(b2);
977 }
978 }
979
980
981 fl::i32 intery = yend + gradient;
982 if (steep) {
983 for (
int x = xpxl1 + 1;
x < xpxl2; ++
x) {
986 PixelT c = color; c.nscale8(255 - frac);
988 c = color; c.nscale8(frac);
990 intery += gradient;
991 }
992 } else {
993 for (
int x = xpxl1 + 1;
x < xpxl2; ++
x) {
996 PixelT c = color; c.nscale8(255 - frac);
998 c = color; c.nscale8(frac);
1000 intery += gradient;
1001 }
1002 }
1003}
fl::CanvasRGB canvas(fl::span< CRGB >(leds, NUM_LEDS), WIDTH, HEIGHT)
enable_if_t< is_same< T, U >::value > swap(T &a, U &b) FL_NO_EXCEPT
fl::i32 toFixed8(Coord val) FL_NO_EXCEPT
Convert any Coord type to 8.8 fixed-point (fl::i32).
void addPixelToBuffer(PixelT *pixels, int width, int height, int x, int y, const PixelT &color) FL_NO_EXCEPT
Internal helper: add or set pixel to rectangular buffer with bounds checking Direct row-major indexin...
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NO_EXCEPT