Layer.affineCopy

Function/Meaning
Affine transformation copy
Type
Method of Layer class
Syntax
affineCopy(src, sleft, stop, swidth, sheight, affine, A, B, C, D, E, F, type=stNearest, clear=false)
Arguments
src Specifies the source layer object.
A Bitmap class object can also be specified. (Since 1.1.0)
sleft Specifies the left position of the rectangle to copy (in the source layer's image coordinates) in pixels.
stop Specifies the top position of the rectangle to copy (in the source layer's image coordinates) in pixels.
swidth Specifies the width of the rectangle to copy (in the source layer's image coordinates) in pixels.
sheight Specifies the height of the rectangle to copy (in the source layer's image coordinates) in pixels.
affine Specifies how to handle the following six arguments (parameters A to F).
If true is specified, the six parameters are interpreted as follows:
A : a of the 2D affine transformation matrix
B : b of the 2D affine transformation matrix
C : c of the 2D affine transformation matrix
D : d of the 2D affine transformation matrix
E : tx of the 2D affine transformation matrix
F : ty of the 2D affine transformation matrix

By affine transformation, the source image position (x, y) (where the top-left corner of the source rectangle is (0, 0)) is converted to the destination image position (x', y') by the following formula:
x' = a*x + c*y + tx
y' = b*x + d*y + ty

If false is specified, the six parameters are interpreted as follows. These parameters also accept real numbers.
A : The X-coordinate position (x0) in the destination image of the top-left corner of the source rectangle.
B : The Y-coordinate position (y0) in the destination image of the top-left corner of the source rectangle.
C : The X-coordinate position (x1) in the destination image of the top-right corner of the source rectangle.
D : The Y-coordinate position (y1) in the destination image of the top-right corner of the source rectangle.
E : The X-coordinate position (x2) in the destination image of the bottom-left corner of the source rectangle.
F : The Y-coordinate position (y2) in the destination image of the bottom-left corner of the source rectangle.

If false is specified, the destination position (x3, y3) corresponding to the bottom-right corner of the source is automatically calculated by the following formula:
x3 = x1 - x0 + x2
y3 = y1 - y0 + y2
A Parameter A. Interpretation changes depending on the affine argument.
B Parameter B. Interpretation changes depending on the affine argument.
C Parameter C. Interpretation changes depending on the affine argument.
D Parameter D. Interpretation changes depending on the affine argument.
E Parameter E. Interpretation changes depending on the affine argument.
F Parameter F. Interpretation changes depending on the affine argument.
type Specifies the type of affine transformation.
stNearest : Nearest neighbor method is used
stFastLinear : Low-precision linear interpolation is used (partially implemented)
stLinear : Linear interpolation is used (not implemented)
stCubic : Cubic interpolation is used (not implemented)
For stFastLinear, stLinear, and stCubic, stRefNoClip can be added using a bitwise OR. In this case, referencing outside the bitmap area to synthesize colors is permitted. If this is not specified, even if there is space around the source bitmap, it will not reference outside the source bitmap range (colors outside the range are considered the same as the nearest pixel within the range).
clear Specifies whether to clear the area around the affine-transformed image in the destination layer with the color and opacity indicated by the Layer.neutralColor property. If true is specified, it is cleared; if this argument is omitted or false is passed, it is not cleared.
The area to be cleared can also be restricted with the Layer.setClip method.
Using this clear function avoids redundant clearing of the area to be overwritten (the part overwritten by the affine transformation in the cleared area) when clearing the destination layer before transferring the image with affine transformation.
Return Value
None (void)
Description
Copies the specified rectangle of the source layer to the destination (the layer executing the method) while performing an affine transformation.
Depending on the affine argument, you can choose to specify a 2D affine transformation matrix as the transformation parameter or directly specify the points after transformation.
In the current version, linear interpolation with stFastLinear is effective when the Layer.face property of the destination layer (the layer executing the method) is dfAlpha (or dfBoth) or dfAddAlpha. Linear interpolation is also possible when the Layer.face property is dfOpaque and the Layer.holdAlpha property is false.
If the Layer.face property of the destination layer (the layer executing the method) is dfAlpha (or dfBoth) or dfAddAlpha, both the main image and the mask image are copied.
If the Layer.face property of the destination layer (the layer executing the method) is dfOpaque (or dfMain), only the main image is copied when the Layer.holdAlpha property is true, and both the main image and the mask image are copied when it is false.

Transformation by a 2D affine transformation matrix is defined as follows, with the top-left of the source rectangle as the origin (0, 0):