.
Code: Select all
;****************************************************************************************************************************************************************************
#Include <My Altered GDIP lib> ;<<<-------------- gdip.ahk
#Include <PopUpWindow_V2> ; In a prv post in this thread.
#Include <ArrowHead_2> ; In a prv post in this thread.
;****************************************************************************************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
global gdiplus := LoadLibrary("gdiplus")
Gdip_Startup()
Gui1 := New PopUpWindow( { AutoShow: 1 , X: 1100 , Y: 220 , W: 410 , H: 310 , Options: " -DPIScale +AlwaysOnTop " } )
Gui1.Controls := {}
Gui1.Controls.Head := { X: 340 , Y: 80 , W: 50 , H: 30 , Value: 25 }
Gui1.Controls.Neck := { X: 340 , Y: 140 , W: 50 , H: 30 , Value: 7 }
Gui1.Controls.Arm := { X: 340 , Y: 200 , W: 50 , H: 30 , Value: 15 }
Gui1.Controls.Elbow := { X: 340 , Y: 260 , W: 50 , H: 30 , Value: 5 }
Gui1.Controls.Arrow := { X: 15 , Y: 75 , W: 310 , H: 220 , BGColor: "0xaa004444" , ArrowColor: "0xFF22262a" , ArrowBorderColor: "0xFF62666a" }
Gui1.Controls.Move := { X: 15 , Y: 15 , W: 340 , H: 60 }
Gui1.Controls.Close := { X: 364 , Y: 15 , W: 30 , H: 30 }
blackAndWhite := [ "0x33004444" , "0x44FFFFFF" , "0x33aaaaaa" , "0x6622262a" ]
BAndWSize := [ 9 , 6 , 5 , 3 ]
Gui1.MyString := New BubbleText( { Text: "ArrowHead 2" , FontColor: "0xFF009999" , FontSize: 39 , FontType: "Ink Free" , FullWrap: 0 } , blackAndWhite , BAndWsize )
DrawWindow( Gui1 )
OnMessage( 0x201 , func( "WindowClick" ).Bind( Gui1 ) )
OnMessage( 0x020A , func( "WheelChange" ).bind( Gui1 ) )
return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
RALT::PopUpWindow.Helper()
WindowClick( Gui1 , l , w , msg , hwnd ){
if( Gui1.Hwnd != hwnd )
return 1
CoordMode, Mouse, Screen
MouseGetPos, x, y
x -= Gui1.X
y -= Gui1.Y
for k , v in [ "Arrow" , "Move" , "Close" ] {
cc := Gui1.Controls[ v ]
if( x >= cc.X && x <= cc.X + cc.W && y >= cc.Y && y <= cc.Y + cc.H ){
if( k = 1 ){
if( GetKeyState( "Shift" ) && GetKeyState( "Ctrl" ) ){
Gui1.Controls.Arrow.BGColor := GetColor()
}else if( GetKeyState( "Shift" ) ){
Gui1.Controls.Arrow.ArrowColor := GetColor()
}else if( GetKeyState( "Ctrl" ) ){
Gui1.Controls.Arrow.ArrowBorderColor := GetColor()
}else{
return
}
DrawWindow( Gui1 )
}else if( k = 2 ){
MoveWindow( Gui1 )
}else if( k = 3 ){
ExitApp
}
}
}
}
MoveWindow( Gui1 ){
PostMessage, 0xA1, 2
While( GetKeyState( "LButton" , "P" ) )
Sleep, 30
WinGetPos, x, y,,, % "ahk_id " Gui1.Hwnd
Gui1.UpdateSettings( { X: x , Y: y } )
}
GetColor(){
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
While( GetKeyState( "Shift" ) || GetKeyState( "ctrl" ) )
Sleep, 30
ColorGui := New PopUpWindow( { AutoShow: 1 , X: 0 , Y: 0 , W: 40 , H: 40 , Options: " -DPIScale +AlwaysOnTop +ToolWindow" } )
While( !GetKeyState( "ctrl" ) ){
ToolTip, Move your cursor over a color and then press "ctrl".
MouseGetPos, x , y
PixelGetColor, color , x , y , RGB
ColorGui.UpdateSettings( { X: x + 40 , Y: y - 60 } )
ColorGui.ClearWindow()
ColorGui.PaintBackground( { Color: "0xFF000000" , X: 1 , Y: 1 , W: ColorGui.W - 2 , H: ColorGui.H - 2 , Round: 10 } , 1 )
ColorGui.PaintBackground( { Color: "0xFF" SubStr( color , 3 ) , X: 2 , Y: 2 , W: ColorGui.W - 4 , H: ColorGui.H - 4 , Round: 10 } , 1 )
}
ColorGui.DeleteWindow()
ToolTip,
return "0xFF" SubStr( color , 3 )
}
WheelChange( Gui1 , input , l , msg , hwnd ){
if( Gui1.Hwnd != hwnd )
return 1
CoordMode, Mouse, Screen
MouseGetPos, x, y
x -= Gui1.X
y -= Gui1.Y
Dir := ( ( input >> 16 ) > 0x7FFF ) || ( ( input < 0 ) ? ( 1 ) : ( 0 ) )
change := 0
for k , v in Gui1.Controls {
cc := Gui1.Controls[ k ]
if( x >= cc.X && x <= cc.X + cc.W && y >= cc.Y && y <= cc.Y + cc.H ){
if( Dir ){
if( GetKeyState( "Shift" ) ){
cc.Value -= 10
}else{
--cc.Value
}
}else if( !Dir ){
if( GetKeyState( "Shift" ) )
cc.Value += 10
else
cc.Value += 1
}
Sleep, 30
DrawWindow( Gui1 )
return -1
}
}
}
DrawWindow( Gui1 ){
Gui1.ClearWindow()
Gui1.DrawBitmap( ArrowHeadEditor( Gui1 ) , { X: 0 , Y: 0 , W: Gui1.W , H: Gui1.H } , dispose := 1 )
MyArrow := New ArrowHead_2( { X: 30 , Y: 280 } , { X: 300 , Y: 100 } , Gui1.Controls.Head.Value , Gui1.Controls.Neck.Value , Gui1.Controls.Arm.Value , Gui1.Controls.Elbow.Value )
_FillPolygon( Gui1.G , MyArrow , Gui1.Controls.Arrow.ArrowColor )
_DrawPolygon( Gui1.G , MyArrow , Gui1.Controls.Arrow.ArrowBorderColor , Thickness := 3 )
Gui1.UpdateWindow()
}
_FillPolygon( G , Points := "50 , 50 | 100 , 100 | 150 , 50 | 50 , 50 " , Color := "0xFFFF0000" ){
Brush := Gdip_BrushCreateSolid( Color ) , Gdip_FillPolygon( G , Brush , Points ) , Gdip_DeleteBrush( Brush )
}
_DrawPolygon( G , Points := "50 , 50 | 100 , 100 | 150 , 50 | 50 , 50 " , Color := "0xFF000000" , Thickness := 3 ){
Pen := Gdip_CreatePen( Color , Thickness ) , Gdip_DrawLines( G , Pen , Points ) , Gdip_DeletePen( Pen )
}
ArrowHeadEditor( Gui1 , ScaleFactor := 1 ){
;Bitmap Created Using: HB Bitmap Maker
pBitmap := Gdip_CreateBitmap( 410 * ScaleFactor , 310 * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_CreateLineBrushFromRect( 1 * ScaleFactor , 4 * ScaleFactor , 403 * ScaleFactor , 300 * ScaleFactor , "0x99F0F0F0" , "0x99000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 * ScaleFactor , 5 * ScaleFactor , 400 * ScaleFactor , 300 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 6 * ScaleFactor , 7 * ScaleFactor , 399 * ScaleFactor , 298 * ScaleFactor , "0x66F0F0F0" , "0x66000000" , 2 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 * ScaleFactor , 5 * ScaleFactor , 400 * ScaleFactor , 300 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 6 * ScaleFactor , 7 * ScaleFactor , 399 * ScaleFactor , 298 * ScaleFactor , "0x33F0F0F0" , "0x33000000" , 3 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 * ScaleFactor , 5 * ScaleFactor , 400 * ScaleFactor , 300 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 7 * ScaleFactor , 7 * ScaleFactor , 397 * ScaleFactor , 294 * ScaleFactor , "0x99FFFFFF" , "0x99000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 5 * ScaleFactor , 5 * ScaleFactor , 400 * ScaleFactor , 300 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeletePen( Pen )
Gdip_DrawImage( G , Gui1.MyString.Bitmap, 40 , 5 , Gui1.MyString.Width , Gui1.MyString.Height )
Brush := Gdip_BrushCreateSolid( "0xFF444444" ) , Gdip_FillRoundedRectangle( G , Brush , 364 * ScaleFactor , 15 * ScaleFactor , 30 * ScaleFactor , 30 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99F0F0F0" ) , Gdip_TextToGraphics( G , "x" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 355 * ScaleFactor " y" 5 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 50 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( Gui1.Controls.Arrow.BGColor ) , Gdip_FillRoundedRectangle( G , Brush , 15 * ScaleFactor , 75 * ScaleFactor , 310 * ScaleFactor , 220 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF444444" ) , Gdip_FillRoundedRectangle( G , Brush , 335 * ScaleFactor , 55 * ScaleFactor , 60 * ScaleFactor , 240 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99333333" ) , Gdip_TextToGraphics( G , "Head" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 342 * ScaleFactor " y" 54 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99F0F0F0" ) , Gdip_TextToGraphics( G , "Head" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 341 * ScaleFactor " y" 53 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRoundedRectangle( G , Brush , 340 * ScaleFactor , 80 * ScaleFactor , 50 * ScaleFactor , 30 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Gui1.Controls.Head.Value , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 340 * ScaleFactor " y" 80 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99333333" ) , Gdip_TextToGraphics( G , "Neck" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 342 * ScaleFactor " y" 114 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99F0F0F0" ) , Gdip_TextToGraphics( G , "Neck" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 341 * ScaleFactor " y" 113 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRoundedRectangle( G , Brush , 340 * ScaleFactor , 140 * ScaleFactor , 50 * ScaleFactor , 30 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Gui1.Controls.Neck.Value , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 340 * ScaleFactor " y" 140 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99333333" ) , Gdip_TextToGraphics( G , "Arm" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 342 * ScaleFactor " y" 174 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99F0F0F0" ) , Gdip_TextToGraphics( G , "Arm" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 341 * ScaleFactor " y" 173 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRoundedRectangle( G , Brush , 340 * ScaleFactor , 200 * ScaleFactor , 50 * ScaleFactor , 30 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Gui1.Controls.Arm.Value , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 340 * ScaleFactor " y" 200 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99333333" ) , Gdip_TextToGraphics( G , "Elbow" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 336 * ScaleFactor " y" 234 * ScaleFactor , "Segoe UI" , 60 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99F0F0F0" ) , Gdip_TextToGraphics( G , "Elbow" , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 336 * ScaleFactor " y" 233 * ScaleFactor , "Segoe UI" , 60 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRoundedRectangle( G , Brush , 340 * ScaleFactor , 260 * ScaleFactor , 50 * ScaleFactor , 30 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" ) , Gdip_TextToGraphics( G , Gui1.Controls.Elbow.Value , "s" 16 * ScaleFactor " Center vCenter Bold c" Brush " x" 340 * ScaleFactor " y" 260 * ScaleFactor , "Segoe UI" , 50 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
return pBitmap
}
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;####################################################################################################################################################################################
;Color Text class
;Written By: Hellbent
;Date: Jan 18th , 2023
;Last Edit: Jan 20th , 2023
;Change: Can now set to use a pie shape to do a drop shadow. [ Key: FullWrap | Values: 0/1 ]
;Thanks To: jNizM ( https://www.autohotkey.com/boards/viewtopic.php?f=76&t=112861#p502745 )
class BubbleText {
__New( obj := "" , Colors := "0xFF000000" , Sizes := 2 ){
This._SetDefaults()
This._UpdateDefaults( obj , Colors , Sizes )
This._CreateBitmaps()
This._LiquidatePixels()
return This.Output
}
_SetDefaults(){
This.Text := "Hello World"
This.FontType := "Comic Sans MS"
This.FontSize := 16
This.FontColor := "0xFFFFFFFF"
This.FontOptions := " Center vCenter "
This.BackgroundColor := ""
This.StringHeight := ""
This.StringWidth := ""
This.TextBitmap := ""
This.Bitmaps := []
This.Colors := []
This.SizeInterval := 1
This.Smoothing := 4
This.RedRange := 128
This.GreenRange := 128
This.BlueRange := 128
This.FullWrap := 1
}
_UpdateDefaults( obj := "" , Colors := "0xFF000000" , Sizes := 2 ){
for k , v in obj
This[ k ] := obj[ k ]
if( IsObject( Colors ) ){
for k , v in Colors
This.Colors[ A_Index ] := Colors[ A_Index ]
}else if( colors != "" ){
This.Colors[ 1 ] := colors
}
if( IsObject( Sizes ) ){
for k , v in Sizes
This.Sizes[ A_Index ] := Sizes[ A_Index ]
}else if( Sizes != "" ){
This.Sizes[ 1 ] := Sizes
}
if( ( dif := This.Sizes.Length() - This.Colors.Length() ) < 0 ){
index := This.Sizes.Length()
loop, % dif {
This.Sizes[ index + A_Index ] := This.Sizes[ index + A_Index - 1 ] - This.SizeInterval
}
}else if( ( dif := This.Colors.Length() - This.Sizes.Length() ) < 0 ){
index := This.Colors.Length()
loop, % dif {
This.Colors[ index + A_Index ] := This.Colors[ index + A_Index - 1 ]
}
}
}
_CreateBitmaps(){
This.StringWidth := This._GetTextSize( 1 , This.Text )
This.StringHeight := This._GetTextSize( 2 , This.Text ) / 1.05
This.TextBitmap := Gdip_CreateBitmap( This.StringWidth , This.StringHeight )
This.TextBitmapGraphics := Gdip_GraphicsFromImage( This.TextBitmap )
Gdip_SetSmoothingMode( This.TextBitmapGraphics , This.Smoothing )
if( This.BackgroundColor != ""){
Brush := Gdip_BrushCreateSolid( This.BackgroundColor )
Gdip_FillRectangle( This.TextBitmapGraphics , Brush, -10 , -10 , This.StringWidth + 20 , This.StringHeight + 20 )
Gdip_DeleteBrush( Brush )
}
Brush := Gdip_BrushCreateSolid( This.FontColor )
Gdip_TextToGraphics( This.TextBitmapGraphics , This.Text , " s" This.Fontsize " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.FontType , This.StringWidth, This.StringHeight )
Gdip_DeleteBrush( Brush )
This.MaxSize := 0
Loop, % This.Sizes.Length() {
if( This.Sizes[ A_Index ] > This.MaxSize ){
This.MaxSize := This.Sizes[ A_Index ]
}
}
Loop, % This.Colors.Length() {
This.Bitmaps[ A_Index ] := {}
This.Bitmaps[ A_Index ].Bitmap := Gdip_CreateBitmap( This.StringWidth + 2 * This.MaxSize + 4 , This.StringHeight + 2 * This.MaxSize + 4 )
This.Bitmaps[ A_Index ].Graphics := Gdip_GraphicsFromImage( This.Bitmaps[ A_Index ].Bitmap )
Gdip_SetSmoothingMode( This.Bitmaps[ A_Index ].Graphics , This.Smoothing )
}
This.Output := {}
This.Output.Width := This.StringWidth + 2 * This.MaxSize + 4
This.Output.Height := This.StringHeight + 2 * This.MaxSize + 4
This.Output.Bitmap := Gdip_CreateBitmap( This.Output.Width , This.Output.Height )
This.Output.Graphics := Gdip_GraphicsFromImage( This.Output.Bitmap )
}
_GetTextSize( outputType := 0 , String := "" ){ ; 0 = all , 1 = width , 2 = height
local pBitmap, G, Brush, temparr
pBitmap := Gdip_CreateBitmap( 10,10), G := Gdip_GraphicsFromImage( pBitmap ), Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF000000")
temparr := StrSplit( Gdip_TextToGraphics( G , ( String != "" ) ? ( String ) : ( "T" ) , " s" This.Fontsize " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.FontType , 10000, 10000 ),"|","|" )
Gdip_DeleteBrush( Brush ), Gdip_DeleteGraphics( G ), Gdip_DisposeImage( pBitmap )
if( outputType = 0 )
return temparr
else if( outputType = 1 )
return temparr[ 3 ]
else if( outputType = 2 )
return temparr[ 4 ]
}
_GetGray( OUTPUTCOLOR ){ ;From HB color picker v2
StringTrimLeft,OUTPUTCOLOR,OUTPUTCOLOR,2
StringLeft , r , OUTPUTCOLOR , 2
StringTrimLeft,OUTPUTCOLOR,OUTPUTCOLOR,2
StringLeft , g , OUTPUTCOLOR , 2
StringTrimLeft,OUTPUTCOLOR,OUTPUTCOLOR,2
StringLeft , b , OUTPUTCOLOR , 2
r := "0x" r , g := "0x" g , b := "0x" b
REDSLIDERVALUE:=r+0,GreenSLIDERVALUE:=g+0,BlueSLIDERVALUE:=b+0
GreyScaleSLIDERVALUE:=Round((REDSLIDERVALUE+GreenSLIDERVALUE+BlueSLIDERVALUE)/3)
return GreyScaleSLIDERVALUE
}
_LiquidatePixels(){
local x , y , brushes := [] , Ptr := A_PtrSize ? "UPtr" : "UInt"
Loop, % This.Colors.Length()
Brushes[ A_Index ] := Gdip_BrushCreateSolid( This.Colors[ A_Index ] )
y := 0
Loop, % This.StringHeight {
x := 0
Loop, % This.StringWidth {
SetFormat, IntegerFast, hex
DllCall( gdiplus.GdipBitmapGetPixel , Ptr , This.TextBitmap, "int", x, "int", y, "uint*", col )
if( col != 0x0 ){
Loop, % This.Bitmaps.Length() {
if( This.FullWrap ){
DllCall( gdiplus.GdipFillEllipse , Ptr, This.Bitmaps[ A_Index ].Graphics, Ptr, Brushes[ A_Index ] , "float", x + This.MaxSize + 2 - This.Sizes[ A_Index ] , "float", y + This.MaxSize + 2 - This.Sizes[ A_Index ] , "float", 2 * This.Sizes[ A_Index ] , "float", 2 * This.Sizes[ A_Index ] )
}else{
DllCall( gdiplus.GdipFillPie , Ptr, This.Bitmaps[ A_Index ].Graphics , Ptr, Brushes[ A_Index ] , "float", x + This.MaxSize + 2 - This.Sizes[ A_Index ] , "float", y + This.MaxSize + 2 - This.Sizes[ A_Index ] , "float", 2 * This.Sizes[ A_Index ] , "float", 2 * This.Sizes[ A_Index ] , "float", 0 , "float", 90)
}
}
}
SetFormat, IntegerFast, dec
x++
}
y++
}
Loop, % This.Bitmaps.Length() {
Gdip_DeleteGraphics( This.Bitmaps[ A_Index ].Graphics )
Gdip_DrawImage( This.Output.Graphics , This.Bitmaps[ A_Index ].Bitmap , 0 , 0 , This.Output.Width , This.Output.Height )
}
if( This.BackgroundColor = "" )
Gdip_DrawImage( This.Output.Graphics , This.TextBitmap , This.MaxSize + 2 , This.MaxSize + 2 , This.StringWidth , This.StringHeight )
else{
Gdip_DeleteGraphics( This.TextBitmapGraphics )
Gdip_DisposeImage( This.TextBitmap )
This.TextBitmap := Gdip_CreateBitmap( This.StringWidth , This.StringHeight )
This.TextBitmapGraphics := Gdip_GraphicsFromImage( This.TextBitmap )
Gdip_SetSmoothingMode( This.TextBitmapGraphics , This.Smoothing )
Brush := Gdip_BrushCreateSolid( This.FontColor )
Gdip_TextToGraphics( This.TextBitmapGraphics , This.Text , " s" This.Fontsize " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.FontType , This.StringWidth, This.StringHeight )
Gdip_DeleteBrush( Brush )
Gdip_DrawImage( This.Output.Graphics , This.TextBitmap , This.MaxSize + 2 , This.MaxSize + 2 , This.StringWidth , This.StringHeight )
}
Gdip_DeleteGraphics( This.Output.Graphics )
Loop, % This.Colors.Length() {
Gdip_DeleteBrush( Brushes[ A_Index ] )
}
Gdip_DeleteGraphics( This.TextBitmapGraphics )
}
_hex2rgb( CR , ByRef R , ByRef G , ByRef B , ByRef A := "NA" ){ ;https://www.autohotkey.com/boards/viewtopic.php?t=3925&p=312862
H := InStr(CR, "0x") ? CR : ( InStr(CR, "#" ) ? "0x" SubStr( CR , 2 ) : "0x" CR )
R := (H & 0xFF0000) >> 16 , G := (H & 0xFF00) >> 8 , B := (H & 0xFF) , ( A != "NA" ) ? ( A := (H & 0xFF000000) >> 24 )
}
}
LoadLibrary(filename){ ;https://www.autohotkey.com/boards/viewtopic.php?p=48392#p48392
static ref := {}
if (!(ptr := p := DllCall("LoadLibrary", "str", filename, "ptr")))
return 0
ref[ptr,"count"] := (ref[ptr]) ? ref[ptr,"count"]+1 : 1
p += NumGet(p+0, 0x3c, "int")+24
o := {_ptr:ptr, __delete:func("FreeLibrary"), _ref:ref[ptr]}
if (NumGet(p+0, (A_PtrSize=4) ? 92 : 108, "uint")<1 || (ts := NumGet(p+0, (A_PtrSize=4) ? 96 : 112, "uint")+ptr)=ptr || (te := NumGet(p+0, (A_PtrSize=4) ? 100 : 116, "uint")+ts)=ts)
return o
n := ptr+NumGet(ts+0, 32, "uint")
loop % NumGet(ts+0, 24, "uint"){
if (p := NumGet(n+0, (A_Index-1)*4, "uint")){
o[f := StrGet(ptr+p, "cp0")] := DllCall("GetProcAddress", "ptr", ptr, "astr", f, "ptr")
if (Substr(f, 0)==((A_IsUnicode) ? "W" : "A"))
o[Substr(f, 1, -1)] := o[f]
}
}
return o
}
FreeLibrary(lib){
if (lib._ref.count>=1)
lib._ref.count -= 1
if (lib._ref.count<1)
DllCall("FreeLibrary", "ptr", lib._ptr)
}