Function
Given a string it will generate a bitmap of the characters drawn with a given angle between each char, if the angle is 0 it will try to make the string fill the entire circle.
Code: Select all
CircularText(Angle, Str, Width, Height, Font, Options){
pBitmap := Gdip_CreateBitmap(Width, Height)
G := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(G, 4)
if(!Angle) {
Angle := 360 / StrLen(Str)
}
for i, chr in StrSplit(Str) {
RotateAroundCenter(G, Angle, Width, Height)
Gdip_TextToGraphics(G, chr, Options, Font, Width, Height)
}
Gdip_DeleteGraphics(G)
Return pBitmap
}
RotateAroundCenter(G, Angle, Width, Height) {
Gdip_TranslateWorldTransform(G, Width / 2, Height / 2)
Gdip_RotateWorldTransform(G, Angle)
Gdip_TranslateWorldTransform(G, - Width / 2, - Height / 2)
}
Code: Select all
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
; Uncomment if Gdip.ahk is not in your standard library
;#Include, Gdip.ahk
Width := 600, Height := 600
Angle := 0
Font := "Arial"
Options := "x" Width / 2 " y5p w10 Centre cbbffffff r4 s30"
Str := "I thought what I'd do was, I'd pretend I was one of those deaf-mutes. "
Init()
;Gdip_FillEllipse(G, pBrush, 0, 0, Width, Height)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20)
UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height)
pText := CircularText(Angle, Str, Width, Height, Font, Options)
loop {
Angle -= 0.2
Gdip_GraphicsClear(G)
;Gdip_FillEllipse(G, pBrush, 0, 0, Width, Height)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20)
RotateAroundCenter(G, Angle, Width, Height)
Gdip_DrawImage(G, pText)
UpdateLayeredWindow(hwnd1, hdc)
Gdip_ResetWorldTransform(G)
;Sleep, 25
}
Return
CircularText(Angle, Str, Width, Height, Font, Options){
pBitmap := Gdip_CreateBitmap(Width, Height)
G := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(G, 4)
if(!Angle) {
Angle := 360 / StrLen(Str)
}
for i, chr in StrSplit(Str) {
Gdip_TextToGraphics(G, chr, Options, Font, Width, Height)
RotateAroundCenter(G, Angle, Width, Height)
}
Gdip_DeleteGraphics(G)
Return pBitmap
}
RotateAroundCenter(G, Angle, Width, Height) {
Gdip_TranslateWorldTransform(G, Width / 2, Height / 2)
Gdip_RotateWorldTransform(G, Angle)
Gdip_TranslateWorldTransform(G, - Width / 2, - Height / 2)
}
Init() {
Global
; Start gdi+
if(!pToken := Gdip_Startup()) {
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
Gui, 1: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop
Gui, 1: Show, NA
hwnd1 := WinExist()
hbm := CreateDIBSection(Width, Height)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid(0xaa000000)
OnMessage(0x201, "WM_LBUTTONDOWN")
}
WM_LBUTTONDOWN() {
PostMessage, 0xA1, 2
}
Exit:
; Select the object back into the hdc
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
Gdip_DisposeImage(pText)
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
ExitApp
Return