DrawImage (BaseStatusBar)

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


BaseStatusBar

void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1)

Usage

Can be used in a ZScript HUD to draw an image. The texture argument takes an image name.

Parameters

  • string texture
The name of the image. Any type of graphic can be used here (sprites, textures, graphics, ANIMDEFS definitions, TEXTURES definitions, etc.). The name must be provided in double quotation marks.
If the filename of the image is over 8 characters, a full path (with subfolders and the file extension) must be provided, for example "graphics/hud/helmet_outline.png"
The image is anchored at its top left corner by default (this can be changed with flags). The built-in offsets of the image are ignored, unless the DI_ITEM_OFFSETS flag is passed.
  • vector2 pos
The position of the element on the screen relative to the HUD's virtual resolution. Positive X moves it to the right, positive Y moves it down. By default, like with all other BaseStatusBar elements, (0, 0) equals to top left corner of the HUD area.
If you're making a fullscreen HUD, unless it's forcescaled (the forcescaled argument of the BeginHUD call is set to true), pos should never be used globally. Instead, DI_SCREEN* and DI_ITEM* flags (see below) should be used to move the anchor point of the image and the origin point of the coordinates, so that it's drawn relative to screen corners and/or sides. This is the only way to make sure that the image doesn't end up being misplaced at different screen resolutions and aspect ratios.
  • 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.
The DI_ITEM* flags determine the anchor point of the HUD element, i.e. how it is placed relative to the specified position. By default elements are drawn from their top left corner. The following flags determine the anchor point:
  • DI_ITEM_TOP - top. Combine with DI_ITEM_CENTER to anchor at the top center.
  • DI_ITEM_BOTTOM - bottom. Combine with DI_ITEM_CENTER to anchor at the bottom center.
  • DI_ITEM_LEFT - left side. Combine with DI_ITEM_CENTER to anchor at the center of the left side.
  • DI_ITEM_RIGHT - right side. Combine with DI_ITEM_CENTER to anchor at the center of the right side.
  • DI_ITEM_LEFT_TOP - top left corner (same as DI_ITEM_TOP|DI_ITEM_LEFT)
  • DI_ITEM_RIGHT_TOP - top right corner (same as DI_ITEM_TOP|DI_ITEM_RIGHT)
  • DI_ITEM_LEFT_BOTTOM - bottom left corner (same as DI_ITEM_BOTTOM|DI_ITEM_LEFT)
  • DI_ITEM_RIGHT_BOTTOM - bottom right corner (same as DI_ITEM_BOTTOM|DI_ITEM_RIGHT)
  • DI_ITEM_CENTER - center point
  • DI_ITEM_OFFSETS - The element's built-in offsets (as set in SLADE) are taken into account.
Note, these flags do not change the orientation of coordinates. Regardless of the element's anchor point, 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.
  • double alpha
Determines the translucency of the image in the 0.0-1.0 range.
  • vector2 box
Determines the size of the box the image will be drawn in. If the size is smaller than the image, the image will be scaled to the size. The default value of (-1, -1) doesn't apply any box.
  • vector2 scale
Determines the scale of the image.
  • ERenderStyle style
The renderstyle of the image. Uses the same values as the RenderStyle property. The default value is STYLE_Translucent.
  • color col
Allows tinting the image to a specific color. The default value is FFFFFF (white), which applies no tint. The darker the color, the more visible the tint will be.
  • int translation
Allows applying a translation to the image. The translation can be picked from an actor pointer with <actorpointer>.translation, or with Translation.GetID('MyTranslationName') where 'MyTranslationName' is a definition from the TRNSLATE lump.
  • double clipwidth
Allows specifying a distance in pixels beyond which the image will be clipped horizontally. (Verification needed)

Example

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.