Sign in to follow this  
Followers 0
smashly

GDI_Star

17 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Edited by rasim

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Really nice work!

Going to use this as my screensaver :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Like the all other responses, IT IS COOL!!! :)


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Wonderfull star, wooooow =)

nice work, respekt!

Mfg Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

That was actually pretty cool. Not what I was expecting.

Share this post


Link to post
Share on other sites

Very cool!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

brings me memory's above from the early computer times !

very well done !!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0