canvas .c ; pack .c100.0 100.0 150.0 150.0
.c create rectangle 0 0 50 50 -outline "" -tag RECT
.c moveto RECT 100 100
.c coords RECT
Please try this:
canvas .c ; pack .c100.0 100.0 150.0 150.0
.c create rectangle 0 0 50 50 -outline "" -tag RECT
.c moveto RECT 100 100
.c coords RECT
The problem is that the rectangle in your example gets an outline
per default which counts when calculating the bounding box:
pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first
coordinate pair (the upper-left corner of the bounding box) ...
Hope that helps.
Il giorno lunedì 30 agosto 2021 alle 10:44:58 UTC+2 Uwe Schmitz ha scritto:coordinate will be unchanged. All items matching tagOrId remain in the same positions relative to each other. This command returns an empty string.
Please try this:
canvas .c ; pack .c100.0 100.0 150.0 150.0
.c create rectangle 0 0 50 50 -outline "" -tag RECT
.c moveto RECT 100 100
.c coords RECT
The problem is that the rectangle in your example gets an outline
per default which counts when calculating the bounding box:
pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first
coordinate pair (the upper-left corner of the bounding box) ...
Hope that helps.Sorry but I don't agree.
From the canvas widget spec:
[..] pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first coordinate pair of the bottommost item with tag tagOrId is located at position (xPos,yPos). xPos and yPos may be the empty string, in which case the corresponding
With other words, "moveto" has nothing to do with the item's border thickness or the bbox, just with the position of item as returned by the "coords" method.
As my little code snippet demonstrated, when I "moveto" a RECT to (100,100) the "first coordinate pair of the bottommost item"
it's not moved to (100,100) but it's moved to (101,101) !
I think that I should open a BUG.
From the canvas widget spec:coordinate will be unchanged. All items matching tagOrId remain in the same positions relative to each other. This command returns an empty string.
[..] pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first coordinate pair of the bottommost item with tag tagOrId is located at position (xPos,yPos). xPos and yPos may be the empty string, in which case the corresponding
coordinate will be unchanged. All items matching tagOrId remain in the same positions relative to each other. This command returns an empty string.From the canvas widget spec:
[..] pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first coordinate pair of the bottommost item with tag tagOrId is located at position (xPos,yPos). xPos and yPos may be the empty string, in which case the corresponding
I don' know where you get this specification, which doesn't mention the bounding box.
IMO the "official" documentation for canvas moveto (V8.6) is here: https://www.tcl.tk/man/tcl8.6/TkCmd/canvas.html#M60
and this mentions the bounding box as the source for the moveto.
Am 06.09.21 um 11:22 schrieb Uwe Schmitz:coordinate will be unchanged. All items matching tagOrId remain in the same positions relative to each other. This command returns an empty string.
From the canvas widget spec:
[..] pathName moveto tagOrId xPos yPos
Move the items given by tagOrId in the canvas coordinate space so that the first coordinate pair of the bottommost item with tag tagOrId is located at position (xPos,yPos). xPos and yPos may be the empty string, in which case the corresponding
Many thanks Csaba,I don' know where you get this specification, which doesn't mention the bounding box.
IMO the "official" documentation for canvas moveto (V8.6) is here: https://www.tcl.tk/man/tcl8.6/TkCmd/canvas.html#M60
and this mentions the bounding box as the source for the moveto.
The clarification "(the upper-left corner of the bounding box)" was
added to the description of the moveto command in the canvas man page in
Tk 8.6.11, thus fixing a documentation bug reported by Schelte Bron back
in 2014. See
https://core.tcl-lang.org/tk/tktview?name=279b027fd7
--
Csaba Nemethi https://www.nemethi.de mailto:csaba....@t-online.de
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 33:30:08 |
Calls: | 6,449 |
Calls today: | 1 |
Files: | 12,052 |
Messages: | 5,254,982 |