Fix 3 bugs in filled arc drawing...
1. Certain small angles would fill the inverse angle 2. Certain angles would draw a spurios horizontal line 3. Integer rounding improvements (now also improved for arc drawing)spinbox_widget
parent
a5f27d61c6
commit
e3a0cff000
|
@ -1722,11 +1722,11 @@ void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c
|
|||
sedge = NONFIXED(radius * ((sbit & 0x99) ? ffsin(start) : ffcos(start)) + FIXED0_5);
|
||||
eedge = NONFIXED(radius * ((ebit & 0x99) ? ffsin(end) : ffcos(end)) + FIXED0_5);
|
||||
#elif GFX_USE_GMISC && GMISC_NEED_FASTTRIG
|
||||
sedge = round(radius * ((sbit & 0x99) ? fsin(start) : fcos(start)));
|
||||
eedge = round(radius * ((ebit & 0x99) ? fsin(end) : fcos(end)));
|
||||
sedge = floor(radius * ((sbit & 0x99) ? fsin(start) : fcos(start)) + 0.5);
|
||||
eedge = floor(radius * ((ebit & 0x99) ? fsin(end) : fcos(end)) + 0.5);
|
||||
#else
|
||||
sedge = round(radius * ((sbit & 0x99) ? sin(start*GFX_PI/180) : cos(start*GFX_PI/180)));
|
||||
eedge = round(radius * ((ebit & 0x99) ? sin(end*GFX_PI/180) : cos(end*GFX_PI/180)));
|
||||
sedge = floor(radius * ((sbit & 0x99) ? sin(start*GFX_PI/180) : cos(start*GFX_PI/180)) + 0.5);
|
||||
eedge = floor(radius * ((ebit & 0x99) ? sin(end*GFX_PI/180) : cos(end*GFX_PI/180)) + 0.5);
|
||||
#endif
|
||||
if (sbit & 0xB4) sedge = -sedge;
|
||||
if (ebit & 0xB4) eedge = -eedge;
|
||||
|
@ -1843,17 +1843,21 @@ void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c
|
|||
|
||||
MUTEX_ENTER(g);
|
||||
|
||||
// Do the trig to get the formulas for the start and end lines.
|
||||
// We add a half pixel so that we are drawing from the centre of the pixel
|
||||
// instead of the left edge of the pixel. This also fixes the implied floor()
|
||||
// when converting back to a coord_t
|
||||
sxa = exa = FIXED(x) + FIXED0_5;
|
||||
|
||||
// Do the trig to get the formulas for the start and end lines.
|
||||
#if GFX_USE_GMISC && GMISC_NEED_FIXEDTRIG
|
||||
sxb = radius*ffcos(start); sy = -NONFIXED(radius*ffsin(start) + FIXED0_5);
|
||||
exb = radius*ffcos(end); ey = -NONFIXED(radius*ffsin(end) + FIXED0_5);
|
||||
sxb = radius*ffcos(start); sy = NONFIXED(FIXED0_5 - radius*ffsin(start));
|
||||
exb = radius*ffcos(end); ey = NONFIXED(FIXED0_5 - radius*ffsin(end));
|
||||
#elif GFX_USE_GMISC && GMISC_NEED_FASTTRIG
|
||||
sxb = FP2FIXED(radius*fcos(start)); sy = -round(radius*fsin(start));
|
||||
exb = FP2FIXED(radius*fcos(end)); ey = -round(radius*fsin(end));
|
||||
sxb = FP2FIXED(radius*fcos(start)); sy = floor(0.5-radius*fsin(start));
|
||||
exb = FP2FIXED(radius*fcos(end)); ey = floor(0.5-radius*fsin(end));
|
||||
#else
|
||||
sxb = FP2FIXED(radius*cos(start*GFX_PI/180)); sy = -round(radius*sin(start*GFX_PI/180));
|
||||
exb = FP2FIXED(radius*cos(end*GFX_PI/180)); ey = -round(radius*sin(end*GFX_PI/180));
|
||||
sxb = FP2FIXED(radius*cos(start*GFX_PI/180)); sy = floor(0.5-radius*sin(start*GFX_PI/180));
|
||||
exb = FP2FIXED(radius*cos(end*GFX_PI/180)); ey = floor(0.5-radius*sin(end*GFX_PI/180));
|
||||
#endif
|
||||
sxd = sy ? sxb/sy : sxb;
|
||||
exd = ey ? exb/ey : exb;
|
||||
|
@ -1864,7 +1868,7 @@ void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c
|
|||
if (sy > 0) qtr |= 0x02;
|
||||
if (exb > 0) qtr |= 0x04; // E1=0100(4), E2=0000(0), E3=1000(8), E4=1100(12)
|
||||
if (ey > 0) qtr |= 0x08;
|
||||
if (sy > ey) qtr |= 0x10; // order of start and end lines
|
||||
if (sy > ey || (sy == ey && sxb > 0)) qtr |= 0x10; // order of start and end lines
|
||||
|
||||
// Calculate intermediates
|
||||
a = 1;
|
||||
|
@ -2318,7 +2322,7 @@ void gdispGBlitArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c
|
|||
}
|
||||
} while(a < b);
|
||||
if (a <= ey) {
|
||||
g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C
|
||||
g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = NONFIXED(exa); hline_clip(g); // S2E
|
||||
} else if (a <= sy) {
|
||||
g->p.y = y+a; g->p.x = NONFIXED(sxa); g->p.x1 = x+b; hline_clip(g); // S2C
|
||||
} else if (!(qtr & 4)) {
|
||||
|
|
Loading…
Reference in New Issue