clip property

  1. @override
PRectangle? get clip
override

Returns the current drawing clip.

Implementation

@override
PRectangle? get clip => _clip;
  1. @override
set clip (PRectangle? clip)
override

Sets the drawing clip.

  • Note that the clip won't be merged with the previouse clip (the clip coordinates are always global).
  • See subClip.

Implementation

@override
set clip(PRectangle? clip) {
  if (clip == null) {
    if (_clip != null) {
      final widthD = canvasXD(width);
      final heightD = canvasYD(height);

      final rect = Rect.fromLTWH(0, 0, widthD, heightD);

      _setClipGlobal(rect);
      _clip = null;
    }
  } else {
    if (_clip != clip) {
      final xd = canvasXD(clip.x);
      final yd = canvasYD(clip.y);

      final widthD = canvasXD(clip.width);
      final heightD = canvasYD(clip.height);

      final rect = Rect.fromLTWH(xd, yd, widthD, heightD);

      _setClipGlobal(rect);
      _clip = clip;
    }
  }
}