Hohoho,
Da wir gerade Weihnachten und ggf. bald auch etwas Schnee haben gibt es hier ein Skript mit dem man Schneeflocken generieren kann (die man villeicht in irgendwelchen anderen Skripten verwenden könnte). Von diesen Generatoren gibt es bestimmt schon tausende, jetzt gibt es noch einen mehr
Code
#include <GDIPlus.au3>
; Snowflake Settings
Global Const $iSize = 400 ; Größe des Resultats in Pixeln
Global Const $fPointRadius = 4 ; Radius der Punkte. Kleiner -> Feiner. Normal ist irgendwas zwischen 4 und 8
Global Const $fSpread = 1 ; Wie chaotisch soll die Flocke aussehen? normal ist 0.5 bis 1
; GUI Settings
Global Const $sTitle = 'Snowflake'
Global Const $iW = $iSize > 512 ? $iSize : 512
Global Const $iH = $iSize > 512 ? $iSize : 512
_GDIPlus_Startup()
Global $hGUI = GUICreate($sTitle, $iW, $iH)
Global $hGFX_GUI = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Global $hBMP_GUI = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGFX_GUI)
Global $hBUF_GUI = _GDIPlus_ImageGetGraphicsContext($hBMP_GUI)
Global $hFLA = Snowflake($iSize, $fPointRadius, $fSpread)
OnAutoItExitRegister(Xit)
GUISetState(@SW_SHOW, $hGUI)
While GUIGetMsg() <> -3
_GDIPlus_GraphicsClear($hBUF_GUI, 0xFF000000)
_GDIPlus_GraphicsDrawImageRect($hBUF_GUI, $hFLA, $iW / 2 - $iSize / 2, $iH / 2 - $iSize / 2, $iSize, $iSize)
_GDIPlus_GraphicsDrawImageRect($hGFX_GUI, $hBMP_GUI, 0, 0, $iW, $iH)
Refresh()
WEnd
Func Refresh()
Local Static $t = TimerInit()
If TimerDiff($t) < 2000 Then Return
$t = TimerInit()
_GDIPlus_BitmapDispose($hFLA)
$hFLA = Snowflake($iSize, $fPointRadius, $fSpread)
EndFunc
Func Snowflake($iSize, $iPointRadius = 4, $fSpread = 0.5)
Local $hBMP = _GDIPlus_BitmapCreateFromScan0($iSize, $iSize)
Local $hGFX = _GDIPlus_ImageGetGraphicsContext($hBMP)
Local $hBRU = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
_GDIPlus_GraphicsSetSmoothingMode($hGFX, 2)
_GDIPlus_GraphicsClear($hGFX, 0xFF000000)
Local $aPoint = [$iSize / 2, $iSize / 2], $aTmp[2]
Local $n = 0
For $ii = 0 To 9999 Step 1 ; Eigentlich braucht man hier keine Abbruchbedingung... falls man SEHR GROßE Flocken will muss man hier hochschrauben.
$n = 0
$aPoint[0] = $iSize / 2
$aPoint[1] = 0
While $aPoint[0] > 1
$n += 1
$aPoint[0] -= $iPointRadius/3
$aPoint[1] += Random(-1, 1) * $iPointRadius*$fSpread
$aTmp[0] = $aPoint[0] + $iSize / 2
$aTmp[1] = $aPoint[1] + $iSize / 2
If Hex(_GDIPlus_BitmapGetPixel($hBMP, $aTmp[0], $aTmp[1]), 8) <> 'FF000000' Then ExitLoop
WEnd
For $i = 0 To 5 Step 1
_GDIPlus_GraphicsFillEllipse($hGFX, $aTmp[0] - $iPointRadius / 2, $aTmp[1] - $iPointRadius / 2, $iPointRadius, $iPointRadius, $hBRU)
_GDIPlus_GraphicsFillEllipse($hGFX, $aTmp[0] - $iPointRadius / 2, ($iSize - $aTmp[1]) - $iPointRadius / 2, $iPointRadius, $iPointRadius, $hBRU)
Rotate($aTmp, $iSize/2, $iSize/2, 60)
Next
If $n < 4 Then ExitLoop
Next
;~ ConsoleWrite($ii & @CRLF)
_GDIPlus_BrushDispose($hBRU)
_GDIPlus_GraphicsDispose($hGFX)
Return $hBMP
EndFunc ;==>Snowflake
Func Rotate(ByRef $aPoint, $mX, $mY, $nDegAngle)
Local $x, $fAngle = $nDegAngle / 180 * 3.141593
$x = $mX + Cos($fAngle) * ($aPoint[0] - $mX) - Sin($fAngle) * ($aPoint[1] - $mY)
$aPoint[1] = $mY + Sin($fAngle) * ($aPoint[0] - $mX) + Cos($fAngle) * ($aPoint[1] - $mY)
$aPoint[0] = $x
EndFunc
Func Xit()
_GDIPlus_BitmapDispose($hFLA)
_GDIPlus_GraphicsDispose($hBUF_GUI)
_GDIPlus_BitmapDispose($hBMP_GUI)
_GDIPlus_GraphicsDispose($hGFX_GUI)
_GDIPlus_Shutdown()
EndFunc ;==>Xit
Alles anzeigen
lg
M