derpy's script loader - Render Functions

All of DSL's render functions follow some general rules. Unless otherwise noted by the function's documentation, you can assume the following concepts.


Normalized Coordinates

Rendering functions that take coordinates or sizes (width / height) expect them to be normalized. This means a position of (0, 0) defines the top left of the screen, and (1, 1) is the bottom right. Similarly, a size of 1 x 1 will be as big as the entire screen. Because of this it is important you make proper use of GetDisplayAspectRatio when you need to draw something that should appear the same size on any aspect ratio. For preserving the aspect ratio of textures, you can use the height multiplied by GetTextureDisplayAspectRatio as the width of your texture draw.


Color Ranges

Colors values are expected to be in the range of [0, 255], where an RGB value of 0, 0, 0 is pure black and 255, 255, 255 is pure white. The alpha value sometimes comes after works the same way, where 0 is fully transparent and 255 is fully opaque. If a value given is not an integer, it will be rounded down. Optional color values will always default to 255.


Text Formatting

Text formatting for the DrawText and MeasureText functions are done using multiple function calls. Before drawing (or measuring) text, you should be calling any of the text formatting functions to define how you want your text to look. If you end up deciding not to draw text after setting up the format for it, you should call DiscardText to get rid of it so it doesn't affect the next time text is drawn. You could also call PopTextFormatting to discard the current text but also return a value for later use with SetTextFormatting. For simple text draws, you can consider using DrawTextInline as a quick alternative to the normal method.


Cached Drawing

Things can only technically be drawn in a drawing thread (those with a type of DRAWING, POST_WORLD, or PRE_FADE). You are still able to use all rendering functions (unless otherwise noted by the function) at any point, which will simply cache the drawing operation to be done later. The time at which a cached draw is actually drawn is determined by the current layer, which is set using SetDrawLayer. If a measurement is meant to be returned by the function that gets cached, a measurement is still done without actually drawing anything yet.