开发者

Is this "pixel shift" a bug in tcl/tk canvas?

Look at result of this script:

 canvas .c -bg white
 grid .c
 set x1 20
 set x2 22
 set y2 105
 for {set f 0} {$f<50} {incr f} {
     set y1 [expr {$y2-0.05*$f}]
     .c create rectangle $x1 $y1 $x2 $y2 -fill 开发者_如何学Pythonblack
     incr x1 2
     incr x2 2
 }

On Windows XP I see that at left side of figure bottom margin is one pixel lower than at right side. But it shouldn't happen as y2 is the same (105) for all rectangles. What do you think?


I think it has to do with the effort of TK to draw a rectangle of a least 1 pixel in size.

In the code I can see, that y2 is incremeted by 1 if it's equal to y1 after rounding to short integer.

Logging your creation statements one can see, that the pixel jump occurs between f=10 and f=11. That is the point where y1 and y2 become unequal and no adjust takes place:

f=10 .c create rectangle 40 104.5 42 105 -fill black
   rounded:   y1=105 y2=105
   adjusted:  y1=105 y2=106
f=11 .c create rectangle 42 104.45 44 105 -fill black
   rounded:   y1=104 y2=105
   no adjustment

That explains the pixel jump.

IMO you should file a bug on this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜