$setTo method
void
$setTo(})
(Internal usage)
Updates the sub-texture to use a new parent texture and region.
This method can be used to update the sub-texture dynamically, for example to use a different frame from the parent texture.
Implementation
void $setTo(GTexture parent,
{GRect? region,
bool ownsParent = false,
GRect? frame,
required bool rotated,
double scaleModifier = 1}) {
_region ??= GRect();
if (region != null) {
_region!.copyFrom(region);
} else {
/// used (parent.width)
_region!.setTo(0, 0, parent.nativeWidth, parent.nativeHeight);
}
if (frame != null) {
if (this.frame != null) {
this.frame!.copyFrom(frame);
} else {
this.frame = frame.clone();
}
} else {
this.frame = null;
}
_parent = parent;
_ownsParent = ownsParent;
_rotated = rotated;
_w = (rotated ? _region!.height : _region!.width) / scaleModifier;
_h = (rotated ? _region!.width : _region!.height) / scaleModifier;
_scale = parent.scale! * scaleModifier;
_sourceRegion = _region!.clone() * scale!;
/// cache.
_sourceRegionRect = _sourceRegion.toNative();
/// used width, height
_destRect = ui.Rect.fromLTWH(0, 0, nativeWidth, nativeHeight);
sourceRect = GRect(0, 0, nativeWidth, nativeHeight);
// updateMatrices();
}