setClipRect method

bool setClipRect([
  1. Rectangle<double>? rect
])

Set the clipping rectangle for a surface.

When surface is the destination of a blit, only the area within the clip rectangle is drawn into.

Note that blits are automatically clipped to the edges of the source and destination surfaces.

\param surface the SDL_Surface structure to be clipped. \param rect the SDL_Rect structure representing the clipping rectangle, or NULL to disable clipping. \returns true if the rectangle intersects the surface, otherwise false and blits will be completely clipped.

\since This function is available since SDL 3.1.3.

\sa SDL_GetSurfaceClipRect

extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect)

Implementation

bool setClipRect([math.Rectangle<double>? rect]) {
  Pointer<SdlRect> rectPointer = nullptr;
  if (rect != null) {
    rectPointer = rect.callocInt();
  }
  var result = sdlSetSurfaceClipRect(this, rectPointer);
  calloc.free(rectPointer);
  return result;
}