This is not necessarily the current version of this TIP.
|Title:||Moving Vertices of Canvas Items|
|Version:||$Revision: 1.6 $|
Agnar Renolen <agnar dot renolen at emap dot no>|
Donal K. Fellows <donal dot k dot fellows at manchester dot ac dot uk>
|Created:||Friday, 07 June 2002|
This TIP proposes a canvas subcommand (or possibly two) that allows for replacing characters in text objects and to move individual vertices of line and polygon items.
Interactive graphics programs often allow users to modify shapes of objects by selecting and dragging the vertices. Moving one vertex of a canvas item in the current version of Tk, (at least as far as I can find out from the documentation), can only be done by first removing the coordinate by dchars and then insert the new one by insert, or for geometric items like lines and polygons using the coords command to obtain and reset the coordinates, after having modified the coordinate list by lreplace.
The most important issue here, I think, is performance. I believe that the current way of moving a vertex can be slow in some scenarios.
The rchars canvas subcommand is proposed merely to conform with the dchars and insert commands, which both operate on lines, polygons and text items, hence rchars should do that as well.
Two canvas widget subcommands are proposed: imove and rchars. The following subcommand is proposed to move a vertex of any canvas item:
canvas imove tagOrID index x y
This subcommand will move the indexth coordinate of the items identified by tagOrID to the new position given by x and y. The index value will be processed according to normal canvas index rules (see the INDICES section of the canvas manual). The subcommand will only work for line and polygon items.
The following command provides a similar functionality, but conforms to the model of the current insert and dchars subcommands.
canvas rchars tagOrID first last string
This command will:
replace the characters in the range first and last (inclusive) with the characters in string.
replace the coordinates in the range first and last (inclusive) with the coordinate list specified in string (subject to the requirement that the coordinate list is an even number of floating point numbers).
In both cases, first and last will be processed according to the rules in the INDICES section of the canvas manual page.
The imove subcommand is not strictly necessary as the rchars subcommand can be used to obtain the same result. However, I believe that a separate imove subcommand will be easier to understand for users than the rchars subcommand, though the latter is still necessary as it allows f