Adds non-inear transformations to the ASVDrawing class, which are defined as functions. Here are some examples of the method in action: example1, example2, example3, example4
myASVDrawing.setTransform(transformFunc)
Applies a transform function to an instance of ASVDrawing. This function should take two arguments, the x and y coordinates of a point. And it should return an object with x and y properties, which is the transformed coordinates of the point.
myASVDrawing.removeTransform()
Removes a transform from an instance of ASVDrawing.
These are functions that return another function, which an be used as a transformation function. They are called as methods of ASVDrawing
rather than of individual instances.
ASVDrawing.createWhirl(centreX, centreY, radius, amount)
Returns a function that can be passed to myASVDrawing.setTransform.
This function creates a "whirl" effect. The effect is confined to
a circular area, defined by the arguments. The final argument is the maximum
rotation, measured in degrees.
ASVDrawing.createPinch(xMin, yMin, xMax, yMax, xAmount, yAmount)
Returns a function that can be passed to myASVDrawing.setTransform.
This function creates a "pinch" or pin-cushion effect. The effect
is confined to a rectangular area, defined by the first four argumants. The
final two arguments (xAmount and yAmount)
are percentage values for how much the shape is pinched in the x and y directions.
If you set a negative value then the shape will appear inflated instead.
ASVDrawing.createWaves(xMin, yMin, xMax, yMax, xAmount, yAmount, xCount,
yCount, xOffset, yOffset)
Returns a function that can be passed to myASVDrawing.setTransform.
This function creates a "wave" effect in both the x an y direction.
The effect is confined to a rectangular area, defined by the first four argumants.
The next two arguments (xAmount and yAmount)
are percentage values for how much the shape is distorted by each wave. xCount
and yCount determine how many waves occur in each direction
and xOffset and yOffset determine
an angular offset for the wave function.
ASVDrawing.createFreeform(xMin, yMin, xMax, yMax, x0,y0, x1,y1, x2,y2,
x3,y3)
Returns a function that can be passed to myASVDrawing.setTransform.
This function can be used to manipulate the corners of bounding box of a drawing.
The bounding box, defined by the first four arguments is transformed to the
quadrilateral, defined by the four points (x0,y0,), (x1,y1), (x2,y2), (x3,y3),
as shown in this diagram:

#include "ASVDrawing.as"
#include "ASVDrawingTransformFunction.as"
squareData = [['S',[1,0xFF0000]],
['M',[0,0]],
['L',[0,100]],
['L',[100,100]],
['L',[100,0]],
['L',[0,0]]
];
pinch = ASVDrawing.createPinch(0,0,100,100,50,-20);
squareDrawing = new ASVDrawing(squareData);
squareDrawing.linesToCurves();
squareDrawing.setTransformFunction(pinch);
_root.draw(squareDrawing);
download
actionscript file
download
ASVDrawing AS file