Skip to content

Commit bb8ca0b

Browse files
committed
bugfix [6051a9fc]: MS-Win canvas arcs with to small extend are drawn as 360 degrees
1 parent d5390ba commit bb8ca0b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ to the userbase.
2626
- [Aqua: compiler warning in tkMacOSXImage.c](https://core.tcl-lang.org/tk/tktview/7f3751)
2727
- [tkpWinRopModes[GXnoop] is R2_NOT, should be R2_NOP](https://core.tcl-lang.org/tk/tktview/95da0f)
2828
- [image svg: support paint order and fix possible nan race condition](https://core.tcl-lang.org/tk/tktview/b43dbc)
29+
- [MS-Win canvas arcs with small extent are drawn 360 dregrees](https://core.tcl-lang.org/tk/info/6051a9fc)
2930

3031
Release Tk 9.0.2 arises from the check-in with tag `core-9-0-2`.
3132

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)