SDL_Rect

A structure that contains the definition of a rectangle, with the origin at the upper left.该结构定义一个从左上角起始的矩形。

Data Fields 数据字段

intxthe x location of the rectangle’s upper left corner矩形左上角的x坐标
intythe y location of the rectangle’s upper left corner矩形左上角的y坐标
intwthe width of the rectangle矩形的宽
inththe height of the rectangle矩形的高

Code Examples 示例代码

  1. SDL_Rect srcrect;
  2. SDL_Rect dstrect;
  3. srcrect.x = 0;
  4. srcrect.y = 0;
  5. srcrect.w = 32;
  6. srcrect.h = 32;
  7. dstrect.x = 640/2;
  8. dstrect.y = 480/2;
  9. dstrect.w = 32;
  10. dstrect.h = 32;
  11. SDL_BlitSurface(src, &srcrect, dst, &dstrect);

Remarks 注意

An SDL_Rect defines a rectangular area of the screen. It is used by SDL_BlitSurface() to define blitting regions and by several other video functions.SDL_Rect结构在屏幕上定义一个矩形的区域。在SDL_BlitSurface()函数中被用来设置绘制的区域,同时也被很多其他的视频函数所使用。

Related Functions 相关函数

SDL_BlitSurface
SDL_EnclosePoints
SDL_GetDisplayBounds
SDL_HasIntersection
SDL_IntersectRect
SDL_LockTexture
SDL_RenderCopy
SDL_RenderDrawRect
SDL_RenderDrawRects
SDL_RenderReadPixels
SDL_UnionRect
SDL_UpdateTexture


Translated by SteDeshain Reference to http://wiki.libsdl.org/SDL_Rect