Jump to content

Recommended Posts

Posted

Hi, boredom made me do it

#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>

Global $GuiSize = 500, $LastGrid

$hWnd = GUICreate("GDI Star", $GuiSize, $GuiSize)
GUISetBkColor(0x0)
GUISetState()

While (Not _IsPressed("1B"))
    $sColor = Random(0xff000000, 0xffffff00, 1)
    $sSpeed = Random(1, 5, 1)
    $WGCS = WinGetClientSize($hWnd)
    Do
       Global $sGrid = Random(3, Round($WGCS[1] / 4), 1)
    Until (Not Mod($WGCS[1] / 2, $sGrid) And $sGrid <> $LastGrid)
    $LastGrid = $sGrid
    $iDirection = Random(1, 2, 1)
    GDIPlus_Star($hWnd, $sGrid, $sSpeed, $sColor, $iDirection)
    Sleep(50)
Wend

Func GDIPlus_Star($hWnd, $sGrid = 10, $sSpeed = 0, $sColor = 0xFF00FF00, $iDirection = 1)
    Local $WGCS = WinGetClientSize($hWnd)
    Local $hGraphic, $hPen, $sy = 0, $ex = ($WGCS[1] / 2), $ds = 1
    _GDIPlus_Startup ()
    $hPen = _GDIPlus_PenCreate($sColor)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd)
    While ($ds <> 0) 
        If _IsPressed("1B") Or GUIGetMsg() = -3 Then Exit
        Sleep($sSpeed)
        _GDIPlus_GraphicsDrawLine ($hGraphic, $WGCS[1] / 2, $sy, $ex, $WGCS[1] / 2, $hPen)

        If $ds < 3 Then $sy += $sGrid 
        If $ds > 2 Then $sy -= $sGrid   
        Switch $ds
            Case 1
                If $sy = ($WGCS[1] / 2) Then $ds = 2
                If $iDirection = 1 Then $ex += $sGrid
                If $iDirection = 2 Then $ex -= $sGrid
            Case 2
                If $sy = $WGCS[1] Then $ds = 3
                If $iDirection = 2 Then $ex += $sGrid
                If $iDirection = 1 Then $ex -= $sGrid               
            Case 3
                If $sy = ($WGCS[1] / 2) Then $ds = 4
                If $iDirection = 2 Then $ex += $sGrid
                If $iDirection = 1 Then $ex -= $sGrid
            Case 4
                If $sy = 0 Then $ds = 0
                If $iDirection = 1 Then $ex += $sGrid
                If $iDirection = 2 Then $ex -= $sGrid
        EndSwitch
    Wend   
    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()
EndFunc

Cheers

Posted (edited)

I shocked! ;) Excellent! Very nice! Thank you for this super example, I did not know this :)

Edited by rasim
Posted

Hi,

yeah looks good. Took a while to get the maths working, I guess.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted

very impressive. its soo pretty i can't take my eyes away from it. i have to cut my post short, i need to go look at it some more :)

Posted

Believe it or not , I did get tired of watching it.

So I grabbed another window on my desktop and continued to drag the window up and down in front of the display. It's quite mesmerizing.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...