Fill

From ZDoom Wiki
Jump to navigation Jump to search

BaseStatusBar

void Fill(Color col, double x, double y, double w, double h, int flags = 0)

Usage

Can be used in a ZScript HUD to fill a rectangle with a specific color. Fills a rectangle directed down and to the right from the specified positon.

Parameters

  • color col
The color of the fill. Has to be provided as color(a, r, g, b) where a, r, g, b are alpha, red, green and blue color components as integers in the 0-255 range.
  • double x
Horizontal starting position.
  • double y
Vertical starting position.
  • double w
Width of the fill rectangle (directed to the right along the X axis).
  • double h
Height of the fill 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_TOP - The coordinates begin at the top center of the screen
  • DI_SCREEN_BOTTOM - The coordinates begin at the bottom center of the screen
  • DI_SCREEN_LEFT_CENTER - The coordinates begin at the center left side of the screen
  • DI_SCREEN_RIGHT_CENTER - The coordinates begin at the center right side of the screen
  • DI_SCREEN_LEFT_TOP - The coordinates begin at the top left corner of the screen
  • DI_SCREEN_RIGHT_TOP - The coordinates begin at the top right corner of the screen
  • DI_SCREEN_LEFT_BOTTOM - The coordinates begin at the bottom left corner of the screen
  • DI_SCREEN_RIGHT_BOTTOM - The coordinates begin at the bottom right corner of the screen
  • DI_SCREEN_CENTER - The coordinates begin at the center of the screen
  • DI_SCREEN_CENTER_BOTTOM - The coordinates begin at the bottom center 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.

Example

This shows how two Fill() calls can be used to draw a cross shape at the center of the screen:

double crossLength = 8;
double crossWidth = 2;
Fill(color(255, 255, 0, 0), -crossWidth * 0.5, -crossLength * 0.5, crossWidth, crossLength, DI_SCREEN_CENTER);
Fill(color(255, 255, 0, 0), -crossLength * 0.5, -crossWidth * 0.5, crossLength, crossWidth, DI_SCREEN_CENTER);