Jump to content

3dish - 4point star drawn from lines


LostUser
 Share

Recommended Posts

Valuater and rogdog posted a response about doing gradients using gui graphic controls and I remembered something some my friends and I used to do. Maybe the code could be cleaned up but here it is.

#include <GUIConstants.au3>

;The Width and Height need to be evenly divisible by GridWidth and Height otherwise it will go wonky
;The sleep command can be remarked out but I have it there because I like to watch it get drawn
$gui = GUICreate("Gradient",@DesktopWidth-8,@DesktopHeight-32)
; width,height(full size of star),GridWidth,GridHeight,(the separation between lines) StartX,StartY,(starting top location of star)
$FPS= FourPointStar($gui, 400,400,10,10,500,200)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit
Wend


Func FourPointStar($StarGUI,$nStarWidth,$nStarHeight,$nGridWidth,$nGridHeight,$nStartX,$nStartY)
    $nWinSize = WinGetClientSize($StarGUI)
    Local $nX = 0, $nY = 0
    Local $nXdir = 1, $nYdir = 1
    Local $nWSizeX = $nWinSize[0], $nWSizeY = $nWinSize[1]
;   Local $nLineLen = 50
    $DrawFlg=1
    $nStarGraphic = GUICtrlCreateGraphic($nX,$nY,$nWSizeX,$nWSizeY)
    $nX = $nStartX
    $nY = $nStartY
    GUISetState()
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000ff, 0xffffff)
    While $DrawFlg = 1
        If $nY = $nStartY + $nStarHeight/2  Then $nXdir = $nXdir * -1
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $nStartX, $nY)
;       ConsoleWrite($nX & ", " & $nY & ", " & $nXdir & ", " & $nYdir & @CRLF)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nX, $nStartY + $nStarHeight/2)
    ;Changes the direction of the y point when it hits the bottom
        $nX = $nX + ($nGridWidth * $nXdir)
        $nY = $nY + ($nGridHeight * $nYdir)
        If $nY >= $nStarHeight + $nStartY Then $nYdir = -1
        If $nY = $nStartY Then $DrawFlg = 0     
        Sleep(20)
        GUICtrlSetState( $nStarGraphic, $GUI_SHOW)
    WEnd

    Return $nStarGraphic

EndFunc

Enjoy, see you later.

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
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
 Share

  • Recently Browsing   0 members

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