Using ObjectAffineDistort command

Corel PHOTO-PAINT is a bitmap editing application which means it works with bitmap images. Sometimes those bitmap are really huge and opertations on those bitmap could take awhile to complete.

Frequently it is necessary to perform several consecutive transformations on a single object (e.g. stretch it, then rotate and skew). And not even it could take long to perform each individual operation, each transformation reduces the quality of the image by adding more blur to it.

Fortunately there is a way to combine different types of transformations (stretch, rotation and skew) into one transformation command and do them all at once. This speeds up the transformation and provides better result. This magic scripting command is ObjectAffineDistort.

This command uses a transformation matrix to perform the transformation. A transformation matrix is four numbers that include three transformations.

If a is a rotation angle, b is a skew angle, and Dx and Dy are horizontal and vertical stretch factors, then the transformation matrix will look like:

Each matrix element is referred to as D11, D12, D21, and D22 respectively (left to right, top to bottom).

ObjectAffineDistort command takes the four transformation matrix elements,  the translation values to perform the transformation, and a boolean indicating whether or not use anti-aliasing. The translation values show the position of the lower left corner of the transformed object relatively to the lower left corner of the document.

So, here is an example of how to apply rotation, skew and stretch to an object at one step. (You can use it to apply even one transformation only though - just use 1 for each "unused" stretch values and 0 for each angle).

Note the order of matrix elements. They go in the following order: D11, D21, D12, D22, not .., D12, D21,...

WITHOBJECT "CorelPhotoPaint.Automation.9"
	.ObjectAffineDistort 0, 0, D11, D21, D12, D22, TRUE
		.ObjectSelect 1, TRUE

[ CorelSCRIPT Tips&Tricks | Learning CorelSCRIPT | Oberon Home Page ]

Copyright 2000 by Alex Vakulenko. All rights reserved.
This page was last revised on 02/14/00.