Skip to content

Tips & Tricks

Edison Hua edited this page Apr 25, 2021 · 37 revisions

Helpful Tips

  • You can call tr := TextRender(text, backgroundstyles, textstyles) by itself. Use this one-line format to save time and space!
  • You can call tr.Draw(text) multiple times, then call tr.Render() with blank parameters to render all those draws on screen.
  • If you need to display text on screen temporarily, take advantage of the time syntax: TextRender("Au revoir", "time:3000") — this will display "Au revoir" for 3 seconds!
  • If you are memory-conscious, be sure to call FreeMemory() immediately after to reduce memory usage by over 60%.

Styling Text

  • Speed up text rendering by setting the text quality to 0. This will disable anti-aliasing. Create a cool stencil effect with quality:0 color:None outline:(stroke:1px color:Black)!
  • Avoid using the glow parameter in outline. It's very slow and will delay your render time. If you must use it, choose an number less than 5px. Anything more will slow down your script exponentially.
  • To increase the size of the text without increasing the font size, set the outline width to 1, and the outline color to your text color. Not only will this increase readability, but it will also decrease space between letters, saving you on-screen real estate! Example: outline:(stroke:1px)
  • Create a interesting effect by making the text "eat" through the background. Use color:Delete or color:Erase as the text color.
  • If the text color is omitted, it defaults to white or black depending on the background color!
  • The text position can be independent of the background. Use x and y to position your text off the background box.

Styling Background

  • If you want to set the background to be transparent, you can use c:None, c:Off, c:Clear, or c:Transparent. Don't use w:0 or h:0. Even though they work - they act weird changing your x and y positions.
  • A random color can help keep your background boxes fresh. Try color:Random2 for a random solid color.

Methods and Properties

  • To avoid rendering to the screen, use Flush() instead. This does the same thing as Render() without modifying the screen.
  • You must clean up any pointers returned by CopyToBitmap() and RenderToBitmap() with DllCall("gdiplus\GdipDisposeImage", "ptr", pBitmap). Likewise for CopyToHBitmap() and RenderToHBitmap(), DllCall("DeleteObject", "ptr", hbm) must be called.
  • Save() must be called after Render(). Otherwise subsequent drawing operations will affect what is being saved.
  • Use tr.GUID to check if the internal graphics has been changed. Use tr.Hash() to check if two states are identical.

Advanced Tricks

  • Grab the unique window id by calling tr.hwnd
  • Use the toggles .AlwaysOnTop(), .ClickThrough() and .ToggleVisible() to change properties of the window.
  • If you want to activate the window send .Show(1). By default .Show() will not activate the window.
  • If you want to name the window title, use the new constructor. a := new TextRender."Window Title")
  • Chaining properties is very useful. TextRender.Render("hi!", "color:Pink", "color:White").AlwaysOnTop().FreeMemory() will make a window that is not always on top, and cannot be edited since its Bitmap memory has been cleared.
Clone this wiki locally