TIP #97 Version 1.5: Moving Vertices of Canvas Items

This is not necessarily the current version of this TIP.


TIP:97
Title:Moving Vertices of Canvas Items
Version:$Revision: 1.5 $
Authors: Agnar Renolen <agnar dot renolen at emap dot no>
Donal K. Fellows <donal dot k dot fellows at manchester dot ac dot uk>
State:Draft
Type:Project
Tcl-Version:8.6
Vote:Pending
Created:Friday, 07 June 2002

Abstract

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.

Rationale

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.

Specification

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 item identified by tagOrID to the new position given by x and y. The index value will be subject to normal end processing, but refers to coordinate indices and not list indices. The subcommand should work f