SetClipRect (BaseStatusBar)
Note: This function is for the BaseStatusBar class. For the Screen function of the same name, see SetClipRect. |
void SetClipRect(double x, double y, double w, double h, int flags = 0)
Usage
Can be used in a ZScript HUD to create a clipping rectangle. Clipping rectangles prevent anything outside of the specified bounding box from being drawn. This can be used to clip the edges of graphics if they leave a specific area. Note that this will only clip things that are drawn on the screen after the clipping rectangle is specified. Anything drawn before it's set, even if they lie outside of the rectangle, will not be clipped.
Everything drawn on the screen after calling this function will be clipped, until the clipping rectangle is cleared with ClearClipRect().
Parameters
- double x
- Horizontal starting position.
- double y
- Vertical starting position.
- double w
- Width of the clipping rectangle (directed to the right along the X axis).
- double h
- Height of the clipping rectangle (directed downward along the Y axis).
- int flags
- The DI_SCREEN* flags will change the origin point of the coordinates where the element is drawn (essentially, moving where the (0, 0) point is located.
- DI_SCREEN_LEFT_TOP - The coordinates begin at the top left corner of the screen
- DI_SCREEN_CENTER_TOP - The coordinates begin at the top center of the screen
- DI_SCREEN_RIGHT_TOP - The coordinates begin at the top right corner of the screen
- DI_SCREEN_LEFT_CENTER - The coordinates begin at the center left side of the screen
- DI_SCREEN_CENTER - The coordinates begin at the center of the screen
- DI_SCREEN_RIGHT_CENTER - The coordinates begin at the center right side of the screen
- DI_SCREEN_LEFT_BOTTOM - The coordinates begin at the bottom left corner of the screen
- DI_SCREEN_CENTER_BOTTOM - The coordinates begin at the bottom center of the screen
- DI_SCREEN_RIGHT_BOTTOM - The coordinates begin at the bottom right corner of the screen
- Note, these flags do not change the orientation of coordinates. Regardless of where the element is drawn, positive X moves it to the right, positive Y moves it down.
- More flags are defined in the StatusBarCore class, but they're mostly aliases of the above ones.
- DI_ITEM* flags have no effect on this function. The clipping rectangle is always anchored at its top left corner.
Example
This will drawn the FIREBLU1 texture at the center of the screen, but its lower half will be clipped:
TextureID tex = TexMan.CheckForTexture("FIREBLU1");
vector2 size = TexMan.GetScaledSize(tex);
vector2 pos = (size.x * -0.5, size.y * -0.5);
SetClipRect(pos.x, pos.y, size.x, size.y*0.5, DI_SCREEN_CENTER);
DrawTexture(tex, pos, DI_SCREEN_CENTER|DI_ITEM_LEFT_TOP);
ClearClipRect();
Note, this has to be called in Draw()
after BeginHUD()
.