Layer.affineCopy

機能/意味
Affine transformation copy
タイプ
Layerクラスのメソッド
構文
affineCopy(src, sleft, stop, swidth, sheight, affine, A, B, C, D, E, F, type=stNearest, clear=false)
引数
src  Specify the copy source layer object.
 Bitmap class objects can also be specified. (1.1.0 or later)
sleft  Specifies the left edge of the rectangle to be copied in pixels (at the image position of the source layer).
stop  Specifies the top edge of the rectangle to be copied in pixels (at the image position of the source layer).
swidth  Specifies the width of the rectangle to be copied in pixels (at the image position of the source layer).
sheight  Specifies the height of the rectangle to be copied in pixels (at the image position of the source layer).
affine  Specify how to handle the following six arguments (A to F parameters).
 If you specify true, each of the six parameters is 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 the affine transformation, the image position (x, y) of the copy source (where the upper left corner of the copy source rectangle is (0, 0)) is calculated by the following equation using the image position (x', y') of the copy destination.
x' = a*x + c*y + tx
y' = b*x + d*y + ty

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

 If false is specified, the copy destination position (x3, y3) corresponding to the lower right corner of the copy source is automatically calculated by the following formula.
x3 = x1 - x0 + x2
y3 = y1 - y0 + y2
A  A parameter. The interpretation depends on the affine argument.
B  B parameter. The interpretation depends on the affine argument.
C  C parameter. The interpretation depends on the affine argument.
D  D parameter. The interpretation depends on the affine argument.
E  The E parameter. The interpretation depends on the affine argument.
F  The F parameter. The interpretation depends 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 : 3D interpolation is used (not implemented)
 For stFastLinear, stLinear, and stCubic, stRefNoClip can be additionally specified by bitwise OR, and in this case, it is allowed to refer to outside the area of the bitmap to be copied and combine colors. If this is not specified, there will be no reference outside the range of the source bitmap, even if there is room around the source bitmap. Is considered a color).
clear  Specifies whether to clear around the affine-transformed image of the destination layer with the color and transparency indicated by the Layer.neutralColor property. If you specify true, it will be cleared. If you omit this argument or pass false, it will not be cleared.
 The area to be cleared can be limited by the Layer.setClip method.
 When this clear function is used, when the transfer destination layer is cleared and the image is overwritten and transferred by affine transformation, the area to be overwritten (the part overwritten by affine transformation in the cleared place) is wasted. Can be omitted.
戻り値
なし (void)
説明
 Copies the rectangle of the specified copy source layer to the copy destination (layer where the method is executed) while performing affine transformation.
 With the affine argument, you can choose whether to specify a two-dimensional affine transformation matrix as the deformation parameter or directly specify the transformed point.
 In the current version, linear interpolation is effective when stFastLinear is specified when the Layer.face property of the layer to be overlaid (executing the method) is dfAlpha (or dfBoth) or dfAddAlpha. Also, when the Layer.face property is dfOpaque and the Layer.holdAlpha property is false, linear interpolation is possible.
 If the Layer.face property of the destination layer (executing the method) is dfAlpha (or dfBoth) or dfAddAlpha, both the main and mask images are copied.
 If the Layer.face property of the layer to be superimposed (executing the method) is dfOpaque (or dfMain), only the main image is copied when the Layer.holdAlpha property is true, and when the Layer.holdAlpha property is false, the main image and mask image are copied. Both are copied.

 The transformation using the 2D affine transformation matrix is defined as follows, with the origin (0, 0) at the upper left corner of the source rectangle.

 By performing a two-dimensional affine transformation, you can scale, rotate, shear (tilt), translate, flip, or any combination of these.
 In the method that performs 2D affine transformation, you can specify the transformation by directly specifying each transformed vertex instead of the 2D affine matrix, but even in this case, perform transformation that can not be defined by 2D affine transformation You can not.

 For affine transformations, pixels are assumed to have a size of 1.0 x 1.0. That is, the pixel at (0, 0) is considered to be in the range (-0.5, -0.5)-(0.5, 0.5).