Tk canvas: why are some lines a pixel too short?



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
____________________________________________________________________________

.



Relevant Pages

  • Re: What books/characters should Mark Bagley draw?
    ... characters, I haven't cared for his rendition of them (a Superman ... don't look the same - which some artists still have a problem with. ... He draws "dynamic" which is always a plus. ... comics so it would fit with the above titles. ...
    (rec.arts.comics.dc.universe)
  • Re: Eliza, plot-noodler subordinaire (Re: Which way round do you work?)
    ... I would suggest giving the software a list of your characters' ... Would you mind emailing me what you have of the ... Whatever it draws upon, propositions, questions, whatever. ... working program. ...
    (rec.arts.sf.composition)
  • Re: Ubuntu virtual terminal - characters not showing correctly
    ... when slrn has a thread opened it draws the thread tree ... This worked perfectly under most terminals on ... The graphics characters that slrn draws may be ...
    (comp.os.linux.misc)
  • Re: Screen Size
    ... So I presume you mean that you used the conversion obtained from Point to Pixels to set up the size of your font in the LOGFONT structure that you used with CreateFontIndirect API and then just happened to draw that text to the screen DC using DrawText. ... If that is the case then you've probably used the pixel value directly when using CreateFontIndirect, ... When you use a negative value for the pixel size in the lfHeight entry in the LOGFONT structure then you are effectively asking Windows to select a font size such that the height of the "glyph" (the part of the character cell actually occupied by the shape of the characters) is the requested pixel height. ...
    (microsoft.public.vb.general.discussion)
  • Re: Today screen plugin not displaying correctly on 2003 SE VGA Device
    ... My plugin simply draws text to the screen, ... I'm using GetClientRectto determine the item window width, ... assuming a specific pixel width. ... > We included a pixel doubling feature that should enable your application ...
    (microsoft.public.pocketpc.developer)

Loading