So, da es ja auch schon einige Partikelexplosionen in GDI+ gibt, hab ich jetzt auch mal eine gemacht
Allerdings finde ich, dass meine nicht ganz so gut ist, wie die anderen.
Hier das Skript:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <Color.au3>
Opt("GuiOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $iGUIHeight = 800
Global $iGUIWidth = 800
Global $iX = 400
Global $iY = 400
Global $AmountParticles = 70 ;;##Anzahl der Partikel
Global $ParticlesPos[$AmountParticles][2]
Global $ParticlesWay[$AmountParticles][2]
Global $DurchlaufZahl = -1.5
Global $Hex = 255
Global $Color = _RandomColor()
For $i = 0 To $AmountParticles - 1
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][0] = Random(1, 100, 1) / 50
EndIf
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][1] = Random(1, 100, 1) / 50
EndIf
Next
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] = ($iX - $ParticlesWay[$i][0])
$ParticlesPos[$i][1] = ($iY + $ParticlesWay[$i][1])
Next
Global $hGUI = GUICreate("Partikelexplosion by ClezZ", $iGUIWidth, $iGUIHeight)
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphics)
Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
_GDIPlus_GraphicsClear($hBuffer, 0xFF000000)
Global $hBrush = _GDIPlus_BrushCreateSolid('0xFF' & $Color)
_WM_PAINT()
[/autoit] [autoit][/autoit] [autoit]AdlibRegister("_ParticleDraw", 19)
[/autoit] [autoit][/autoit] [autoit]While 1
WEnd
Func _ParticleDraw()
_GDIPlus_GraphicsClear($hBuffer, '0x'&Hex(50, 2)&'000000')
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] += $ParticlesWay[$i][0] / $DurchlaufZahl
$ParticlesPos[$i][1] += $ParticlesWay[$i][1] / $DurchlaufZahl
_GDIPlus_GraphicsFillEllipse($hBuffer, $ParticlesPos[$i][0], $ParticlesPos[$i][1], 4, 4, $hBrush)
Next
$Hex += $DurchlaufZahl
_GDIPlus_BrushSetSolidColor($hBrush, '0x' & Hex($Hex, 2) & $Color)
If $Hex <= 0 Then
_GDIPlus_GraphicsClear($hBuffer, '0xFF000000')
For $i = 0 To $AmountParticles - 1
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][0] = Random(1, 100, 1) / 50
EndIf
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][1] = Random(1, 100, 1) / 50
EndIf
Next
$iX = Random(100, $iGUIWidth-100, 1)
$iY = Random(100, $iGUIHeight-100, 1)
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] = $iX
$ParticlesPos[$i][1] = $iY
Next
$DurchlaufZahl = -1.5
$Hex = 255
$Color = _RandomColor()
EndIf
$DurchlaufZahl -= 0.01
[/autoit] [autoit][/autoit] [autoit]_WM_PAINT()
EndFunc ;==>_ParticleDraw
Func _Exit()
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
Func _WM_PAINT()
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
EndFunc ;==>_WM_PAINT
Func _RandomColor()
Local $BackColor[3]
$BackColor[0] = Random(70, 255, 1)
$BackColor[1] = Random(70, 255, 1)
$BackColor[2] = Random(70, 255, 1)
Return Hex(_ColorSetRGB($BackColor), 6)
EndFunc ;==>_RandomColor
Und hier noch, mit Hilfe von name22, als Screensaver:
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Color.au3>
#include <Timers.au3>
Opt("GuiOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $iGUIHeight = 500
Global $iGUIWidth = 500
Global $iX = 200
Global $iY = 200
Global $AmountParticles = 60
Global $ParticlesPos[$AmountParticles][2]
Global $ParticlesWay[$AmountParticles][2]
Global $DurchlaufZahl = -1.5
Global $Hex = 255
Global $Color = _RandomColor()
For $i = 0 To $AmountParticles - 1
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][0] = Random(1, 100, 1) / 50
EndIf
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][1] = Random(1, 100, 1) / 50
EndIf
Next
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] = ($iX - $ParticlesWay[$i][0])
$ParticlesPos[$i][1] = ($iY + $ParticlesWay[$i][1])
Next
Global $hGUI = GUICreate("Partikelexplosion by ClezZ", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
WinSetState($hGUI, "", @SW_MAXIMIZE)
GUISetCursor(16, 1, $hGUI)
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphics)
Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
_GDIPlus_GraphicsClear($hBuffer, 0xFF000000)
_GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
Global $hBrush = _GDIPlus_BrushCreateSolid('0xFF' & $Color)
Sleep(100)
[/autoit] [autoit][/autoit] [autoit]While Sleep(20)
If _Timer_GetIdleTime() <= 100 Then _Exit()
_GDIPlus_GraphicsClear($hBuffer, '0x'&Hex(50, 2)&'000000')
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] += $ParticlesWay[$i][0] / $DurchlaufZahl
$ParticlesPos[$i][1] += $ParticlesWay[$i][1] / $DurchlaufZahl
_GDIPlus_GraphicsFillEllipse($hBuffer, $ParticlesPos[$i][0], $ParticlesPos[$i][1], 4, 4, $hBrush)
Next
$Hex += $DurchlaufZahl
_GDIPlus_BrushSetSolidColor($hBrush, '0x' & Hex($Hex, 2) & $Color)
If $Hex <= 0 Then
_GDIPlus_GraphicsClear($hBuffer, '0xFF000000')
For $i = 0 To $AmountParticles - 1
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][0] = Random(1, 100, 1) / 50
EndIf
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][1] = Random(1, 100, 1) / 50
EndIf
Next
$iX = Random(100, $iGUIWidth-100, 1)
$iY = Random(100, $iGUIHeight-100, 1)
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] = $iX
$ParticlesPos[$i][1] = $iY
Next
$DurchlaufZahl = -1.5
$Hex = 255
$Color = _RandomColor()
EndIf
$DurchlaufZahl -= 0.01
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, @DesktopWidth / 2 - $iGUIWidth / 2, @DesktopHeight / 2 - $iGUIHeight / 2, $iGUIWidth, $iGUIHeight)
WEnd
Func _Exit()
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
Func _RandomColor()
Local $BackColor[3]
$BackColor[0] = Random(70, 255, 1)
$BackColor[1] = Random(70, 255, 1)
$BackColor[2] = Random(70, 255, 1)
Return Hex(_ColorSetRGB($BackColor), 6)
EndFunc ;==>_RandomColor
//Edit: Dann noch die "XP Version", für die, bei denen es ruckelt
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <Color.au3>
Opt("GuiOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $iGUIHeight = 800
Global $iGUIWidth = 800
Global $iX = 400
Global $iY = 400
Global $AmountParticles = 40
Global $ParticlesPos[$AmountParticles][2]
Global $ParticlesWay[$AmountParticles][2]
Global $DurchlaufZahl = -1.5
Global $Hex = 255
Global $Color = _RandomColor()
For $i = 0 To $AmountParticles - 1
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][0] = Random(1, 100, 1) / 50
EndIf
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][1] = Random(1, 100, 1) / 50
EndIf
Next
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] = ($iX - $ParticlesWay[$i][0])
$ParticlesPos[$i][1] = ($iY + $ParticlesWay[$i][1])
Next
Global $hGUI = GUICreate("Partikelexplosion by ClezZ", $iGUIWidth, $iGUIHeight)
GUISetState()
WinSetTrans($hGUI,"",0xFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphics)
Global $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
_GDIPlus_GraphicsClear($hBuffer, 0xFF000000)
Global $hBrush = _GDIPlus_BrushCreateSolid('0xFF' & $Color)
_WM_PAINT()
[/autoit] [autoit][/autoit] [autoit]AdlibRegister("_ParticleDraw", 19)
[/autoit] [autoit][/autoit] [autoit]While 1
WEnd
Func _ParticleDraw()
_GDIPlus_GraphicsClear($hBuffer, '0x'&Hex(50, 2)&'000000')
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] += $ParticlesWay[$i][0] / $DurchlaufZahl
$ParticlesPos[$i][1] += $ParticlesWay[$i][1] / $DurchlaufZahl
_GDIPlus_GraphicsFillEllipse($hBuffer, $ParticlesPos[$i][0], $ParticlesPos[$i][1], 4, 4, $hBrush)
Next
$Hex += $DurchlaufZahl
_GDIPlus_BrushSetSolidColor($hBrush, '0x' & Hex($Hex, 2) & $Color)
If $Hex <= 0 Then
_GDIPlus_GraphicsClear($hBuffer, '0xFF000000')
For $i = 0 To $AmountParticles - 1
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][0] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][0] = Random(1, 100, 1) / 50
EndIf
$Random = Random(1, 2, 1)
If $Random = 1 Then
$ParticlesWay[$i][1] = -Random(1, 100, 1) / 50
Else
$ParticlesWay[$i][1] = Random(1, 100, 1) / 50
EndIf
Next
$iX = Random(100, $iGUIWidth-100, 1)
$iY = Random(100, $iGUIHeight-100, 1)
For $i = 0 To $AmountParticles - 1
$ParticlesPos[$i][0] = $iX
$ParticlesPos[$i][1] = $iY
Next
$DurchlaufZahl = -1.5
$Hex = 255
$Color = _RandomColor()
EndIf
$DurchlaufZahl -= 0.01
[/autoit] [autoit][/autoit] [autoit]_WM_PAINT()
EndFunc ;==>_ParticleDraw
Func _Exit()
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
Func _WM_PAINT()
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
EndFunc ;==>_WM_PAINT
Func _RandomColor()
Local $BackColor[3]
$BackColor[0] = Random(70, 255, 1)
$BackColor[1] = Random(70, 255, 1)
$BackColor[2] = Random(70, 255, 1)
Return Hex(_ColorSetRGB($BackColor), 6)
EndFunc ;==>_RandomColor