Canvas Creation Methods

To place graphic elements in a canvas, there are several item creation methods:

createArc

Creates an arc contained within the given bounding box. For example, to create an oval bounded by the box from (0,0) to (40,100):

$canvas->createArc(0,0,40,100, -extent => 360);

The -extent option gives a number between 0 and 360 defining the length of the arc. The default -extent is 90, or 1/4 of an oval; an extent of 360 gives you a full oval. The complete list of options to createArc is:

-extent => degrees

Creates an arc of the specified extent. degrees can be any number between 0 and 360, as described above.

-fill => color

Fills the arc with the specified color.

-outline => color

Draws the arc with the specified color (default is black).

-outlinestipple => bitmap

Draws the outline with the specified bitmap pattern.

-start => degrees

Starts drawing the arc from the specified position, which is represented by a number from 0 to 360. The default is 0, which means to start drawing at the 3 o’clock position.

-stipple => bitmap

Uses the specified bitmap to fill the arc (if -fill is also specified).

-style => type

Draws the arc as specified. Values are:

pieslice

Draws lines from the center to the ends of the arc (the default)

chord

Draws a line connecting the two ends of the arc

arc

Draws the arc with no other lines

-tags => tagnames

Associates the arc with the specified tag(s). Multiple tag names can be supplied as an anonymous list.

-width => amount

The width of the outline. Default is 1.

createBitmap ...

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.