124
Auto Shapes
You can create Auto Shape icons for the Tools panel or Auto Shapes panel in PNG, JPG, or
GIF format. For the Tools panel, the icon image should be 16 x 16 pixels (if the image is
larger than 16 x 16 pixels, Fireworks scales the image to fit in the Tools panel). For the Auto
Shapes panel, the Auto Shape icon should be 60 x 60 pixels. If the image for the Auto Shapes
panel is smaller, or larger, than 60 x 60 pixels, Fireworks will not scale the image—the icon
will appear centered in its cell, but not sized to fit, so it may appear cropped if it is too large.
Creating an Auto Shape
To create an Auto Shape, you need to define a series of properties for the shape, define the
shape’s control points, and write functions that tell Fireworks how to handle the Auto Shape
as the user interacts with the object (for more information, see
“Handling the user
interaction” on page 126
).
Defining the shape
The following code creates the initial shape, a rectangle (a more concise way of creating an
initial shape follows this example):
function InsertSmartShapeAt()
{
smartShape.elem.elements[0] = new Path;
smartShape.elem.elements[0].contours[0] = new Contour;
smartShape.elem.elements[0].contours[0].nodes[0] = new ContourNode;
smartShape.elem.elements[0].contours[0].nodes[0].predX = 0;
smartShape.elem.elements[0].contours[0].nodes[0].predY = 0;
smartShape.elem.elements[0].contours[0].nodes[0].x = 0;
smartShape.elem.elements[0].contours[0].nodes[0].y = 0;
smartShape.elem.elements[0].contours[0].nodes[0].succX = 0;
smartShape.elem.elements[0].contours[0].nodes[0].succY = 0;
smartShape.elem.elements[0].contours[0].nodes[1] = new ContourNode;
smartShape.elem.elements[0].contours[0].nodes[1].predX = 200;
smartShape.elem.elements[0].contours[0].nodes[1].predY = 0;
smartShape.elem.elements[0].contours[0].nodes[1].x = 200;
smartShape.elem.elements[0].contours[0].nodes[1].y = 0;
smartShape.elem.elements[0].contours[0].nodes[1].succX = 200;
smartShape.elem.elements[0].contours[0].nodes[1].succY = 0;
smartShape.elem.elements[0].contours[0].nodes[2] = new ContourNode;
smartShape.elem.elements[0].contours[0].nodes[2].predX = 200;
smartShape.elem.elements[0].contours[0].nodes[2].predY = 125;
smartShape.elem.elements[0].contours[0].nodes[2].x = 200;
NO
TE
If the icon is missing (or named incorrectly) then Fireworks does not display an icon.
However, if the Auto Shapes folder has an icon with the same name as a shape in the
Auto Shape Tools folder, then that icon will be used in the Tools panel.
Содержание FIREWORKS 8-EXTENDING FIREWORKS
Страница 1: ...Extending Fireworks ...
Страница 4: ...4 Contents ...
Страница 358: ...358 Fireworks JavaScript API ...
Страница 372: ...372 Index ...