JBR - 2010-11-20
Here is a small namespace of commands to draw classical 2d structured graphics on the Tk canvas. Its currently about 200 lines of code so I placed it here [L1 ]. - TWu 2025-01-20 Reference gone without copy.
2d transforms are handled with this code: https://wiki.tcl-lang.org/1234 .
I need a better name its just called "canvas::" for now.
is at the center of the display and Y is up.
Drawing commands:
Each of the above graphic display items have their own coordinate system and may contain other items that will be positioned relative to them. In addition the "csys" command creates a coordinate system that can be used as a container for other graphical items and csys coordinate systems but contains no drawn item of its own. CSys coordinate system tags are in same namespace as canvas item tags and as such should not be integers. The "txti" item draws a canvas text item but is named so that it can be imported without conflicting with the Tk text widget command.
Drawing command take these options in addition to the options allowed by the canvas create item commands.
Move commands:
Other:
There are two methods for creating a hierarchy of graphics object coordinate systems. Items may be explicitly placed in the system of other objects with the "-in" option, or a code block can be included as the final parameter to an item command, any items created in that block are placed in the parent system by default:
set box [canvas::rect $c 0 0 10 10] canvas::rect 10 10 10 10 -in $box
Or:
canvas::rect $c 0 0 10 10 { canvas::rect 10 10 10 10 }
See Drawing diagrams as well.