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" a#=ANGLECONVERT(1,2,20) b#=ANGLECONVERT(1,2,10) Dx#=0.5 Dy#=0.5 D11#=Dx*Cos(a) D12#=-Dy*Sin(a+b) D21#=Dx*Sin(a) D22#=Dy*Cos(a+b) .ObjectAffineDistort 0, 0, D11, D21, D12, D22, TRUE .ObjectSelectNone .ObjectSelect 1, TRUE .EndObject END WITHOBJECT
Copyright © 2000 by Alex Vakulenko. All rights reserved.