canvas.html
来自「perl教程」· HTML 代码 · 共 1,385 行 · 第 1/5 页
HTML
1,385 行
obscure other item types, and the stacking order of window items is
determined by the <strong>raise</strong> and <strong>lower</strong> methods of the widget, not the
<strong>raise</strong> and <strong>lower</strong> methods for canvases.
This method returns an empty string.</p>
</dd>
</li>
<dt><strong><a name="item_move"><em>$canvas</em>-><strong>move</strong>(<em>tagOrId, xAmount, yAmount</em>)</a></strong>
<dd>
<p>Move each of the items given by <em>tagOrId</em> in the canvas coordinate
space by adding <em>xAmount</em> to the x-coordinate of each point
associated with the item and <em>yAmount</em> to the y-coordinate of
each point associated with the item.
This method returns an empty string.</p>
</dd>
</li>
<dt><strong><a name="item_postscript"><em>$canvas</em>-><strong>postscript</strong>(?<em>option, value, option, value, ...</em>?)</a></strong>
<dd>
<p>Generate a Postscript representation for part or all of the canvas.
If the <strong>-file</strong> option is specified then the Postscript is written
to a file and an empty string is returned; otherwise the Postscript
is returned as the result of the method.
If the interpreter that owns the canvas is marked as safe, the operation
will fail because safe interpreters are not allowed to write files.
If the <strong>-channel</strong> option is specified, the argument denotes the name
of a channel already opened for writing. The Postscript is written to
that channel, and the channel is left open for further writing at the end
of the operation.
The Postscript is created in Encapsulated Postscript form using
version 3.0 of the Document Structuring Conventions.
Note: by default Postscript is only generated for information that
appears in the canvas's window on the screen. If the canvas is
freshly created it may still have its initial size of 1x1 pixel
so nothing will appear in the Postscript. To get around this problem
either invoke the <strong>update</strong> method to wait for the canvas window
to reach its final size, or else use the <strong>-width</strong> and <strong>-height</strong>
options to specify the area of the canvas to print.
The <em>option</em>-<em>value</em> argument pairs provide additional
information to control the generation of Postscript. The following
options are supported:</p>
</dd>
<dl>
<dt><strong><a name="item__2dcolormap__3d_3e_hashref"><strong>-colormap</strong> => <em>hashRef</em></a></strong>
<dd>
<p><em>HashRef</em> must be a reference to a hash variable or an anonymous hash
that specifies a color mapping to use in the Postscript.
Each value of the hash must consist of Postscript
code to set a particular color value (e.g. ``<strong>1.0 1.0 0.0 setrgbcolor</strong>'').
When outputting color information in the Postscript, Tk checks
to see if there is a key in the hash with the same
name as the color.
If so, Tk uses the value of the element as the Postscript method
to set the color.
If this option hasn't been specified, or if there isn't a key
in <em>hashRef</em> for a given color, then Tk uses the red, green,
and blue intensities from the X color.</p>
</dd>
</li>
<dt><strong><a name="item__2dcolormode__3d_3e_mode"><strong>-colormode</strong> => <em>mode</em></a></strong>
<dd>
<p>Specifies how to output color information. <em>Mode</em> must be either
<strong>color</strong> (for full color output), <strong>gray</strong> (convert all colors
to their gray-scale equivalents) or <strong>mono</strong> (convert all colors
to black or white).</p>
</dd>
</li>
<dt><strong><a name="item__2dfile__3d_3e_filename"><strong>-file</strong> => <em>fileName</em></a></strong>
<dd>
<p>Specifies the name of the file in which to write the Postscript.
If this option isn't specified then the Postscript is returned as the
result of the method instead of being written to a file.</p>
</dd>
</li>
<dt><strong><a name="item__2dfontmap__3d_3e_hashref"><strong>-fontmap</strong> => <em>hashRef</em></a></strong>
<dd>
<p><em>HashRef</em> must be a reference to a hash variable or an anonymous hash
that specifies a font mapping to use in the Postscript.
Each value of the hash must consist of an array reference with
two elements, which are the name and point size of a Postscript font.
When outputting Postscript commands for a particular font, Tk
checks to see if <em>hashRef</em> contains a value with the same
name as the font.
If there is such an element, then the font information contained in
that element is used in the Postscript.
Otherwise Tk attempts to guess what Postscript font to use.
Tk's guesses generally only work for well-known fonts such as
Times and Helvetica and Courier, and only if the X font name does not
omit any dashes up through the point size.
For example, <strong>-*-Courier-Bold-R-Normal--*-120-*</strong> will work but
<strong>*Courier-Bold-R-Normal*120*</strong> will not; Tk needs the dashes to
parse the font name).</p>
</dd>
</li>
<dt><strong><a name="item__2dheight__3d_3e_size"><strong>-height</strong> => <em>size</em></a></strong>
<dd>
<p>Specifies the height of the area of the canvas to print.
Defaults to the height of the canvas window.</p>
</dd>
</li>
<dt><strong><a name="item__2dpageanchor__3d_3e_anchor"><strong>-pageanchor</strong> => <em>anchor</em></a></strong>
<dd>
<p>Specifies which point of the printed area of the canvas should appear over
the positioning point on the page (which is given by the <strong>-pagex</strong>
and <strong>-pagey</strong> options).
For example, <strong>-pageanchor</strong>=><strong>n</strong> means that the top center of the
area of the canvas being printed (as it appears in the canvas window)
should be over the positioning point. Defaults to <strong>center</strong>.</p>
</dd>
</li>
<dt><strong><a name="item__2dpageheight__3d_3e_size"><strong>-pageheight</strong> => <em>size</em></a></strong>
<dd>
<p>Specifies that the Postscript should be scaled in both x and y so
that the printed area is <em>size</em> high on the Postscript page.
<em>Size</em> consists of a floating-point number followed by
<strong>c</strong> for centimeters, <strong>i</strong> for inches, <strong>m</strong> for millimeters,
or <strong>p</strong> or nothing for printer's points (1/72 inch).
Defaults to the height of the printed area on the screen.
If both <strong>-pageheight</strong> and <strong>-pagewidth</strong> are specified then
the scale factor from <strong>-pagewidth</strong> is used (non-uniform scaling
is not implemented).</p>
</dd>
</li>
<dt><strong><a name="item__2dpagewidth__3d_3e_size"><strong>-pagewidth</strong> => <em>size</em></a></strong>
<dd>
<p>Specifies that the Postscript should be scaled in both x and y so
that the printed area is <em>size</em> wide on the Postscript page.
<em>Size</em> has the same form as for <strong>-pageheight</strong>.
Defaults to the width of the printed area on the screen.
If both <strong>-pageheight</strong> and <strong>-pagewidth</strong> are specified then
the scale factor from <strong>-pagewidth</strong> is used (non-uniform scaling
is not implemented).</p>
</dd>
</li>
<dt><strong><a name="item__2dpagex__3d_3e_position"><strong>-pagex</strong> => <em>position</em></a></strong>
<dd>
<p><em>Position</em> gives the x-coordinate of the positioning point on
the Postscript page, using any of the forms allowed for <strong>-pageheight</strong>.
Used in conjunction with the <strong>-pagey</strong> and <strong>-pageanchor</strong> options
to determine where the printed area appears on the Postscript page.
Defaults to the center of the page.</p>
</dd>
</li>
<dt><strong><a name="item__2dpagey__3d_3e_position"><strong>-pagey</strong> => <em>position</em></a></strong>
<dd>
<p><em>Position</em> gives the y-coordinate of the positioning point on
the Postscript page, using any of the forms allowed for <strong>-pageheight</strong>.
Used in conjunction with the <strong>-pagex</strong> and <strong>-pageanchor</strong> options
to determine where the printed area appears on the Postscript page.
Defaults to the center of the page.</p>
</dd>
</li>
<dt><strong><a name="item__2drotate__3d_3e_boolean"><strong>-rotate</strong> => <em>boolean</em></a></strong>
<dd>
<p><em>Boolean</em> specifies whether the printed area is to be rotated 90
degrees.
In non-rotated output the x-axis of the printed area runs along
the short dimension of the page (``portrait'' orientation);
in rotated output the x-axis runs along the long dimension of the
page (``landscape'' orientation).
Defaults to non-rotated.</p>
</dd>
</li>
<dt><strong><a name="item__2dwidth__3d_3e_size"><strong>-width</strong> => <em>size</em></a></strong>
<dd>
<p>Specifies the width of the area of the canvas to print.
Defaults to the width of the canvas window.</p>
</dd>
</li>
<dt><strong><a name="item__2dx__3d_3e_position"><strong>-x</strong> => <em>position</em></a></strong>
<dd>
<p>Specifies the x-coordinate of the left edge of the area of the
canvas that is to be printed, in canvas coordinates, not window
coordinates.
Defaults to the coordinate of the left edge of the window.</p>
</dd>
</li>
<dt><strong><a name="item__2dy__3d_3e_position"><strong>-y</strong> => <em>position</em></a></strong>
<dd>
<p>Specifies the y-coordinate of the top edge of the area of the
canvas that is to be printed, in canvas coordinates, not window
coordinates.
Defaults to the coordinate of the top edge of the window.</p>
</dd>
</li>
</dl>
<dt><strong><a name="item_raise"><em>$canvas</em>-><strong>raise</strong>(<em>tagOrId, </em>?<em>aboveThis</em>?)</a></strong>
<dd>
<p>Move all of the items given by <em>tagOrId</em> to a new position
in the display list just after the item given by <em>aboveThis</em>.
If <em>tagOrId</em> refers to more than one item then all are moved
but the relative order of the moved items will not be changed.
<em>AboveThis</em> is a tag or id; if it refers to more than one
item then the last (topmost) of these items in the display list is used
as the destination location for the moved items.
Note: this method has no effect on window items. Window items always
obscure other item types, and the stacking order of window items is
determined by the <strong>raise</strong> and <strong>lower</strong> widget commands, not the
<strong>raise</strong> and <strong>lower</strong> methods for canvases.
This method returns an empty string.</p>
</dd>
</li>
<dt><strong><a name="item_scale"><em>$canvas</em>-><strong>scale</strong>(<em>tagOrId, xOrigin, yOrigin, xScale, yScale</em>)</a></strong>
<dd>
<p>Rescale all of the items given by <em>tagOrId</em> in canvas coordinate
space.
<em>XOrigin</em> and <em>yOrigin</em> identify the origin for the scaling
operation and <em>xScale</em> and <em>yScale</em> identify the scale
factors for x- and y-coordinates, respectively (a scale factor of
1.0 implies no change to that coordinate).
For each of the points defining each item, the x-coordinate is
adjusted to change the distance from <em>xOrigin</em> by a factor
of <em>xScale</em>.
Similarly, each y-coordinate is adjusted to change the distance
from <em>yOrigin</em> by a factor of <em>yScale</em>.
This method returns an empty string.</p>
</dd>
</li>
<dt><strong><a name="item_scan"><em>$canvas</em>-><strong>scan</strong>(<em>option, args</em>)</a></strong>
<dd>
<p>This method is used to implement scanning on canvases. It has
two forms, depending on <em>option</em>:</p>
</dd>
<dl>
<dt><strong><a name="item_scanmark"><em>$canvas</em>-><strong>scanMark</strong>(<em>x, y</em>)</a></strong>
<dd>
<p>Records <em>x</em> and <em>y</em> and the canvas's current view; used
in conjunction with later <strong>scanDragto</strong> method.
Typically this method is associated with a mouse button press in
the widget and <em>x</em> and <em>y</em> are the coordinates of the
mouse. It returns an empty string.</p>
</dd>
</li>
<dt><strong><a name="item_scandragto"><em>$canvas</em>-><strong>scanDragto</strong>(<em>x, y, ?gain?</em>.)</a></strong>
<dd>
<p>This method computes the difference between its <em>x</em> and <em>y</em>
arguments (which are typically mouse coordinates) and the <em>x</em> and
<em>y</em> arguments to the last <strong>scanMark</strong> method for the widget.
It then adjusts the view by 10 times the
difference in coordinates. This method is typically associated
It then adjusts the view by <em>gain</em> times the
difference in coordinates, where <em>gain</em> defaults to 10.
This command is typically associated
with mouse motion events in the widget, to produce the effect of
dragging the canvas at high speed through its window. The return
value is an empty string.</p>
</dd>
</li>
</dl>
<dt><strong><a name="item_select"><em>$canvas</em>-><strong>select</strong>(<em>option, </em>?<em>tagOrId, arg</em>?)</a></strong>
<dd>
<p>Manipulates the selection in one of several ways, depending on
<em>option</em>.
The method may take any of the forms described below.
In all of the descriptions below, <em>tagOrId</em> must refer to
an item that supports indexing and selection; if it refers to
multiple items then the first of
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?