Sign in to follow this  
Followers 0
JoHanatCent

Draw 5 Point Star

4 posts in this topic

Created because:

* Wanted to see if I can

* Can I use percentadges to control size?

* Visualization of the Random function

* Wanted to see if this can waist other peoples time as well

* See some reaction from other users.

;================================= * = * = * = * = * = * ===========================================================
#NoTrayIcon
SRandom(@AutoItPID)

WinMinimizeAll ()
HotKeySet("{ESC}", "OntSnap"); ==  *   *   *  == To stop the program
$lengte = 450
Dim $x0ne, $yone, $xtwo, $ytwo, $line, $Slaap, $LineColor, $LineWidth
While "Creating the Stars"
$Slaap = Random(1, 1000, 1)
    $lengte = Random(50, 450, 1)
    $LineWidth = Random(2, 20, 1)
    $x0ne = Random(10, @DesktopWidth - $lengte / 3, 1)
    Sleep($Slaap)
    $yone = Random(-1, @DesktopHeight - $lengte / 3, 1)
    $xtwo = $x0ne + $lengte * .328
    $ytwo = $yone + $lengte * .955
    $LineColor = Random(0x000000, 0xFFFFFF, 1)
    DrawALine()
    $x0ne = $x0ne - $lengte * .507
    $yone = $yone + $lengte * .373
    Sleep($Slaap)
    DrawALine()
    $xtwo = $xtwo + $lengte * .164
    $ytwo = $ytwo - $lengte * .582
    Sleep($Slaap)
    DrawALine()
    $x0ne = $x0ne + $lengte * .179
    $yone = $yone + $lengte * .582
    Sleep($Slaap)
    DrawALine()
    $xtwo = $xtwo - $lengte * .492
    $ytwo = $ytwo - $lengte * .373
    Sleep($Slaap)
    DrawALine()
    Sleep($Slaap)
WEnd
Func DrawALine()
    $hnd = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    $pen = DllCall("gdi32.dll", "int", "CreatePen", "int", 0, "int", $LineWidth, "int", $LineColor)
    DllCall("gdi32.dll", "int", "SelectObject", "int", $hnd[0], "int", $pen[0])
    DllCall("GDI32.dll", "int", "MoveToEx", "hwnd", $hnd[0], "int", $x0ne, "int", $yone, "int", 0)
    DllCall("GDI32.dll", "int", "LineTo", "hwnd", $hnd[0], "int", $xtwo, "int", $ytwo)
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $hnd[0])
EndFunc   ;==>DrawALine
Func OntSnap()
    WinMinimizeAllUndo ( )
    Exit
EndFunc   ;==>OntSnap
;================================= * = * = * = * = * = * ===========================================================

Share this post


Link to post
Share on other sites



It's funny ! Posted Image

That's a lot of beautiful stars for the holidays of year-end ! Posted Image

Thanks.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

@wakillon - You are welcome.

@least I could bring joy to one person this year.


Share this post


Link to post
Share on other sites

Thanks.

For me, it's a quite good example to start learning "DllCall" & "DC".

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