AERMRE 1.5.1
AER modding framework for Hyper Light Drifter.
draw.h File Reference

Utilities for drawing to the screen. More...

Go to the source code of this file.

Functions

float AERDrawGetCurrentAlpha (void)
 Query the current global draw alpha. More...
 
void AERDrawSetCurrentAlpha (float alpha)
 Set the current global draw alpha. More...
 
void AERDrawSprite (int32_t spriteIdx, uint32_t frame, float x, float y, float scale, uint32_t blend)
 Draw a sprite to the screen. More...
 
void AERDrawSpriteAdv (int32_t spriteIdx, uint32_t frame, int32_t left, int32_t top, int32_t width, int32_t height, float x, float y, float scaleX, float scaleY, float angle, uint32_t blendNW, uint32_t blendNE, uint32_t blendSE, uint32_t blendSW, float alpha)
 Draw a sprite to the screen. More...
 
void AERDrawLine (float x1, float y1, float x2, float y2, uint32_t color)
 Draw a line to the screen. More...
 
void AERDrawLineAdv (float x1, float y1, float x2, float y2, float width, uint32_t color1, uint32_t color2)
 Draw a line to the screen. More...
 
void AERDrawEllipse (float left, float top, float right, float bottom, uint32_t color, bool outline)
 Draw an ellipse to the screen. More...
 
void AERDrawEllipseAdv (float left, float top, float right, float bottom, uint32_t colorCenter, uint32_t colorEdge, bool outline)
 Draw an ellipse to the screen. More...
 
void AERDrawTriangle (float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color, bool outline)
 Draw a triangle to the screen. More...
 
void AERDrawTriangleAdv (float x1, float y1, float x2, float y2, float x3, float y3, uint32_t color1, uint32_t color2, uint32_t color3, bool outline)
 Draw a triangle to the screen. More...
 
void AERDrawRectangle (float left, float top, float right, float bottom, uint32_t color, bool outline)
 Draw a rectangle to the screen. More...
 
void AERDrawRectangleAdv (float left, float top, float right, float bottom, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, bool outline)
 Draw a rectangle to the screen. More...
 
void AERDrawText (const char *text, float x, float y, uint32_t width, float scale, uint32_t color)
 Draw text to the screen. More...
 
void AERDrawTextAdv (const char *text, float x, float y, int32_t height, uint32_t width, float scaleX, float scaleY, float angle, uint32_t colorNW, uint32_t colorNE, uint32_t colorSE, uint32_t colorSW, float alpha)
 Draw text to the screen. More...
 

Detailed Description

Utilities for drawing to the screen.

The functions in this module should only be called from inside object draw event listeners. See AERObjectAttachDrawListener for more information.

Colors

Colors are represented as unsigned 32-bit integers. The least significant byte is the red component, the next byte is the green component, the second most significant byte is the blue component and the most significant byte is unused (it is not used for alpha).

This means that expressing a color in hexadecimal requires writing it in "BGR" order (i.e. the color red=0x0, green=0x70, blue=0xf0 would be written as 0xf07000).

Since
1.1.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ AERDrawEllipse()

void AERDrawEllipse ( float  left,
float  top,
float  right,
float  bottom,
uint32_t  color,
bool  outline 
)

Draw an ellipse to the screen.

Parameters
[in]leftX-intercept of the left side of ellipse.
[in]topY-intercept of the top side of ellipse.
[in]rightX-intercept of the right side of ellipse.
[in]bottomY-intercept of the bottom side of ellipse.
[in]colorColor of the ellipse. See Colors for more infomation.
[in]outlineWhether to render a solid ellipse (false) or a 1 pixel wide outline of an ellipse (true).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.3.0
See also
AERDrawEllipseAdv

◆ AERDrawEllipseAdv()

void AERDrawEllipseAdv ( float  left,
float  top,
float  right,
float  bottom,
uint32_t  colorCenter,
uint32_t  colorEdge,
bool  outline 
)

Draw an ellipse to the screen.

If more than one color is provided, then the engine will render a smooth gradient.

Parameters
[in]leftX-intercept of the left side of ellipse.
[in]topY-intercept of the top side of ellipse.
[in]rightX-intercept of the right side of ellipse.
[in]bottomY-intercept of the bottom side of ellipse.
[in]colorCenterColor of the center ellipse. See Colors for more infomation.
[in]colorEdgeColor of the edge ellipse. See Colors for more infomation.
[in]outlineWhether to render a solid ellipse (false) or a 1 pixel wide outline of an ellipse (true).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.3.0
See also
AERDrawEllipse

◆ AERDrawGetCurrentAlpha()

float AERDrawGetCurrentAlpha ( void  )

Query the current global draw alpha.

Global Alpha

This value is implicitly blended into the final result of all draw functions. For functions that take an explicit alpha value, the global alpha is still factored in.

Returns
Global alpha or -1.0f if unsuccessful.
Exceptions
AER_SEQ_BREAKif called outside action stage.
Since
1.1.0

◆ AERDrawLine()

void AERDrawLine ( float  x1,
float  y1,
float  x2,
float  y2,
uint32_t  color 
)

Draw a line to the screen.

Parameters
[in]x1Horizontal position of line start.
[in]y1Vertical position of line start.
[in]x2Horizontal position of line end.
[in]y2Vertical position of line end.
[in]colorColor of the line. See Colors for more infomation.
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.3.0
See also
AERDrawLineAdv

◆ AERDrawLineAdv()

void AERDrawLineAdv ( float  x1,
float  y1,
float  x2,
float  y2,
float  width,
uint32_t  color1,
uint32_t  color2 
)

Draw a line to the screen.

If more than one color is provided, then the engine will render a smooth gradient.

Parameters
[in]x1Horizontal position of line start.
[in]y1Vertical position of line start.
[in]x2Horizontal position of line end.
[in]y2Vertical position of line end.
[in]widthLine width in pixels.
[in]color1Color of the start of the line. See Colors for more infomation.
[in]color2Color of the end of the line. See Colors for more infomation.
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.3.0
See also
AERDrawLine

◆ AERDrawRectangle()

void AERDrawRectangle ( float  left,
float  top,
float  right,
float  bottom,
uint32_t  color,
bool  outline 
)

Draw a rectangle to the screen.

Parameters
[in]leftX-intercept of the left side of rectangle.
[in]topY-intercept of the top side of rectangle.
[in]rightX-intercept of the right side of rectangle.
[in]bottomY-intercept of the bottom side of rectangle.
[in]colorColor of the rectangle. See Colors for more infomation.
[in]outlineWhether to render a solid rectangle (false) or a 1 pixel wide outline of a rectangle (true).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.1.0
See also
AERDrawRectangleAdv

◆ AERDrawRectangleAdv()

void AERDrawRectangleAdv ( float  left,
float  top,
float  right,
float  bottom,
uint32_t  colorNW,
uint32_t  colorNE,
uint32_t  colorSE,
uint32_t  colorSW,
bool  outline 
)

Draw a rectangle to the screen.

If more than one color is provided, then the engine will render a smooth gradient.

Parameters
[in]leftX-intercept of the left side of rectangle.
[in]topY-intercept of the top side of rectangle.
[in]rightX-intercept of the right side of rectangle.
[in]bottomY-intercept of the bottom side of rectangle.
[in]colorNWColor of northwest vertex. See Colors for more infomation.
[in]colorNEColor of northeast vertex. See Colors for more infomation.
[in]colorSEColor of southeast vertex. See Colors for more infomation.
[in]colorSWColor of southwest vertex. See Colors for more infomation.
[in]outlineWhether to render a solid rectangle (false) or a 1 pixel wide outline of a rectangle (true).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.1.0
See also
AERDrawRectangle

◆ AERDrawSetCurrentAlpha()

void AERDrawSetCurrentAlpha ( float  alpha)

Set the current global draw alpha.

See Global Alpha for more information about this value.

Parameters
[in]alphaGlobal alpha.
Exceptions
AER_SEQ_BREAKif called outside action stage.
AER_BAD_VALif argument alpha is less than 0.0f or greater than 1.0f.
Since
1.1.0

◆ AERDrawSprite()

void AERDrawSprite ( int32_t  spriteIdx,
uint32_t  frame,
float  x,
float  y,
float  scale,
uint32_t  blend 
)

Draw a sprite to the screen.

Parameters
[in]spriteIdxSprite to draw.
[in]frameFrame of sprite to draw.
[in]xHorizontal position at which to draw sprite.
[in]yVertical position at which to draw sprite.
[in]scaleHorizontal and vertical scale of text.
[in]blendColor to blend with sprite. See Colors for more infomation.
Exceptions
AER_SEQ_BREAKif called outside draw stage.
AER_FAILED_LOOKUPif argument spriteIdx is an invalid sprite.
AER_BAD_VALif argument frame is greater than or equal to the number of frames in sprite.
Since
1.4.0
See also
AERDrawSpriteAdv

◆ AERDrawSpriteAdv()

void AERDrawSpriteAdv ( int32_t  spriteIdx,
uint32_t  frame,
int32_t  left,
int32_t  top,
int32_t  width,
int32_t  height,
float  x,
float  y,
float  scaleX,
float  scaleY,
float  angle,
uint32_t  blendNW,
uint32_t  blendNE,
uint32_t  blendSE,
uint32_t  blendSW,
float  alpha 
)

Draw a sprite to the screen.

If more than one blend color is provided, then the engine will render a smooth gradient.

Parameters
[in]spriteIdxSprite to draw.
[in]frameFrame of sprite to draw.
[in]leftHorizontal offset into sprite to draw in pixels.
[in]topVertical offset into sprite to draw in pixels.
[in]widthHorizontal component of sprite to draw in pixels.
[in]heightVertical component of sprite to draw in pixels.
[in]xHorizontal position at which to draw sprite.
[in]yVertical position at which to draw sprite.
[in]scaleXHorizontal scale of sprite.
[in]scaleYVertical scale of sprite.
[in]angleSprite offset angle in degrees.
[in]blendNWBlend color of northwest corner. See Colors for more infomation.
[in]blendNEBlend color of northeast corner. See Colors for more infomation.
[in]blendSEBlend color of southeast corner. See Colors for more infomation.
[in]blendSWBlend color of southwest corner. See Colors for more infomation.
[in]alphaSprite alpha (transparency).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
AER_FAILED_LOOKUPif argument spriteIdx is an invalid sprite.
AER_BAD_VALif argument alpha is less than 0.0f or greater than 1.0f or if argument frame is greater than or equal to the number of frames in sprite.
Since
1.4.0
See also
AERDrawSprite

◆ AERDrawText()

void AERDrawText ( const char *  text,
float  x,
float  y,
uint32_t  width,
float  scale,
uint32_t  color 
)

Draw text to the screen.

See Text Escape Sequences for more information about text escape sequences.

Parameters
[in]textString to draw. Maximum size is 8192 characters including null terminator (will not cause error if larger).
[in]xHorizontal position at which to draw text.
[in]yVertical position at which to draw text.
[in]widthMaximum line width before line break in pixels (not characters).
[in]scaleHorizontal and vertical scale of text.
[in]colorColor of text. See Colors for more infomation.
Exceptions
AER_SEQ_BREAKif called outside draw stage.
AER_NULL_ARGif argument text is NULL.
Since
1.1.0
See also
AERDrawTextAdv

◆ AERDrawTextAdv()

void AERDrawTextAdv ( const char *  text,
float  x,
float  y,
int32_t  height,
uint32_t  width,
float  scaleX,
float  scaleY,
float  angle,
uint32_t  colorNW,
uint32_t  colorNE,
uint32_t  colorSE,
uint32_t  colorSW,
float  alpha 
)

Draw text to the screen.

If more than one color is provided, then the engine will render a smooth gradient.

Text Escape Sequences

The game maker engine chose to use the hashtag ('#') character to represent linebreaks. To display a literal hashtag, preceed it with a backslash.

Parameters
[in]textString to draw. Maximum size is 8192 characters including null terminator (will not cause error if larger).
[in]xHorizontal position at which to draw text.
[in]yVertical position at which to draw text.
[in]heightSpace between each line of text in pixels.
[in]widthMaximum line width before line break in pixels (not characters).
[in]scaleXHorizontal scale of text.
[in]scaleYVertical scale of text.
[in]angleText offset angle in degrees.
[in]colorNWColor of northwest corner. See Colors for more infomation.
[in]colorNEColor of northeast corner. See Colors for more infomation.
[in]colorSEColor of southeast corner. See Colors for more infomation.
[in]colorSWColor of southwest corner. See Colors for more infomation.
[in]alphaText alpha (transparency).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
AER_NULL_ARGif argument text is NULL.
AER_BAD_VALif argument alpha is less than 0.0f or greater than 1.0f.
Since
1.1.0
See also
AERDrawText

◆ AERDrawTriangle()

void AERDrawTriangle ( float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
uint32_t  color,
bool  outline 
)

Draw a triangle to the screen.

Parameters
[in]x1Horizontal position of first vertex.
[in]y1Vertical position of first vertex.
[in]x2Horizontal position of second vertex.
[in]y2Vertical position of second vertex.
[in]x3Horizontal position of third vertex.
[in]y3Vertical position of third vertex.
[in]colorColor of the triangle. See Colors for more infomation.
[in]outlineWhether to render a solid triangle (false) or a 1 pixel wide outline of a triangle (true).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.1.0
See also
AERDrawTriangleAdv

◆ AERDrawTriangleAdv()

void AERDrawTriangleAdv ( float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
uint32_t  color1,
uint32_t  color2,
uint32_t  color3,
bool  outline 
)

Draw a triangle to the screen.

If more than one color is provided, then the engine will render a smooth gradient.

Parameters
[in]x1Horizontal position of first vertex.
[in]y1Vertical position of first vertex.
[in]x2Horizontal position of second vertex.
[in]y2Vertical position of second vertex.
[in]x3Horizontal position of third vertex.
[in]y3Vertical position of third vertex.
[in]color1Color of first vertex. See Colors for more infomation.
[in]color2Color of second vertex. See Colors for more infomation.
[in]color3Color of third vertex. See Colors for more infomation.
[in]outlineWhether to render a solid triangle (false) or a 1 pixel wide outline of a triangle (true).
Exceptions
AER_SEQ_BREAKif called outside draw stage.
Since
1.1.0
See also
AERDrawTriangle