Skip to content

Commit cb11034

Browse files
committed
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees
2 parents aa66ab6 + 56effa4 commit cb11034

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

win/tkWinDraw.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,13 @@ DrawOrFillArc(
12131213
int clockwise = (extent < 0); /* non-zero if clockwise */
12141214
int xstart, ystart, xend, yend;
12151215
double radian_start, radian_end, xr, yr;
1216+
int extent_less_than_180_deg;
1217+
1218+
extent = extent % (64*360);
1219+
if (extent < 0) {
1220+
extent += (64*360);
1221+
}
1222+
extent_less_than_180_deg = (extent < (64*180));
12161223

12171224
if (d == None) {
12181225
return BadDrawable;
@@ -1256,6 +1263,32 @@ DrawOrFillArc(
12561263
xend = (int)((xr + cos(radian_end)*width/2.0) + 0.5);
12571264
yend = (int)((yr + sin(-radian_end)*height/2.0) + 0.5);
12581265

1266+
if ((xstart == xend) && (ystart == yend) && extent_less_than_180_deg) {
1267+
/*
1268+
* The extent is so small that the arc size is less than one pixel.
1269+
* If the Arc, Chord, or Pie GDI function later received this, then
1270+
* a complete ellipse would be drawn instead of the desired 1-pixel
1271+
* size arc. The end point must be made different from the start
1272+
* point. Since (at this level in the code) arcs are always drawn
1273+
* counterclockwise, either xend or yend needs adjustment, depending
1274+
* on the sub-range where radian_start lies (it was constrained to
1275+
* the [0 ; 2*PI[ range earlier). See bug [6051a9fc]
1276+
*/
1277+
if (radian_start > PI/4) {
1278+
if (radian_start < 3*PI/4) {
1279+
xend--;
1280+
} else if (radian_start < 5*PI/4) {
1281+
yend++;
1282+
} else if (radian_start < 7*PI/4) {
1283+
xend++;
1284+
} else {
1285+
yend--;
1286+
}
1287+
} else {
1288+
yend--;
1289+
}
1290+
}
1291+
12591292
/*
12601293
* Now draw a filled or open figure. Note that we have to increase the
12611294
* size of the bounding box by one to account for the difference in pixel

0 commit comments

Comments
 (0)