533 {
534 PixelT* pixels = canvas.
pixels;
537
538
543
547
548 fl::i32 dx8 = fx1 - fx0;
549 fl::i32 dy8 = fy1 - fy0;
550
551
552 fl::i32 gradient = (dx8 == 0) ? 0 : ((dy8 << 8) / dx8);
553
554
555 fl::i32 xend = (fx0 + 128) & ~0xFF;
556 fl::i32 yend = fy0 + ((gradient * (xend - fx0)) >> 8);
557 fl::i32 xgap = 256 - ((fx0 + 128) & 0xFF);
558 int xpxl1 = xend >> 8;
559 int ypxl1 = yend >> 8;
561
562
563 fl::i32 xend2 = (fx1 + 128) & ~0xFF;
564 fl::i32 yend2 = fy1 + ((gradient * (xend2 - fx1)) >> 8);
565 fl::i32 xgap2 = (fx1 + 128) & 0xFF;
566 int xpxl2 = xend2 >> 8;
567 int ypxl2 = yend2 >> 8;
569
570
571 {
572 fl::u8 b1 =
static_cast<fl::u8>(((255 - yfrac1) * xgap) >> 8);
574 if (steep) {
575 PixelT c =
color; c.nscale8(b1);
577 c =
color; c.nscale8(b2);
579 } else {
580 PixelT c = color; c.nscale8(b1);
582 c = color; c.nscale8(b2);
584 }
585 }
586
587
588 {
589 fl::u8 b1 =
static_cast<fl::u8>(((255 - yfrac2) * xgap2) >> 8);
591 if (steep) {
592 PixelT c = color; c.nscale8(b1);
594 c = color; c.nscale8(b2);
596 } else {
597 PixelT c = color; c.nscale8(b1);
599 c = color; c.nscale8(b2);
601 }
602 }
603
604
605 fl::i32 intery = yend + gradient;
606 if (steep) {
607 for (
int x = xpxl1 + 1;
x < xpxl2; ++
x) {
610 PixelT c = color; c.nscale8(255 - frac);
612 c = color; c.nscale8(frac);
614 intery += gradient;
615 }
616 } else {
617 for (
int x = xpxl1 + 1;
x < xpxl2; ++
x) {
620 PixelT c = color; c.nscale8(255 - frac);
622 c = color; c.nscale8(frac);
624 intery += gradient;
625 }
626 }
627}
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...
void swap(array< T, N > &lhs, array< T, N > &rhs) FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NO_EXCEPT