add method
void
add(})
Add an image to the ImageComposition.
The image
will be added at the given position
on the composition.
An optional source
can be used to only add the data that is within the
source
of the image
.
An optional angle
(in radians) can be used to rotate the image when it
gets added to the composition. It will be rotated in a clock-wise
direction around the anchor
.
By default the anchor
will be the source
.width and source
.height
divided by 2
.
isAntiAlias
can be used to if the image
will be anti aliased. Defaults
to defaultAntiAlias.
The blendMode
can be used to change how the image
will be blended onto
the composition. Defaults to defaultBlendMode.
Implementation
void add(
Image image,
Vector2 position, {
Rect? source,
double angle = 0,
Vector2? anchor,
bool? isAntiAlias,
BlendMode? blendMode,
}) {
final imageRect = image.getBoundingRect();
source ??= imageRect;
anchor ??= source.toVector2() / 2;
blendMode ??= defaultBlendMode;
isAntiAlias ??= defaultAntiAlias;
assert(
imageRect.topLeft <= source.topLeft &&
imageRect.bottomRight >= source.bottomRight,
'Source rect should fit within the image',
);
_composes.add(
_Fragment(
image,
position,
source,
angle,
anchor,
blendMode,
antiAlias: isAntiAlias,
),
);
}