Tk canvas: why are some lines a pixel too short?
- From: ptw@xxxxxxxxxxxxxxxxxxxxx (Pat Wallace)
- Date: Thu, 13 Jul 2006 09:46:03 +0000 (UTC)
My Tk application draws its own characters, using lines. I have noticed
that some characters look OK when drawn big but go ugly when redrawn
smaller - so it's not the font to blame. For example my uppercase X seems
to have one few pixel fewer lit up on the two right-hand ends compared
with the left-hand ends.
The following Tcl script demonstrates the kind of thing I mean. It draws
lines radially outwards from a center point, every 10 degrees, constant
radius:
package require Tk
canvas .c -width 100 -height 100
pack .c
set x 50
set y 50
set r 4.5
for {set i 0} {$i < 36} {incr i} {
set t [expr $i*0.174532925]
.c create line $x $y [expr $x+$r*sin($t)] [expr $y+$r*cos($t)]
}
You can get different effects by changing x, y and r. With the values
used above, the supposedly symmetrical pattern has a distinctly flat
lower-right quadrant. (You may need to use a magnifying glass.) Using
deliberately oddball values, such as x=y=50.1, or r=4.7, have an influence
on the pixel pattern, as you'd expect, but the unwanted asymmetry is
frequently seen.
What is the cause, and can I somehow stop it happening? n.b. (i) my
application doesn't know about the mapping from world coordinates to pixel
coordinates, and doesn't want to know, and (ii) I have tried changing the
capstyle to "projecting" etc., but on 1-pixel-wide lines I don't think
this has any effect.
It is as if the line drawing is truncating coordinates rather than
rounding.
Patrick Wallace
____________________________________________________________________________
Space Science & Technology Dept
Rutherford Appleton Laboratory
Chilton, Didcot,
Oxon OX11 0QX, UK
____________________________________________________________________________
.
- Follow-Ups:
- Re: Tk canvas: why are some lines a pixel too short?
- From: Christian Gollwitzer
- Re: Tk canvas: why are some lines a pixel too short?
- From: maurice . ulis
- Re: Tk canvas: why are some lines a pixel too short?
- Prev by Date: Re: two expect scripts using the same spawned process
- Next by Date: Re: Tk canvas: why are some lines a pixel too short?
- Previous by thread: Another parser question
- Next by thread: Re: Tk canvas: why are some lines a pixel too short?
- Index(es):
Relevant Pages
|
Loading