Graphics - Simple yet powerful text and image renderer

Share the finished AutoHotkey v2 Scripts and libraries you made here. Please put the current version of AutoHotkey v2 you used in Square Brackets at the start of the topic title.
iseahound
Posts: 446
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Graphics - Simple yet powerful text and image renderer

04 Aug 2019, 14:56

Image

❧ [Download] ☙

If your script doesn't work you need to:
  • Add #Persistent to the top of your script or a hotkey.
  • Assign a := RenderText() to a variable or include a time parameter RenderText("✿", "time:8s")
Possible Applications:
  • Rendering text and images to screen
  • Converting images to other file formats (jpg, png) and other encodings (base64)
  • Verifying images are equal
Current working functions:
  • EqualImage()
  • PreprocessImage()
  • RenderImage()
  • RenderImageI() - Interactive version.
  • RenderText()
  • RenderTextI() - Interactive version.
Getting started:
  • Make a new script

    Code: Select all

    #include <Graphics>
    #Persistent
    RenderImageI("https://www.autohotkey.com/boards/styles/simplicity/theme/images/logo.png", "time:15seconds x:10vw")
    
  • (WIP) Tutorials to come!
Code is here: https://github.com/iseahound/Graphics/blob/master/lib/Graphics.ahk

I've been working on this on and off for a long time... It seems there's always new improvements and new issues to address. I'd rather push it out in an incomplete state than wait for completeness. Thanks!
As always suggestions, improvements, and importantly your example scripts are welcome. (Rainmeter widget anyone?)
Last edited by iseahound on 05 Aug 2019, 21:12, edited 1 time in total.
iseahound
Posts: 446
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Graphics - Simple yet powerful text and image renderer

04 Aug 2019, 14:59

Script for the banner + Old documentation

Code: Select all

#include <Graphics>
#Persistent

g := new Graphics.TextRenderer
g := new Graphics.INTERACTIVE(g) ; Not really needed other than for fun! :D


; Draw backing rectangles.
g.Draw(, "c:33FAB4  x:27.5vw  w:15vw h:160")
g.Draw(, "c:FBDDB5  x:42.5vw  w:15vw h:160")
g.Draw(, "c:F77563  x:57.5vw  w:15vw h:160")

; Draw Text
g.Draw("Graphics", "c:Off", "s:120pt f:(Avenir LT Pro 55 Roman) c:C1BCA6")

; Draw Outline Glow. This is a unique method, because the font color is set to "off" which makes the text transparent.
; Additionally, the outline fill method would normally be used instead of the draw text method contributing to a mismatch in the two font fills.
; In other words when the outline parameter is set, the graphics engine uses a different method to draw the text.
; In this case we use the normal method of drawing text and proceed to use the outline engine to draw the text glow. 
; If these two lines were combined the outline engine would both draw the text and draw the text glow.
g.Draw("Graphics", "c:Off", "s:120pt f:(Avenir LT Pro 55 Roman) c:Off outline:(stroke:0px color:#070707 glow:2px tint:#070707)")
g.Render()
g.Save("hi2.png")
Syntax
Tips and Tricks
List Of Methods
Thanks for the inspiration random person on the internet!
Last edited by iseahound on 04 Aug 2019, 15:20, edited 2 times in total.
iseahound
Posts: 446
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Graphics - Simple yet powerful text and image renderer

04 Aug 2019, 15:01

It's also v1 compatible if anyone is wondering.
Also, Ctrl to scale the image, Shift to stretch the image.
Helgef
Posts: 3890
Joined: 17 Jul 2016, 01:02
Contact:

Re: Graphics - Simple yet powerful text and image renderer

05 Aug 2019, 10:13

Impressive stuff, good job :clap:. Thanks for sharing.

Cheers.
User avatar
boiler
Posts: 2602
Joined: 21 Dec 2014, 02:44

Re: Graphics - Simple yet powerful text and image renderer

05 Aug 2019, 13:30

This looks very useful. I might suggest that since it is v1 compatible, you might want to also post this in the main section of Scripts and Functions since people who only use v1 will rarely if ever check out the v2 subforum, and there are potentially a lot more people there who would make use of this.
User avatar
DataLife
Posts: 321
Joined: 29 Sep 2013, 19:52

Re: Graphics - Simple yet powerful text and image renderer

08 Aug 2019, 23:26

I get Call to nonexistent function.
Specifically: GetMonitorInfo(image)
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
gregster
Posts: 2789
Joined: 30 Sep 2013, 06:48

Re: Graphics - Simple yet powerful text and image renderer

09 Aug 2019, 00:07

DataLife wrote:
08 Aug 2019, 23:26
I get Call to nonexistent function.
Specifically: GetMonitorInfo(image)
Did you include Gdip_All: https://github.com/iseahound/Graphics/blob/master/lib/Gdip_All.ahk ?
This function seems to be in there (lines 2884-2890)
User avatar
DataLife
Posts: 321
Joined: 29 Sep 2013, 19:52

Re: Graphics - Simple yet powerful text and image renderer

09 Aug 2019, 09:23

gregster wrote:
09 Aug 2019, 00:07
DataLife wrote:
08 Aug 2019, 23:26
I get Call to nonexistent function.
Specifically: GetMonitorInfo(image)
Did you include Gdip_All: https://github.com/iseahound/Graphics/blob/master/lib/Gdip_All.ahk ?
This function seems to be in there (lines 2884-2890)
Yes, I already had Gdip_all in my library folder.

I was not aware of an updated version of Gdip_all.

I would recommend any ahk script that requires #include to add a link to that required file in the opening post. This would insure that all files (and correct versions) are available to run the script.

That way I don't have to search for the latest or at least a compatible version of the #include files.
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
User avatar
joedf
Posts: 7164
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Graphics - Simple yet powerful text and image renderer

09 Aug 2019, 11:06

Neat! :+1:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500 @ 4.00 GHz, 2x8GB DDR4 2733 MHz, NVIDIA GTX 1060 6GB | [About Me] | [ASPDM - StdLib Distribution]
[Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library] | [About the AHK Foundation]

Return to “AutoHotkey v2 Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 2 guests