-
Notifications
You must be signed in to change notification settings - Fork 11
Tips & Tricks
Edison Hua edited this page May 18, 2021
·
37 revisions
- You can call
tr := TextRender(text, backgroundstyles, textstyles)
by itself. Use this one-line format to save time and space! - You can use object notation
TextRender("Alert!", {time:3000, color:"Blue"})
instead of string notationTextRender("Alert!", "time:3000 color:Blue")
. - To draw multiple layers, call
tr.Draw(text)
multiple times, then calltr.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! Note that this can be used without assigning the expression to a variable! - If you are memory-conscious, be sure to call
FreeMemory()
immediately after to reduce memory usage by over 60%. - Tired of objects being clipped by the edges of the screen? Try
RenderOnScreen()
instead. - Place
SetBatchLines -1
at the top of your script for a 2x speedup.
- Setting the quality of the text to ClearType will improve the overall look of the text on mostly opaque backgrounds. By default, ClearType is only enabled when the background color is completely opaque. Example:
q:5
- Increase the readability without increasing font size, by setting the outline stroke to 1. This creates a pseudo-bold effect. For small font sizes, it will decrease the space between letters, saving you on-screen real estate! Example:
outline:(stroke:1px)
oro:(1px)
- Use an alternative rendering process by setting the outline stroke to 0 pixels. Whether this is an improvement depends on the font and font size used. Example:
outline:(stroke:0px)
oro:(0px)
- 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.
- Create a interesting effect by making the text "eat" through the background. Use
color:Delete
orcolor: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.
- If you want to set the background to be transparent, you can use
c:None
,c:Off
,c:Clear
, orc:Transparent
. Don't usew:0
orh: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.
- Although text cannot be rendered off screen with
Render()
, the whole picture can be recovered withSave()
,RenderToBitmap()
, andRenderToHBitmap()
. -
RenderOnScreen()
will render the entire canvas. Although it preforms slower thanRender()
, it is optimized to fall back toRender()
when the entire object is in the visible screen area. It's the best of both worlds! - Using
RenderOnScreen()
may cause objects to be mispositioned. That's whyRender()
is the default. - Save() must be called after Render(), or subsequent drawing operations will have cleared what is being saved.
- The window handle can be retrieved with
tr.hwnd
. -
tr.x
,tr.y
, may be inaccurate when it comes to off screen coordinates. To retrieve the exact coordinates tryWindowLeft
,WindowTop
,WindowRight
,WindowBottom
,WindowWidth
, andWindowHeight
. If the user has moved the window you will have to use WinGetPos instead. - To avoid rendering to the screen, use
Flush()
instead. This does the same thing asRender()
without modifying the screen. - You must clean up any pointers returned by
CopyToBitmap()
andRenderToBitmap()
withDllCall("gdiplus\GdipDisposeImage", "ptr", pBitmap)
. Likewise forCopyToHBitmap()
andRenderToHBitmap()
,DllCall("DeleteObject", "ptr", hbm)
must be called. - Use
tr.GUID
to check if the internal graphics has been changed and usetr.Hash()
to check if two internal graphics states are identical.
- Methods can be chained, as in
tr.Draw(text1).Draw(text2).Render()