Search the Community
Showing results for tags 'GDI+ Animation'.
-
Zip file for this is here #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <String.au3> Opt("GUIOnEventMode", 1) $Wid = 960 $Hgt = 720 Global $StringX, $StringY Global $flakes = 25, $Min = 5, $Max = 20 Global $particles[$flakes][5] Global $santaX = $wid, $santaY = 100 Global $sc_hBrush, $sc_hFormat, $sc_hFamily, $sc_hFont, $sc_text_color, $text_scroller, $sc_tLayout, $sc_pen, $sc_brush Global $letter_distance, $x, $y, $lenght, $end, $scroller_length, $sc_k Global $shadowBrush, $shadowFormat, $shadowFamily, $shadowFont, $shadowFamily, $shadowLayout Global $tshadow, $shadowtext ,$shadowtLayout, $shadowColor = 0xFFABA9BA Global $sc_text = "*** Merry Christmas and Happy New Year to all Autoit Users! ***" Global $sc_font_size = 48, $Font = "Times New Roman", $Fontoffset = 3 Global $bassdll = DllOpen(@ScriptDir & "\BASSMOD.dll"), $Play, $Pause, $stop Global $Titlestart = " " Global $Title = $Titlestart &" *** Merry Christmas! *** " $hGUI = GUICreate($Title, $Wid, $Hgt, -1, -1); -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE)) $menu = GUICtrlCreateMenu("Music") $Play = GUICtrlCreateMenuItem("Play", $menu) GUICtrlSetState(-1, $GUI_CHECKED) $Pause = GUICtrlCreateMenuItem("Pause", $menu) GUICtrlSetState(-1, $GUI_UNCHECKED) $Exit = GUICtrlCreateMenuItem("Exit", $menu) GUICtrlSetState(-1, $GUI_UNCHECKED) If @OSBuild < 7600 Then WinSetTrans($hGUI,"", 0xFF) ; only use this if solid background GUISetState(@SW_SHOW) GUISetOnEvent(-3, "close") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; =========================================== _GDIPlus_Startup() ;Window BckBuffer $graphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) $bitmap = _GDIPlus_BitmapCreateFromGraphics($Wid, $Hgt, $graphics) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) ; BackBuffer for static image $bitmap1 = _GDIPlus_BitmapCreateFromGraphics($Wid, $Hgt, $graphics) $backbuffer1 = _GDIPlus_ImageGetGraphicsContext($bitmap1) $Background = _GDIPlus_ImageLoadFromFile("SnowScene.png") #Region Load Images $santa = _GDIPlus_ImageLoadFromFile("Santa.png") $santaW = _GDIPlus_ImageGetWidth($santa) $santaH = _GDIPlus_ImageGetHeight($santa) $Flake1 = _GDIPlus_ImageLoadFromFile("Flake1.png") $Flake1W = _GDIPlus_ImageGetWidth($Flake1)/4 $Flake1H = _GDIPlus_ImageGetHeight($Flake1)/4 $F1eX = $Flake1W/2 $F1eY = $Flake1H/2 $Flake2 = _GDIPlus_ImageLoadFromFile("Flake2.png") $Flake2W = _GDIPlus_ImageGetWidth($Flake2)/4 $Flake2H = _GDIPlus_ImageGetHeight($Flake2)/4 $F2eX = $Flake2W/2 $F2eY = $Flake2H/2 $Flake3 = _GDIPlus_ImageLoadFromFile("Flake3.png") $Flake3W = _GDIPlus_ImageGetWidth($Flake3)/4 $Flake3H = _GDIPlus_ImageGetHeight($Flake3)/4 $F3eX = $Flake3W/2 $F3eY = $Flake3H/2 #endregion #Region Setup Scroll Font $sc_text_color = 0xFFffffff $sc_htextBrush = _GDIPlus_BrushCreateSolid($sc_text_color) $sc_hFormat = _GDIPlus_StringFormatCreate() $sc_hFamily = _GDIPlus_FontFamilyCreate($Font) $sc_hFont = _GDIPlus_FontCreate($sc_hFamily, $sc_font_size, 2) $sc_pen = _GDIPlus_PenCreate(0) $sc_brush = _GDIPlus_BrushCreateSolid(0) $tLayout = _GDIPlus_RectFCreate(0, 0) ;shadow ;$T_Fontoffset = 5 $ShadowBrush = _GDIPlus_BrushCreateSolid($shadowColor) $ShadowFormat = _GDIPlus_StringFormatCreate() $ShadowFamily = _GDIPlus_FontFamilyCreate($Font) $ShadowFont = _GDIPlus_FontCreate($shadowFamily, $sc_font_size, 2) $ShadowLayout = _GDIPlus_RectFCreate(0, 0) ;Text Ini $sc_letter_distance = $sc_font_size $sc_length = $sc_font_size * 1.666 * 0.36 $sc_k = $wid $end = 0 $scroller_length = StringLen($sc_text) * $sc_length $sc_FontY = $Hgt - $Hgt/4 + 40 #endregion For $i = 0 To UBound($particles) - 1 $particles[$i][0] = Random(0, $wid, 1) ;X pos $particles[$i][1] = Random(0, $hgt, 1) ;Y pos $particles[$i][2] = 0 $particles[$i][3] = Random($min, $max) $particles[$i][4] = Random($min, $max, 1) ;size Next Play_Audio() Do _GDIPlus_GraphicsClear($backbuffer, 0x00FFFFFF) _GDIPlus_GraphicsDrawImageRect($backbuffer1, $Background, 0, 0, $Wid, $Hgt) ;Static Image _Draw() ScrollText() _GDIPlus_GraphicsDrawImageRect($backbuffer1, $bitmap, 0, 0, $Wid, $Hgt) _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap1, 0, 0, $Wid, $Hgt) Sleep(20) Until 0 Func _Draw() _GDIPlus_GraphicsDrawImageRect($backbuffer1, $santa, $santaX, $santaY, $santaW, $santaH) For $i = 0 To UBound($particles) - 1 If $particles[$i][1] > $hgt Then $particles[$i][0] = Random(-50, $wid+50, 1) ; X pos $particles[$i][1] = 0 ; y Pos $particles[$i][2] = 0 $particles[$i][3] = Random($min, $max) ;min, max, [int] $particles[$i][4] = Random($min, $max, 1) ; size EndIf $particles[$i][0] += $particles[$i][2] $particles[$i][1] += $particles[$i][3] ; X y width Height _GDIPlus_GraphicsDrawImageRect($backbuffer1, $Flake1, $particles[$i][0], $particles[$i][1], $Flake1W +$particles[$i][4], $Flake1H + $particles[$i][4]) _GDIPlus_GraphicsDrawImageRect($backbuffer1, $Flake2, $particles[$i][0] + 50 , $particles[$i][1] + 50, $Flake1W +$particles[$i][4], $Flake1H + $particles[$i][4]) _GDIPlus_GraphicsDrawImageRect($backbuffer1, $Flake3, $particles[$i][0] - 25 , $particles[$i][1] - 25, $Flake1W +$particles[$i][4], $Flake1H + $particles[$i][4]) Next $santaX -= 8 If -$SantaW >= $santaX Then $santaX = $Wid EndIf EndFunc ; ========= Handle WM_COMMAND messages ======================= Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $Play Play() Case $Pause Pause() Case $Exit Close() EndSwitch EndFunc ;==>WM_COMMAND ;============================================================= ; ================ SCROLL TEXT ==================== Func ScrollText() $sc_FontX = $sc_k + $sc_letter_distance DllStructSetData($tLayout, "x", $sc_FontX) DllStructSetData($tLayout, "y", $sc_FontY) _GDIPlus_GraphicsDrawStringEx($BackBuffer, $sc_text, $sc_hFont, $tLayout, $sc_hFormat, $sc_htextBrush) ;Shadow DllStructSetData($ShadowLayout, "X", $sc_FontX + $FontOffset) DllStructSetData($ShadowLayout, "Y", $sc_FontY + $FontOffset) _GDIPlus_GraphicsDrawStringEx($Backbuffer1, $sc_text, $shadowFont, $shadowLayout, $shadowFormat, $shadowBrush) ;Text DllStructSetData($tLayout, "X", $sc_FontX) DllStructSetData($tLayout, "Y", $sc_FontY) _GDIPlus_GraphicsDrawStringEx($Backbuffer1, $sc_text, $sc_hFont, $tLayout, $sc_hFormat, $sc_htextBrush) $sc_k -= 5 If -$scroller_length >= $sc_k Then $sc_k = $Wid EndFunc Func Play_Audio() $Init = DllCall($bassdll, "int", "BASSMOD_Init", "int", -1, "int", 44100, "int", 0) $string= DllStructCreate("char[255]") DllStructSetData($string, 1, @ScriptDir & "\christmas_silence.xm") $load = DllCall($bassdll, "int", "BASSMOD_MusicLoad", _ "int", 0, _ "ptr", DllStructGetPtr($string), _ "int", 0, _ "int", 0, _ "int", 4 + 1024) $VolLevel = 100 $Volume = DllCall($bassdll, "int", "BASSMOD_SetVolume", "int", $VolLevel) DllCall($bassdll, "int", "BASSMOD_MusicPlay") EndFunc Func Play() ;consolewrite("You selected Play" &@CRLF) GUICtrlSetState($Play, $GUI_CHECKED) DllCall($bassdll, "int", "BASSMOD_MusicPlay") GUICtrlSetState($Pause, $GUI_UNCHECKED) GUICtrlSetState($Stop, $GUI_UNCHECKED) EndFunc Func Pause() ;consolewrite("You selected Pause" &@CRLF) GUICtrlSetState($Pause, $GUI_CHECKED) DllCall($bassdll, "int", "BASSMOD_MusicPause") GUICtrlSetState($Play, $GUI_UNCHECKED) GUICtrlSetState($Stop, $GUI_UNCHECKED) EndFunc Func close() _GDIPlus_FontDispose($SC_hFont) _GDIPlus_FontFamilyDispose($SC_hFamily) _GDIPlus_StringFormatDispose($SC_hFormat) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_BrushDispose($sc_hBrush) _GDIPlus_FontFamilyDispose($shadowFamily) _GDIPlus_StringFormatDispose($shadowFormat) _GDIPlus_BrushDispose($shadowBrush) _WinAPI_DeleteObject($bitmap) _WinAPI_DeleteObject($bitmap1) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_GraphicsDispose($backbuffer1) _GDIPlus_Shutdown() Exit EndFunc ;==>close ; Happy Holidays!