-
Notifications
You must be signed in to change notification settings - Fork 72
/
class_Animation.ahk
114 lines (90 loc) · 4.06 KB
/
class_Animation.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
;-------------------------------------------------------------------------------
; class Animation.ahk
; by wolf_II
;-------------------------------------------------------------------------------
; version 1.30
;===============================================================================
class Animation { ; manage animations
;===============================================================================
static pToken := ""
static Count := 0
; configuration
BkColor := 0x00FFFFFF ; transparent white
Delay := 10 ; 1..16 <- all the same
Draw := "Draw" ; function name
; configure "Quality functions"
TextRenderingMode := ANTIALIAS
InterpolationMode := HIGHQUALITYBICUBIC
SmoothingMode := ANTIALIAS
CompositingMode := OVERWRITE
;---------------------------------------------------------------------------
__New(hParent, Config := "") { ; attach to parent
;---------------------------------------------------------------------------
If Config.HasKey("BkColor")
this.BkColor := Config.BkColor
If Config.HasKey("Delay")
this.Delay := Config.Delay
If Config.HasKey("Draw")
this.Draw := Config.Draw
If Config.HasKey("TextRenderingMode")
this.TextRenderingMode := Config.TextRenderingMode
If Config.HasKey("InterpolationMode")
this.InterpolationMode := Config.InterpolationMode
If Config.HasKey("SmoothingMode")
this.SmoothingMode := Config.SmoothingMode
If Config.HasKey("CompositingMode")
this.CompositingMode := Config.CompositingMode
If !Animation.pToken
Animation.pToken := Gdip_Startup()
Animation.Count++
GuiControl, +E0x80000, % this.hWnd := hParent ; WS_EX_LAYERED
this.hBM := CreateDIBSection(A_ScreenWidth, A_ScreenHeight)
this.hDC := CreateCompatibleDC()
this.oBM := SelectObject(this.hDC, this.hBM)
this.pGraphics := Gdip_GraphicsFromHDC(this.hDC)
Gdip_SetTextRenderingHint(this.pGraphics, this.TextRenderingMode)
Gdip_SetInterpolationMode(this.pGraphics, this.InterpolationMode)
Gdip_SetSmoothingMode(this.pGraphics, this.SmoothingMode)
Gdip_SetCompositingMode(this.pGraphics, this.CompositingMode)
}
;---------------------------------------------------------------------------
__Delete() { ; clean up
;---------------------------------------------------------------------------
this.Clear()
this.Update()
SelectObject(this.hDC, this.oBM)
DeleteObject(this.hBM)
DeleteDC(this.hDC)
Gdip_DeleteGraphics(this.pGraphics)
If (--Animation.Count = 0)
Gdip_Shutdown(Animation.pToken)
}
;---------------------------------------------------------------------------
Call() { ; timer controlled
;---------------------------------------------------------------------------
this.Clear()
Func(this.Draw).Call()
this.Update()
}
;---------------------------------------------------------------------------
Clear() { ; stand alone
;---------------------------------------------------------------------------
Gdip_GraphicsClear(this.pGraphics, this.BkColor)
}
;---------------------------------------------------------------------------
Update() { ; stand alone
;---------------------------------------------------------------------------
UpdateLayeredWindow(this.hWnd, this.hDC)
}
;---------------------------------------------------------------------------
Start() { ; start timer
;---------------------------------------------------------------------------
SetTimer, %this%, % this.Delay
this.Call() ; start immediately
}
;---------------------------------------------------------------------------
Stop() { ; stop timer
;---------------------------------------------------------------------------
SetTimer, %this%, Off
}
}