• Re: How to center a circle?

    From Ralf Fassel@21:1/5 to All on Wed Oct 16 18:36:36 2024
    * Helmut Giese <hgiese@ratiosoft.com>
    | >Looks pretty centered to me.. although adding +1 to the x1 and x2 coords
    | >makes it even 'more' centered :-) (TK version, since I don't have tkpath at | >hand).
    | looking at my monitor this sounds incredible - it is so obvious. Ok, I
    | made a mistake: I didn't tell platform and version: I am on Windows
    | 10 and run Tcl 8.6.10.

    Same results here on Linux and Windows 10 with tk 8.6.15...

    | If I knew a site where I could upload a screen shot everybody would
    | see what I am talking about.

    Select any of
    https://www.google.com/search?q=public+upload+site
    ?

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Wed Oct 16 19:57:59 2024
    Hello Ralf,
    Select any of
    https://www.google.com/search?q=public+upload+site
    ?
    this was very helpful. The screen shots are now on https://imgbb.com/
    with the URLs:
    TkPath: https://ibb.co/gg6XsRm
    Tk: https://ibb.co/LkGg9mv
    Apart from the rugged edge in Tk they look pretty identical to me.
    And to me the left and top edges are significant smaller than their
    right and bottom counter parts - about less than half I would say.

    Am I crazy? Does my monitor play tricks with me? I know that I don't
    have perfect eye sight - that's why I am wearing glasses since the age
    of ten and so far it has helped me lead a normal life.

    A very confused
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Helmut Giese on Wed Oct 16 18:58:18 2024
    On 10/16/2024 10:57 AM, Helmut Giese wrote:

    Am I crazy? Does my monitor play tricks with me? I know that I don't
    have perfect eye sight - that's why I am wearing glasses since the age
    of ten and so far it has helped me lead a normal life.

    A very confused
    Helmut

    I'm on windows 10 and they look completely symmetrical to me. A circle enclosed in a box. I see the same from an android phone.

    Do you perchance have more than a few diopters of cylinder (astigmatism) in your glasses? That's the only thing other than it being your computer/monitor that comes to mind :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Thu Oct 17 10:55:00 2024
    * Helmut Giese <hgiese@ratiosoft.com>
    | The screen shots are now on https://imgbb.com/
    | with the URLs:
    | TkPath: https://ibb.co/gg6XsRm
    | Tk: https://ibb.co/LkGg9mv
    | Apart from the rugged edge in Tk they look pretty identical to me.
    | And to me the left and top edges are significant smaller than their
    | right and bottom counter parts - about less than half I would say.

    Ok, this is the same what I see. I was not sure whether this small
    difference already counts as 'big' :-p

    As I said, they get 'more centered' if you adjust the coordinates by +1:

    set x1 [expr {$width * 0.04 +1}]
    ...
    set x2 [expr {$width - $width * 0.04 +1}]

    I can only guess as what might be the reason, but my €0.01 would go to a combination of coordinate origin, rounding effects, DPI of the display,
    phase of the moon, and of course currently the comet.

    R', just kidding for the last two... ;-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Thu Oct 17 19:45:11 2024
    I want to thank all of you for responding.
    Well, what's the conclusion? If you all say that the circle is
    centered who am I to disagree.
    It is somewhat troublesome that apparently I cannot trust my own eyes
    but, as I said, who am I to disagree.
    @et99: Yes, I have always had rather strong glasses but so far I had
    never have any reason to mistrust my perception. Ok, it sems that
    there always is a first time.
    Maybe I should attribute it to age - not a very pleasant thought
    either. Well ...
    Many thanks again
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Shaun Deacon@21:1/5 to Helmut Giese on Fri Oct 18 09:28:00 2024
    Helmut Giese wrote:
    I want to thank all of you for responding.
    Well, what's the conclusion? If you all say that the circle is
    centered who am I to disagree.
    It is somewhat troublesome that apparently I cannot trust my own eyes
    but, as I said, who am I to disagree.
    @et99: Yes, I have always had rather strong glasses but so far I had
    never have any reason to mistrust my perception. Ok, it sems that
    there always is a first time.
    Maybe I should attribute it to age - not a very pleasant thought
    either. Well ...
    Many thanks again
    Helmut


    Looking at your images, the rectangle and circle are closer to the
    top-left corner of the canvas than the bottom-right - is this what you
    mean ?

    Shaun

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Fri Oct 18 20:53:14 2024
    Looking at your images, the rectangle and circle are closer to the
    top-left corner of the canvas than the bottom-right - is this what you
    mean ?
    Yes, exactly. However, meanwhile I got convinced that it was only an
    optical illusion (with the help of Tk itself): I enhanced my OP and it
    showed that there is no difference.
    ---
    package require Tk
    package require tkpath

    foreach ch [winfo children "."] {destroy $ch}

    set useTK 0
    if {$argc} {
    set useTK 1
    }
    if {$useTK} {
    set c [canvas .c -background gray50 -width 200 -height 200]
    } else {
    set c [tkp::canvas .c -background gray50 -width 200 -height 200]
    }
    pack $c -padx 10 -pady 10

    set width [$c cget -width]
    set height [$c cget -height]

    set x1 [expr {$width * 0.04}]
    set y1 $x1
    set x2 [expr {$width - $width * 0.04}]
    set y2 $x2
    if {$useTK} {
    $c create oval $x1 $y1 $x2 $y2 -fill white -outline white
    } else {
    set xc [expr {$x1 + ($x2 - $x1) / 2.0}]
    set yc [expr {$y1 + ($y2 - $y1) / 2.0}]
    set r [expr {($x2 - $x1) / 2.0}]
    $c create circle $xc $yc -r $r -fill white -stroke white
    }
    $c create rectangle $x1 $y1 $x2 $y2 -outline red
    puts "horizontal diff: [expr {$x1}] vs [expr {$width - $x2}]"
    puts "vertical diff: [expr {$y1}] vs [expr {$height - $x2}]"
    ---
    So, no matter what the monitor shows (or what we believe it shows) the
    output says that all margins are 8 px.
    Helmut

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)