531 {
532 PixelT* pixels = canvas.
pixels;
535
536
541
545
546 fl::i32 dx8 = fx1 - fx0;
547 fl::i32 dy8 = fy1 - fy0;
548
549
550 fl::i32 gradient = (dx8 == 0) ? 0 : ((dy8 << 8) / dx8);
551
552
553 fl::i32 xend = (fx0 + 128) & ~0xFF;
554 fl::i32 yend = fy0 + ((gradient * (xend - fx0)) >> 8);
555 fl::i32 xgap = 256 - ((fx0 + 128) & 0xFF);
556 int xpxl1 = xend >> 8;
557 int ypxl1 = yend >> 8;
559
560
561 fl::i32 xend2 = (fx1 + 128) & ~0xFF;
562 fl::i32 yend2 = fy1 + ((gradient * (xend2 - fx1)) >> 8);
563 fl::i32 xgap2 = (fx1 + 128) & 0xFF;
564 int xpxl2 = xend2 >> 8;
565 int ypxl2 = yend2 >> 8;
567
568
569 {
570 fl::u8 b1 =
static_cast<fl::u8>(((255 - yfrac1) * xgap) >> 8);
572 if (steep) {
573 PixelT c = color; c.nscale8(b1);
575 c = color; c.nscale8(b2);
577 } else {
578 PixelT c = color; c.nscale8(b1);
580 c = color; c.nscale8(b2);
582 }
583 }
584
585
586 {
587 fl::u8 b1 =
static_cast<fl::u8>(((255 - yfrac2) * xgap2) >> 8);
589 if (steep) {
590 PixelT c = color; c.nscale8(b1);
592 c = color; c.nscale8(b2);
594 } else {
595 PixelT c = color; c.nscale8(b1);
597 c = color; c.nscale8(b2);
599 }
600 }
601
602
603 fl::i32 intery = yend + gradient;
604 if (steep) {
605 for (
int x = xpxl1 + 1;
x < xpxl2; ++
x) {
608 PixelT c = color; c.nscale8(255 - frac);
610 c = color; c.nscale8(frac);
612 intery += gradient;
613 }
614 } else {
615 for (
int x = xpxl1 + 1;
x < xpxl2; ++
x) {
618 PixelT c = color; c.nscale8(255 - frac);
620 c = color; c.nscale8(frac);
622 intery += gradient;
623 }
624 }
625}
void swap(T &a, T &b) FL_NOEXCEPT
fl::i32 toFixed8(Coord val)
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)
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_NOEXCEPT