clip method Null safety

RenderTextureQuad clip(
  1. Rectangle<num> rectangle
)

Clips a RenderTextureQuad from this RenderTextureQuad. The offset of the RenderTextureQuad will be adjusted to match the origin of this RenderTextureQuad.

The rectangle is in target coordinates. Those coordinates take the pixelRatio into account. Please read more about HiDpi textures to learn more about this topic.

Implementation

RenderTextureQuad clip(Rectangle<num> rectangle) {
  final rL = (rectangle.left * pixelRatio).round();
  final rT = (rectangle.top * pixelRatio).round();
  final rR = (rectangle.right * pixelRatio).round();
  final rB = (rectangle.bottom * pixelRatio).round();
  final ow = this.offsetRectangle.width;
  final oh = this.offsetRectangle.height;
  final sourceRectangle = Rectangle<int>(rL, rT, rR - rL, rB - rT);
  final offsetRectangle = Rectangle<int>(0 - rL, 0 - rT, ow, oh);
  return RenderTextureQuad.slice(this, sourceRectangle, offsetRectangle);
}