DrawImageRotated

From ZDoom Wiki
Jump to navigation Jump to search

BaseStatusBar

void DrawImageRotated(String texid, Vector2 pos, int flags, double angle, double alpha = 1, Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0)

Usage

Can be used in a HUD to draw an image and rotate it. The texid argument takes an image name.

In contrast to DrawImage and DrawTexture functions, with DrawImageRoated() the offets built into the graphic are NOT ignored by default; the image will rotate around the (0, 0) point. Thus, the image has to be offset manually if you want to rotate it along a specific point, like its center. As a result, if you want to rotate the image around its center, you will need to offset it so that its center point is at (0, 0). For example, if you have a 64x64 image that you want to rotate around its center, you will need to set its offsets in SLADE to (-32, -32).

Parameters

  • string texid
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 also taken into account.
  • 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.
  • double angle
The angle of the rotated image. Negative values go clockwise, positive go counter-clockwise.
The image's offsets, as set in SLADE, are taken into account, and the image will rotate around the (0, 0) point.
  • 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.

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.