Schon wieder grafische Spielereien ;)

  • Hi

    Hier zwei Zeitvertreib-Scripte:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{ESC}", "_Exit")

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWin = _Win_Create(0, 0, @DesktopWidth, @DesktopHeight)
    Global $aTxt = _Text_Create("AutoIt", @DesktopWidth, @DesktopHeight, 600)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While Sleep(10)
    _GDIPlus_GraphicsClear($tWin.GFX, 0)
    ;_GDIPlus_GraphicsClear($tWin.GFX, 0xFF000000)
    _Text_Draw($tWin.GFX, $aTxt)
    _Win_Draw($tWin)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Text_Draw($hGfx, ByRef $aTxt, $fStep = 0.04)
    If Not IsArray($aTxt) Then Return

    [/autoit] [autoit][/autoit] [autoit]

    Local Const $c2PI = ATan(1) * 8

    [/autoit] [autoit][/autoit] [autoit]

    $aTxt[0][1] -= $fStep
    If $aTxt[0][1] < 0 Then $aTxt[0][1] += $c2PI

    [/autoit] [autoit][/autoit] [autoit]

    Local $iGfx = _GDIPlus_GraphicsSave($hGfx)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hPen = _GDIPlus_PenCreate(0, 1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $iTW = $aTxt[0][4] - 1, $iTH = $aTxt[0][5] - 1
    Local $fT, $fX, $fY, $fA, $fS
    For $i = 1 To $aTxt[0][0]
    _GDIPlus_PenSetColor($hPen, $aTxt[$i][3])

    [/autoit] [autoit][/autoit] [autoit]

    $fT = Sin($aTxt[0][1] + $aTxt[$i][2]) + 1
    $fT *= 0.501
    If $fT > 1 Then $fT = 1

    [/autoit] [autoit][/autoit] [autoit]

    Switch $fT
    Case 1
    _GDIPlus_GraphicsDrawRect($hGfx, $aTxt[$i][0], $aTxt[$i][1], $iTW, $iTH, $hPen)
    $aTxt[$i][4] = Random(0, $aTxt[0][2])
    $aTxt[$i][5] = Random(0, $aTxt[0][3])
    $aTxt[$i][6] = Random(-720, 720)
    $aTxt[$i][7] = Random(0.1, 2)

    [/autoit] [autoit][/autoit] [autoit]

    Case Else
    $fX = $aTxt[$i][4] + ($aTxt[$i][0] - $aTxt[$i][4]) * $fT
    $fY = $aTxt[$i][5] + ($aTxt[$i][1] - $aTxt[$i][5]) * $fT
    $fA = $aTxt[$i][6] * (1 - $fT)
    $fS = $aTxt[$i][7] + (1 - $aTxt[$i][7]) * $fT

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsTranslateTransform($hGfx, $fX, $fY, True)
    _GDIPlus_GraphicsRotateTransform($hGfx, $fA)
    _GDIPlus_GraphicsScaleTransform($hGfx, $fS, $fS)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iTW, $iTH, $hPen)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsResetTransform($hGfx)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsRestore($hGfx, $iGfx)
    EndFunc ;==>_Text_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Text_Create($sText, $iRW, $iRH, $iW, $iH = -1, $iCntY = 14, $sFont = "Courier New", $fSizeF = 0.9)
    Local $fTxtH = Ceiling(($iCntY - 1) * $fSizeF)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $tLayout = _GDIPlus_RectFCreate()
    _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, 100, 0)
    _GDIPlus_FontFamilyDispose($hFamily)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aBnd = _GDIPlus_PathGetWorldBounds($hPath)
    Local $fScale = ($fTxtH * $fSizeF) / $aBnd[3]
    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBnd[0], -($aBnd[1] + $aBnd[3] * 0.5))
    _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale, True)
    _GDIPlus_MatrixTranslate($hMatrix, 1, ($iCntY - 1) * 0.5, True)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    $aBnd = _GDIPlus_PathGetWorldBounds($hPath)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tBmp = DllStructCreate("int W; int H; int Stride; uint PX[" & Ceiling($aBnd[2] + 4) * $iCntY & "];")
    $tBmp.W = Ceiling($aBnd[2]) + 4
    $tBmp.H = $iCntY
    $tBmp.Stride = $tBmp.W * 4
    Local $hBmp = _GDIPlus_BitmapCreateFromScan0($tBmp.W, $tBmp.H, $GDIP_PXF32ARGB, $tBmp.Stride, DllStructGetPtr($tBmp, "PX"))

    [/autoit] [autoit][/autoit] [autoit]

    Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 2)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hBrush = _GDIPlus_LineBrushCreate($aBnd[0], $aBnd[1], $aBnd[0] + $aBnd[2], $aBnd[1], 0, 0, 3)
    Local $aBlends[7][2] = [[6, 0],[0xFFFF0000, 0],[0xFFFFFF00, 0.2],[0xFF00FF00, 0.4],[0xFF00FFFF, 0.6],[0xFF0000FF, 0.8],[0xFFFF00FF, 1]]
    _GDIPlus_LineBrushSetPresetBlend($hBrush, $aBlends)
    _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hPen = _GDIPlus_PenCreate2($hBrush)
    _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_PathDispose($hPath)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $iTW = Ceiling($iW / $tBmp.W), $iTH
    If $iH > 1 Then
    $iTH = Floor($iH / $tBmp.H)
    Else
    $iTH = $iTW
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $iCnt = $tBmp.W * $tBmp.H
    Local $aTxt[$iCnt + 1][8] ;0=X 1=Y 2=Off 3=Color 4=SrcX 5=SrcY 6=SrcAngle 7=SrcScale
    $aTxt[0][1] = ATan(1) * 6
    $aTxt[0][2] = $iRW
    $aTxt[0][3] = $iRH
    $aTxt[0][4] = $iTW
    $aTxt[0][5] = $iTH

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $iIdx, $iOff, $iC
    Local $fX, $fY
    Local $fCX = $iRW * 0.5 - $iTW * ($tBmp.W * 0.5)
    Local $fCY = $iRH * 0.5 - $iTH * ($tBmp.H * 0.5)

    [/autoit] [autoit][/autoit] [autoit]

    Local Const $cXPI = ATan(1) * 1.2
    Local Const $cYPI = ATan(1) * 0.3

    [/autoit] [autoit][/autoit] [autoit]

    $iCnt = 0
    For $y = 0 To $tBmp.H - 1
    $fY = $y * $iTH
    $iOff = $y * $tBmp.W
    For $x = 0 To $tBmp.W - 1
    $fX = $x * $iTW
    $iIdx = $iOff + $x + 1
    $iC = $tBmp.PX(($iIdx))
    If $iC < 0x10000000 Then ContinueLoop

    [/autoit] [autoit][/autoit] [autoit]

    $iCnt += 1
    $aTxt[$iCnt][0] = $fX + $fCX
    $aTxt[$iCnt][1] = $fY + $fCY
    $aTxt[$iCnt][2] = ($cXPI * $x / $tBmp.W) + ($cYPI * $y / $tBmp.H)
    $aTxt[$iCnt][3] = $iC

    [/autoit] [autoit][/autoit] [autoit]

    $aTxt[$iCnt][4] = Random(0, $iRW)
    $aTxt[$iCnt][5] = Random(0, $iRH)
    $aTxt[$iCnt][6] = Random(-360, 360)
    $aTxt[$iCnt][7] = Random(0.1, 2)
    Next
    Next
    $aTxt[0][0] = $iCnt

    [/autoit] [autoit][/autoit] [autoit]

    Return $aTxt
    EndFunc ;==>_Text_Create

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Win_Create($iX, $iY, $iW, $iH)
    Local $tWin = DllStructCreate("int X; int Y; int W; int H; hwnd Gui; hwnd DC; handle GFX; handle BMP; hwnd CDC; hwnd OBJ; int Src[2]; byte Blend[4];")

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.Blend(3) = 0xFF
    $tWin.Blend(4) = 1
    $tWin.X = $iX
    $tWin.Y = $iY
    $tWin.W = $iW
    $tWin.H = $iH

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.Gui = GUICreate("", $iW, $iH, $iX, $iY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.DC = _WinAPI_GetDC($tWin.Gui)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hBmp = _WinAPI_CreateBitmap($iW, $iH)
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
    _WinAPI_DeleteObject($hBmp)

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.BMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.CDC = _WinAPI_CreateCompatibleDC($tWin.DC)
    $tWin.OBJ = _WinAPI_SelectObject($tWin.CDC, $tWin.BMP)

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.GFX = _GDIPlus_GraphicsCreateFromHDC($tWin.CDC)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOWNOACTIVATE, $tWin.Gui)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tWin
    EndFunc ;==>_Win_Create

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Win_Draw(ByRef $tWin)
    If Not IsDllStruct($tWin) Then Return
    _WinAPI_UpdateLayeredWindow($tWin.Gui, $tWin.DC, DllStructGetPtr($tWin, "X"), DllStructGetPtr($tWin, "W"), $tWin.CDC, DllStructGetPtr($tWin, "Src"), 0, DllStructGetPtr($tWin, "Blend"), 2)
    EndFunc ;==>_Win_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Win_Dispose(ByRef $tWin)
    If Not IsDllStruct($tWin) Then Return

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($tWin.GFX)
    _WinAPI_SelectObject($tWin.CDC, $tWin.OBJ)
    _WinAPI_DeleteObject($tWin.BMP)
    _WinAPI_DeleteDC($tWin.CDC)
    _WinAPI_ReleaseDC($tWin.Gui, $tWin.DC)
    GUIDelete($tWin.Gui)
    $tWin = 0
    EndFunc ;==>_Win_Dispose

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _Win_Dispose($tWin)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]
    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <ScreenCapture.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{ESC}", "_Exit")

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hBMP = _ScreenCapture_Capture("", 0, 0, -1, -1, False)
    Global $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    _WinAPI_DeleteObject($hBMP)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWin = _Win_Create(0, 0, @DesktopWidth, @DesktopHeight)

    [/autoit] [autoit][/autoit] [autoit]

    ToolTip("please wait...")
    Global $tBRK = _BRK_Create($hImage)
    _BRK_Shuffle($tBRK)
    ToolTip("")

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ShowCursor(False)
    Global $iTimer = TimerInit()
    While 1
    If TimerDiff($iTimer) > 20 Then
    $iTimer = TimerInit()
    _BRK_Calc($tBRK)
    _BRK_Draw($tWin.Gfx, $tBRK)
    _Win_Draw($tWin)
    Else
    Sleep(1)
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BRK_Calc(ByRef $tBRK, $fIntv = 0.8, $iWait = 20)
    If Not IsDllStruct($tBRK) Then Return

    [/autoit] [autoit][/autoit] [autoit]

    Local Static $iStep = 0
    $iStep += 1

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix
    For $i = 1 To $tBRK.Cnt
    If $iStep > $i * $fIntv + $iWait Then
    If $tBRK.Scale(($i)) > 0.8 Then
    $tBRK.Scale(($i)) *= 0.996
    $hMatrix = _GDIPlus_MatrixClone($tBRK.MX(($i)))

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixInvert($hMatrix)
    _GDIPlus_MatrixMultiply($tBRK.MX(($i)), $hMatrix)
    _GDIPlus_MatrixTranslate($tBRK.MX(($i)), -$tBRK.W * 0.5, -$tBRK.H * 0.5, True)
    _GDIPlus_MatrixScale($tBRK.MX(($i)), $tBRK.Scale(($i)), $tBRK.Scale(($i)), True)
    _GDIPlus_MatrixRotate($tBRK.MX(($i)), $tBRK.Rotate(($i)), True)
    _GDIPlus_MatrixTranslate($tBRK.MX(($i)), $tBRK.W * 0.5, $tBRK.H * 0.5, True)
    _GDIPlus_MatrixInvert($hMatrix)
    _GDIPlus_MatrixMultiply($tBRK.MX(($i)), $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    EndIf
    Next
    EndFunc ;==>_BRK_Calc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BRK_Shuffle(ByRef $tBRK)
    Local $iIdx, $Val
    For $i = 1 To $tBRK.Cnt
    $iIdx = Random(1, $tBRK.Cnt, 1)
    If $iIdx = $i Then ContinueLoop

    [/autoit] [autoit][/autoit] [autoit]

    $Val = $tBRK.BMP(($i))
    $tBRK.BMP(($i)) = $tBRK.BMP(($iIdx))
    $tBRK.BMP(($iIdx)) = $Val

    [/autoit] [autoit][/autoit] [autoit]

    $Val = $tBRK.MX(($i))
    $tBRK.MX(($i)) = $tBRK.MX(($iIdx))
    $tBRK.MX(($iIdx)) = $Val

    [/autoit] [autoit][/autoit] [autoit]

    $Val = $tBRK.Rotate(($i))
    $tBRK.Rotate(($i)) = $tBRK.Rotate(($iIdx))
    $tBRK.Rotate(($iIdx)) = $Val

    [/autoit] [autoit][/autoit] [autoit]

    $Val = $tBRK.Scale(($i))
    $tBRK.Scale(($i)) = $tBRK.Scale(($iIdx))
    $tBRK.Scale(($iIdx)) = $Val

    [/autoit] [autoit][/autoit] [autoit]

    Next
    EndFunc ;==>_BRK_Shuffle

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BRK_Draw($hGfx, ByRef $tBRK)
    If Not IsDllStruct($tBRK) Then Return
    Local $iGfx = _GDIPlus_GraphicsSave($hGfx)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsSetInterpolationMode($hGfx, 5)
    _GDIPlus_GraphicsClear($hGfx, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hImgAttr = _GDIPlus_ImageAttributesCreate()
    Local $tColorMX = _GDIPlus_ColorMatrixCreateScale(1, 1, 1, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aMX, $iImgW, $iImgH, $fCM
    For $i = 1 To $tBRK.Cnt
    If $tBRK.Scale(($i)) > 0.8 Then
    _GDIPlus_GraphicsSetTransform($hGfx, $tBRK.MX(($i)))
    $iImgW = _GDIPlus_ImageGetWidth($tBRK.BMP(($i)))
    $iImgH = _GDIPlus_ImageGetHeight($tBRK.BMP(($i)))

    [/autoit] [autoit][/autoit] [autoit]

    If $tBRK.Scale(($i)) >= 1 Then
    _GDIPlus_GraphicsDrawImage($hGfx, $tBRK.BMP(($i)), 0, 0)
    Else
    $fCM = $tBRK.Scale(($i)) ^ 16
    $tColorMX.m(1) = $fCM
    $tColorMX.m(7) = $fCM
    $tColorMX.m(13) = $fCM

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_ImageAttributesSetColorMatrix($hImgAttr, 0, True, $tColorMX)
    _GDIPlus_GraphicsDrawImageRectRect($hGfx, $tBRK.BMP(($i)), 0, 0, $iImgW, $iImgH, 0, 0, $iImgW, $iImgH, $hImgAttr)
    EndIf
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_ImageAttributesDispose($hImgAttr)
    _GDIPlus_GraphicsRestore($hGfx, $iGfx)
    EndFunc ;==>_BRK_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BRK_Create($hImage, $iSphr = 12, $iSplt = 20, $iColor = 0xFF001122)
    Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iImgW = _GDIPlus_ImageGetWidth($hImage)
    Local $iImgH = _GDIPlus_ImageGetHeight($hImage)
    Local $fCX = $iImgW * 0.5
    Local $fCY = $iImgH * 0.5

    [/autoit] [autoit][/autoit] [autoit]

    Local $hRegion = _GDIPlus_RegionCreate()
    Local $hRegion1
    Local $hPath = _GDIPlus_PathCreate()
    Local $hPen = _GDIPlus_PenCreate($iColor, 2)

    [/autoit] [autoit][/autoit] [autoit]

    Local Const $cPI2 = ATan(1) * 8

    [/autoit] [autoit][/autoit] [autoit]

    Local $tPoly = DllStructCreate("float Pnt[6];")
    $tPoly.Pnt(1) = $fCX
    $tPoly.Pnt(2) = $fCY

    [/autoit] [autoit][/autoit] [autoit]

    Local $fSize = $iImgW > $iImgH ? $iImgW * 1.5 : $iImgH * 1.5

    [/autoit] [autoit][/autoit] [autoit]

    Local $fX, $fY, $fR, $fAS, $fA1, $fA2 = 0, $aBnd
    Local $iMax = ($iSplt + $iSphr) * $iSphr

    [/autoit] [autoit][/autoit] [autoit]

    Local $tBRK = DllStructCreate("int Cnt; int W; int H; handle BMP[" & $iMax & "]; handle MX[" & $iMax & "]; float Rotate[" & $iMax & "]; float Scale[" & $iMax & "];")
    $tBRK.W = $iImgW
    $tBRK.H = $iImgH

    [/autoit] [autoit][/autoit] [autoit]

    Local $fAInc = $cPI2 / $iSplt
    Local $fS, $hCtx

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $iSphr
    $fAInc = $cPI2 / ($iSplt + $i)

    [/autoit] [autoit][/autoit] [autoit]

    $fS = $fSize / $iSphr * $i

    [/autoit] [autoit][/autoit] [autoit]

    $fAS = Random(0, $cPI2)
    $fA1 = $fAS
    $fAS += $cPI2
    $fA2 = 0

    [/autoit] [autoit][/autoit] [autoit]

    While $fA2 < $fAS
    $fA2 = $fA1 + Random($fAInc * 0.8, $fAInc * 1.2)
    If $fA2 > $fAS Then $fA2 = $fAS

    [/autoit] [autoit][/autoit] [autoit]

    $fR = Random($fS * 0.6, $fS * 1.4) * 0.5
    $tPoly.Pnt(3) = Cos($fA1) * $fR + $fCX
    $tPoly.Pnt(4) = Sin($fA1) * $fR + $fCY

    [/autoit] [autoit][/autoit] [autoit]

    $fR = Random($fS * 0.6, $fS * 1.4) * 0.5
    $tPoly.Pnt(5) = Cos($fA2 + 0.01) * $fR + $fCX
    $tPoly.Pnt(6) = Sin($fA2 + 0.01) * $fR + $fCY

    [/autoit] [autoit][/autoit] [autoit]

    $fA1 = $fA2

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathReset($hPath)
    DllCall($ghGDIPDll, "int", "GdipAddPathPolygon", "handle", $hPath, "struct*", $tPoly, "int", 3)

    [/autoit] [autoit][/autoit] [autoit]

    $hRegion1 = _GDIPlus_RegionClone($hRegion)
    _GDIPlus_RegionCombinePath($hRegion1, $hPath, 1)

    [/autoit] [autoit][/autoit] [autoit]

    $aBnd = _GDIPlus_RegionGetBounds($hRegion1, $hGfx)
    If Not IsArray($aBnd) Then
    _GDIPlus_RegionDispose($hRegion1)
    ContinueLoop
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If ($aBnd[2] < 2) Or ($aBnd[3] < 2) Or ($aBnd[0] > $iImgW) Or ($aBnd[1] > $iImgH) Or ($aBnd[0] + $aBnd[2] < 0) Or ($aBnd[1] + $aBnd[3] < 0) Then ContinueLoop

    [/autoit] [autoit][/autoit] [autoit]

    $tBRK.Cnt += 1
    $tBRK.BMP(($tBRK.Cnt)) = _GDIPlus_BitmapCreateFromScan0($aBnd[2], $aBnd[3])
    $hCtx = _GDIPlus_ImageGetGraphicsContext($tBRK.BMP(($tBRK.Cnt)))
    _GDIPlus_GraphicsSetSmoothingMode($hCtx, 2)
    $tBRK.MX(($tBRK.Cnt)) = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($tBRK.MX(($tBRK.Cnt)), $aBnd[0], $aBnd[1])

    [/autoit] [autoit][/autoit] [autoit]

    $tBRK.Rotate(($tBRK.Cnt)) = (Random(-$i, $i) + Random(-$i, $i)) / 3
    $tBRK.Scale(($tBRK.Cnt)) = 1.02

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_RegionTranslate($hRegion1, -$aBnd[0], -$aBnd[1])
    _GDIPlus_GraphicsSetClipRegion($hCtx, $hRegion1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImage($hCtx, $hImage, -$aBnd[0], -$aBnd[1])

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsTranslateTransform($hCtx, -$aBnd[0], -$aBnd[1])
    _GDIPlus_GraphicsDrawPath($hCtx, $hPath, $hPen)
    _GDIPlus_GraphicsDispose($hCtx)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_RegionDispose($hRegion1)
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 4)

    [/autoit] [autoit][/autoit] [autoit]

    WEnd
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_GraphicsDispose($hGfx)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tBRK
    EndFunc ;==>_BRK_Create

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BRK_Dispose(ByRef $tBRK)
    If Not IsDllStruct($tBRK) Then Return
    For $i = 1 To $tBRK.Cnt
    _GDIPlus_BitmapDispose($tBRK.BMP(($i)))
    _GDIPlus_MatrixDispose($tBRK.MX(($i)))
    Next
    $tBRK = 0
    EndFunc ;==>_BRK_Dispose

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Win_Dispose(ByRef $tWin)
    If Not IsDllStruct($tWin) Then Return

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($tWin.GFX)
    _WinAPI_SelectObject($tWin.CDC, $tWin.OBJ)
    _WinAPI_DeleteObject($tWin.BMP)
    _WinAPI_DeleteDC($tWin.CDC)
    _WinAPI_ReleaseDC($tWin.Gui, $tWin.DC)
    GUIDelete($tWin.Gui)
    $tWin = 0
    EndFunc ;==>_Win_Dispose

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Win_Create($iX, $iY, $iW, $iH)
    Local $tWin = DllStructCreate("int X; int Y; int W; int H; hwnd Gui; hwnd DC; handle GFX; handle BMP; hwnd CDC; hwnd OBJ; int Src[2]; byte Blend[4];")

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.Blend(3) = 0xFF
    $tWin.Blend(4) = 1
    $tWin.X = $iX
    $tWin.Y = $iY
    $tWin.W = $iW
    $tWin.H = $iH

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.Gui = GUICreate("", $iW, $iH, $iX, $iY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.DC = _WinAPI_GetDC($tWin.Gui)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hBMP = _WinAPI_CreateBitmap($iW, $iH)
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    _WinAPI_DeleteObject($hBMP)

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.BMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.CDC = _WinAPI_CreateCompatibleDC($tWin.DC)
    $tWin.OBJ = _WinAPI_SelectObject($tWin.CDC, $tWin.BMP)

    [/autoit] [autoit][/autoit] [autoit]

    $tWin.GFX = _GDIPlus_GraphicsCreateFromHDC($tWin.CDC)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOWNOACTIVATE, $tWin.Gui)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tWin
    EndFunc ;==>_Win_Create

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Win_Draw(ByRef $tWin)
    If Not IsDllStruct($tWin) Then Return
    _WinAPI_UpdateLayeredWindow($tWin.Gui, $tWin.DC, DllStructGetPtr($tWin, "X"), DllStructGetPtr($tWin, "W"), $tWin.CDC, DllStructGetPtr($tWin, "Src"), 0, DllStructGetPtr($tWin, "Blend"), 2)
    EndFunc ;==>_Win_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_ImageDispose($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ShowCursor(True)

    [/autoit] [autoit][/autoit] [autoit]

    _Win_Dispose($tWin)
    _BRK_Dispose($tBRK)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Das erste Script kommt natürlich besser auf dunklem Hintergrund - bei Bedarf einfach Zeilen 16/17 aus/ein-schalten

    Viel Spaß
    E

  • Wow

    Super gemacht. Vor allem das 2. Script fand ich super.
    (Das erste ist auch nicht von schlechten Eltern ;))

    Ich glaub ich muss mir auch mal die GDI funktionen angucken :D

    Dieser Beitrag wurde 9521 mal editiert, zum letzten Mal von Blubkuh: Morgen, 02:28.

    [autoit]

    If Not $Elephant Then $Irelephant = True

    [/autoit]
  • Echt coole Effekte :thumbup:

    Ich sehe, dass du jetzt die Strukt und somit Punkt Notation bevorzugst. Ist einfacher zu überblicken - sollte ich mir auch angewöhnen. 8o


    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Vielen Dank für´s Feedback :)


    ...Ich sehe, dass du jetzt die Strukt und somit Punkt Notation bevorzugst. Ist einfacher zu überblicken - sollte ich mir auch angewöhnen...

    Ich verwende auch immer öfter Structs anstelle von Arrays, einfach wegen der Übersicht!
    Man kann auch einfach neue Elemente zwischendrin einfügen und muss im restlichen Script nichts anpassen!

    Ein Nachteil ist evtl. dass man einen Variable must be of type "Object" - Error bekommt, wenn man keine gültige Struct hat (=> sauber programmieren ;))

    Einweiterer Vorteil ist die Geschwindigkeit. Besonders das Rechnen mit einzelnen Elementen geht schneller.
    Beim Arbeiten mit Struct-Arrays ist es leider genau umgekehrt... Hier ist DllStructSetData mit Index zu bevorzugen.


    Und wenn es wirklich auf Speed ankommt, und man nicht auf Structs angewiesen ist (Arbeiten mit Dll´s usw...), dann ist ein normales Array trotzdem noch am schnellsten...


    Hier ein Benchmarkscript:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $iStep = 200000
    $tTest = DllStructCreate("int X; float Y; float Pnt[" & $iStep * 2 & "];")
    Local $iTimer, $fTime1, $fTime2, $fTime3
    DllStructSetData($tTest, 1, Random(0, 1000))
    DllStructSetData($tTest, 2, Random(0, 1000))
    For $i = 0 To $iStep - 1
    DllStructSetData($tTest, 3, Random(0, 1000), $i * 2 + 1)
    DllStructSetData($tTest, 3, Random(0, 1000), $i * 2 + 1)
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Wert zuweisen - Element via String
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    DllStructSetData($tTest, "X", $i)
    DllStructSetData($tTest, "Y", $i)
    Next
    $fTime1 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Wert zuweisen - Element via Index
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    DllStructSetData($tTest, 1, $i)
    DllStructSetData($tTest, 2, $i)
    Next
    $fTime2 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Wert zuweisen - Element via Object
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    $tTest.X = $i
    $tTest.Y = $i
    Next
    $fTime3 = TimerDiff($iTimer)
    _Print($fTime1, $fTime2, $fTime3, "write")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $iX, $fY
    ;Wert auslesen - Element via String
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    $iX = DllStructGetData($tTest, "X")
    $fY = DllStructGetData($tTest, "Y")
    Next
    $fTime1 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Wert auslesen - Element via Index
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    $iX = DllStructGetData($tTest, 1)
    $fY = DllStructGetData($tTest, 2)
    Next
    $fTime2 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Wert auslesen - Element via Object
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    $iX = $tTest.X
    $fY = $tTest.Y
    Next
    $fTime3 = TimerDiff($iTimer)
    _Print($fTime1, $fTime2, $fTime3, "read")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Wert manipulieren - Element via String
    $tTest.X = 1
    $tTest.Y = 1
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    DllStructSetData($tTest, "X", DllStructGetData($tTest, "X") + 1)
    DllStructSetData($tTest, "Y", DllStructGetData($tTest, "Y") + 1.1)
    Next
    $fTime1 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Wert manipulieren - Element via Index
    $tTest.X = 1
    $tTest.Y = 1
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    DllStructSetData($tTest, 1, DllStructGetData($tTest, 1) + 1)
    DllStructSetData($tTest, 2, DllStructGetData($tTest, 2) + 1.1)
    Next
    $fTime2 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Wert manipulieren - Element via Object
    $tTest.X = 1
    $tTest.Y = 1
    $iTimer = TimerInit()
    For $i = 1 To $iStep
    $tTest.X += 1
    $tTest.Y += 1.1
    Next
    $fTime3 = TimerDiff($iTimer)
    _Print($fTime1, $fTime2, $fTime3, "add")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Array schreiben - Element via String
    $iTimer = TimerInit()
    For $i = 0 To $iStep - 1
    DllStructSetData($tTest, "Pnt", $i, $i * 2 + 1)
    DllStructSetData($tTest, "Pnt", $i, $i * 2 + 2)
    Next
    $fTime1 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Array schreiben - Element via Index
    $iTimer = TimerInit()
    For $i = 0 To $iStep - 1
    DllStructSetData($tTest, 3, $i, $i * 2 + 1)
    DllStructSetData($tTest, 3, $i, $i * 2 + 2)
    Next
    $fTime2 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Array schreiben - Element via Object
    $iTimer = TimerInit()
    For $i = 0 To $iStep - 1
    $tTest.Pnt(($i * 2 + 1)) = $i
    $tTest.Pnt(($i * 2 + 2)) = $i
    Next
    $fTime3 = TimerDiff($iTimer)
    _Print($fTime1, $fTime2, $fTime3, "write array")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Array lesen - Element via String
    $iTimer = TimerInit()
    For $i = 0 To $iStep - 1
    $iX = DllStructGetData($tTest, "Pnt", $i * 2 + 1)
    $fY = DllStructGetData($tTest, "Pnt", $i * 2 + 2)
    Next
    $fTime1 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Array lesen - Element via Index
    $iTimer = TimerInit()
    For $i = 0 To $iStep - 1
    $iX = DllStructGetData($tTest, 3, $i * 2 + 1)
    $fY = DllStructGetData($tTest, 3, $i * 2 + 2)
    Next
    $fTime2 = TimerDiff($iTimer)

    [/autoit] [autoit][/autoit] [autoit]

    ;Array lesen - Element via Object
    $iTimer = TimerInit()
    For $i = 0 To $iStep - 1
    $iX = $tTest.Pnt(($i * 2 + 1))
    $fY = $tTest.Pnt(($i * 2 + 2))
    Next
    $fTime3 = TimerDiff($iTimer)
    _Print($fTime1, $fTime2, $fTime3, "read array")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Print($fTime1, $fTime2, $fTime3, $sText)
    Local $sTxt1 = $sText & "[string] "
    Local $sTxt2 = $sText & "[index] "
    Local $sTxt3 = $sText & "[object] "

    [/autoit] [autoit][/autoit] [autoit]

    Local $aVal[3][2] = [[$fTime1, 1],[$fTime2, 2],[$fTime3, 3]]
    _ArraySort($aVal)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fMax

    [/autoit] [autoit][/autoit] [autoit]

    If $aVal[0][1] = 1 Then
    $sTxt1 = "> " & $sTxt1
    ElseIf $aVal[1][1] = 1 Then
    $sTxt1 = "- " & $sTxt1
    $fMax = $fTime1
    Else
    $sTxt1 = "! " & $sTxt1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $aVal[0][1] = 2 Then
    $sTxt2 = "> " & $sTxt2
    $fMax = $fTime2
    ElseIf $aVal[1][1] = 2 Then
    $sTxt2 = "- " & $sTxt2
    Else
    $sTxt2 = "! " & $sTxt2
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $aVal[0][1] = 3 Then
    $sTxt3 = "> " & $sTxt3
    $fMax = $fTime3
    ElseIf $aVal[1][1] = 3 Then
    $sTxt3 = "- " & $sTxt3
    Else
    $sTxt3 = "! " & $sTxt3
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite($sTxt1 & " " & StringFormat("%.2f zeit %.2f x langsamer", $fTime1, $fTime1 / $fMax) & @CRLF)
    ConsoleWrite($sTxt2 & " " & StringFormat("%.2f zeit %.2f x langsamer", $fTime2, $fTime2 / $fMax) & @CRLF)
    ConsoleWrite($sTxt3 & " " & StringFormat("%.2f zeit %.2f x langsamer", $fTime3, $fTime3 / $fMax) & @CRLF & @CRLF)
    EndFunc ;==>_Print

    [/autoit]

    E

  • Sehr schönes Script, vor allem das Erste.

    Wie wär es mit:
    - Multi-Monitor Support (mehr als 1 Monitor)
    - Screensaver-Möglichkeit (wenn nach bestimmter Zeit keine Maus- oder Tastatureingabe erfolgt ist, geht das Script an)

    Bitte mehr ;)

  • Spoiler anzeigen


    na klasse, objekt scheint vorne zu liegen, solange man die Daten nicht braucht :rofl:
    Ich bleibe bei den Indexen...

  • Super :)

    Welche Zeilen muss man im 1. Script verändern, damit der Text länger stehen bleibt?

    An welcher Stelle müsste man im 1. Script eine Random-Funktion integrieren, damit die Farben per Zufallsgenerator erstellt werden?

    Wie kann man im 1. Script den Text mehrzeilig anzeigen lassen?

    so funktioniert die Anzeige nicht mehrzeilig

    Global $aTxt = _Text_Create("Autoit" & @CRLF & "eukalyptus", @DesktopWidth, @DesktopHeight, 600)


    Beim 2. Script erhalte ich leider folgende Fehlermeldung:

    Zeile 197

    DllCall($ghGDIPDll, "int", "GdipAddPathPolygon", "handle", $hPath, "struct*", $tPoly, "int", 3)

    warning: $ghGDIPDll: possibly used before declaration.
    DllCall($ghGDIPDll,

    Wisst Ihr, wie ich diesen Fehler beheben kann?

    2 Mal editiert, zuletzt von AutoMit (29. Januar 2016 um 16:59)