texture9Grid method

bool texture9Grid(
  1. Pointer<SdlRenderer> renderer,
  2. Pointer<SdlTexture> texture, {
  3. Rectangle<double>? srcrect,
  4. double? width,
  5. double? leftWidth,
  6. double? rightWidth,
  7. double? height,
  8. double? topHeight,
  9. double? bottomHeight,
  10. double scale = 1.0,
  11. Rectangle<double>? dstrect,
})

Perform a scaled copy using the 9-grid algorithm to the current rendering target at subpixel precision.

The pixels in the texture are split into a 3x3 grid, using the different corner sizes for each corner, and the sides and center making up the remaining pixels. The corners are then scaled using scale and fit into the corners of the destination rectangle. The sides and center are then stretched into place to cover the remaining destination rectangle.

\param renderer the renderer which should copy parts of a texture. \param texture the source texture. \param srcrect the SDL_Rect structure representing the rectangle to be used for the 9-grid, or NULL to use the entire texture. \param left_width the width, in pixels, of the left corners in srcrect. \param right_width the width, in pixels, of the right corners in srcrect. \param top_height the height, in pixels, of the top corners in srcrect. \param bottom_height the height, in pixels, of the bottom corners in srcrect. \param scale the scale used to transform the corner of srcrect into the corner of dstrect, or 0.0f for an unscaled copy. \param dstrect a pointer to the destination rectangle, or NULL for the entire rendering target. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function should only be called on the main thread.

\since This function is available since SDL 3.2.0.

\sa SDL_RenderTexture \sa SDL_RenderTexture9GridTiled

extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect)

{@category render}

Implementation

bool texture9Grid(
  Pointer<SdlRenderer> renderer,
  Pointer<SdlTexture> texture, {
  math.Rectangle<double>? srcrect,
  double? width,
  double? leftWidth,
  double? rightWidth,
  double? height,
  double? topHeight,
  double? bottomHeight,
  double scale = 1.0,
  math.Rectangle<double>? dstrect,
}) {
  Pointer<SdlFRect> srcrectPointer = nullptr;
  Pointer<SdlFRect> dstrectPointer = nullptr;
  var rw = rightWidth;
  var lw = leftWidth;
  var th = topHeight;
  var bh = bottomHeight;
  if (srcrect != null) {
    srcrectPointer = srcrect.calloc();
  }
  if (dstrect != null) {
    dstrectPointer = dstrect.calloc();
  }
  if (width != null) {
    lw ??= width;
    rw ??= width;
  }
  if (height != null) {
    th ??= height;
    bh ??= height;
  }
  lw ??= 0.0;
  rw ??= 0.0;
  th ??= 0.0;
  bh ??= 0.0;
  final result = sdlRenderTexture9Grid(
    this,
    texture,
    srcrectPointer,
    lw,
    rw,
    th,
    bh,
    scale,
    dstrectPointer,
  );
  calloc
    ..free(srcrectPointer)
    ..free(dstrectPointer);
  return result;
}