NAME

canvas - Create and manipulate a widget which is a generic engine for structured graphics

SYNOPSIS

canvas ?-option optionVal ...?

OPTIONS

-heigth
height of canvas
type: integer
default: 500
-width
width of canvas
type: integer
default: 500
-antialiased
Determines if the antialiased version of the canvas widget should be used. It seems, that only this version can rotate items.
type: boolean
default: true

DESCRIPTION

Canvas widgets implement structured graphics. A canvas displays any number of items, which may be rectangles, circles, lines, and text. Items may be manipulated (e.g. moved or re-colored) and commands may be associated with items with the bind command. For example, a particular command may be associated with the <button>-event so that the command is invoked whenever a button is pressed with the mouse cursor over an item. This means that items in a canvas can have behaviors defined by the Tcl scripts bound to them.

WIDGET COMMANDS

The canvas command creates a new Tcl command whose name is an ID returned on widget creation. This command may be used to invoke various operations on the widget. It has the following general form:

ID option ?arg arg ...?

option and arg determine the exact behavior of the command. The following commands are possible for canvas widgets:
ID create type list-of-coordinates ?-option optionVal ...?
Create a new item. Returns an item identifier. Valid types are line, rectangle, ellipse, text, and widget. Valid options are dependent of the type.
ID delete id
delete item id
delete all deletes all items. In future versions the complete support of tags is planned (see Tk).
ID itemHide id
hide item id
ID itemShow id
show item id
ID itemConfigure ?-option optionVal ...?
configure item id. Valid options are dependent of type of item
ID coords
not yet implemented
ID affine id list-of-coordinates
make affine transformation of id. Length of list-of-coordinates must be 6· The new coordinates are calculated by
x_new = af[0] * x_old + af[2] * y_old + af[4];
y_new = af[1] * x_old + af[3] * y_old + af[5];
ID scale id list-of-coordinates
Scales id. Length of list-of-coordinates must be 3 (center point and scale) or 4 (center point, x scale, and y scale).
ID move id list-of-coordinates
Moves id. Length of list-of-coordinates must be 2 (delta x and delta y)·
ID rotate id list-of-coordinates
Rotates id. Length of list-of-coordinates must be 3 (center point and angle)·
ID windowToWorld list-of-coordinates
Converts window coordinates to world coordinates.
ID worldToWindow list-of-coordinates
Converts world coordinates to window coordinates.
ID findItemAt x y
Returns id of item at the world coordinates x and y.
ID getBounds id
Returns the bounds (x1, y1, x2, y2) of id in world coordinates.

KEYWORDS


Copyright © 2001 - 2002 P. G. Baum