Lakes Posted March 29, 2006 Share Posted March 29, 2006 I know this outside the bounds of Autoit as a Scripting language, but the graphics commands are there, so.. expandcollapse popup#include <GUIConstants.au3> #include <Math.au3> ; == GUI generated with Koda ==); $Graphics = GUICreate("Graphics Test", 600, 600, 192, 125) $Gh = GuiCtrlCreateGraphic(-1, -1, 600,600) $X = 300 $Y = 300 $Size = 300 $Wid = $Size $Hgt = $Size $Col = 0xffffff $Col1 = 0x000000 GUISetState(@SW_SHOW) GUICtrlSetGraphic(-1,$GUI_GR_PENSIZE, 1) GUICtrlSetGraphic(-1,$GUI_GR_MOVE, $Size,$Size) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, $Col,0) _DrawGraphic(0.5) GUICtrlSetGraphic(-1,$GUI_GR_MOVE, $Size,$Size) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, $Col1,0) _DrawGraphic(2) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Func _DrawGraphic($Step) For $R1 =1 to 360 Step $Step $Rad = _Radian ($R1) $Px = Sin($Rad)*$Size + $x $Py = Cos($Rad)*$Size + $y GUICtrlSetGraphic(-1,$GUI_GR_MOVE, $X,$Y) GUICtrlSetGraphic(-1,$GUI_GR_LINE, $Px,$Py) GUICtrlSetGraphic($Gh, $GUI_GR_REFRESH) Next EndFunc I know that I could have it update after the graphics have been drawn, but I think the best part is seeing the graphics being drawn! 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
nfwu Posted March 29, 2006 Share Posted March 29, 2006 (edited) Stick a Sleep(30) in there. Func _DrawGraphic($Step) For $R1 =1 to 360 Step $Step $Rad = _Radian ($R1) $Px = Sin($Rad)*$Size + $x $Py = Cos($Rad)*$Size + $y GUICtrlSetGraphic(-1,$GUI_GR_MOVE, $X,$Y) GUICtrlSetGraphic(-1,$GUI_GR_LINE, $Px,$Py) GUICtrlSetGraphic(-1,$GUI_GR_REFRESH) Sleep(30) Next EndFunc #) I tried including my AutoIt3D's DisplayManager in there, but then it is too bulky and slow for such a small application. Edited March 29, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Lakes Posted April 14, 2006 Author Share Posted April 14, 2006 This works without redrawing the whole GUI expandcollapse popup#include <GUIConstants.au3> #include <Math.au3> ; == GUI generated with Koda ==); $Graphics = GUICreate("Graphics Test", 600, 600, 192, 125, $WS_POPUP) Global $gdi_dll = DllOpen ("gdi32.dll"), $user32_dll = DllOpen ("user32.dll") $Black = "0x000000" $White = "0xFFFFFF" $Red = "0xFF0000" $Green = "0x00FF00" $Blue = "0x0000FF" $Yellow = "0xFFFF00" Dim $PenVar[10] $PenVar[0] = "Black" $PenVar[1] = "White" $PenVar[2] = "Red" $PenVar[3] = "Green" $PenVar[4] = "Blue" $PenVar[5] = "Yellow" $X = 300 $Y = 300 $Size = 300 $Wid = $Size $Hgt = $Size Dim $PenCol[10] $PenCol[0] = $Black $PenCol[1] = $White $PenCol[2] = $Red $PenCol[3] = $Green $PenCol[4] = $Blue $PenCol[5] = $Yellow ;$PenColour = "0xFFFFFF" $BackgrndPen = "0x00D8E9EC" GUISetState(@SW_SHOW) For $n =0 to 5 $PenColour = $PenCol[$n] ;msgbox(0,"Colour", "Colour is " &$PenVar[$n] &" its value is " &$PenCol[$n] &"Size is " &$Size ) _DrawGraphic(0.2) $Size = $Size - 50 next While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE DllClose ($gdi_dll) DllClose ($user32_dll) ExitLoop Case Else ;;;;;;; EndSelect WEnd Func _DrawGraphic($Step) For $R1 =363 to 1 Step -$Step $i = int($R1/3.6) $Rad = _Radian ($R1) $Px = Sin($Rad)*$Size + $x $Py = Cos($Rad)*$Size + $y ;Sleep(1) ;If you want to slow it down _DrawLine ($Graphics,$X,$Y,$Px,$Py,$PenColour,$BackgrndPen) Next EndFunc Func _DrawLine($GUI,$x, $y, $EndPntX, $EndPointY, $PenColour,$BackgrndPen ) $GUIHDC = DllCall ($user32_dll,"int","GetDC","hwnd", $GUI) $Pen = DllCall($gdi_dll, "hwnd", "CreatePen", "int", "0", "int", "0", "hwnd", $PenColour) $Pen = $Pen[0] DllCall($gdi_dll, "hwnd", "SelectObject", "hwnd", $GUIHDC[0], "hwnd", $Pen) DllCall ($gdi_dll, "int", "MoveToEx", "hwnd", $GUIHDC[0], "int", $x, "int", $y, "ptr", 0) DllCall ($gdi_dll, "int", "LineTo", "hwnd", $GUIHDC[0], "int", $EndPntX, "int", $EndPointY) DllCall ($user32_dll,"int","ReleaseDC","int",$GUIHDC[0],"hwnd",$GUI) EndFunc Thanks to GreenMachine & NeoGia Not perfect, as the drawing is wiped out by any overlapping window, even if its made topmost. Maybe do a capture, and then rewrite?, how to detect window overlap? Thanks, Still Learning! 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
jpm Posted April 14, 2006 Share Posted April 14, 2006 @Lakes graphics are drawn always in background so ONTOP cannot be used Link to comment Share on other sites More sharing options...
Lakes Posted April 14, 2006 Author Share Posted April 14, 2006 @Lakesgraphics are drawn always in background so ONTOP cannot be usedOh.. Anyone know how to detect when a window is overlapping the one I`m drawing on?That way I could do a redraw or whatever after the other window has been moved.Hmm.. Get position of Draw Window, then monitor positions of all other visable windows... Gotta be a better way than that.. 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
greenmachine Posted April 14, 2006 Share Posted April 14, 2006 Oh.. Anyone know how to detect when a window is overlapping the one I`m drawing on?That way I could do a redraw or whatever after the other window has been moved.Hmm.. Get position of Draw Window, then monitor positions of all other visable windows... Gotta be a better way than that..If a window is overlapping your window, could you assume that your window is not active? If so, check out my clock again - it has some checking for active or not, and if the window is moved off screen. Link to comment Share on other sites More sharing options...
Lakes Posted April 14, 2006 Author Share Posted April 14, 2006 If a window is overlapping your window, could you assume that your window is not active? If so, check out my clock again - it has some checking for active or not, and if the window is moved off screen.Good Idea! will do thanks! 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
upnorth Posted April 14, 2006 Share Posted April 14, 2006 Anyone know how to detect when a window is overlapping the one I`m drawing on?you could draw to a memorydc, GUIRegisterMsg( $WM_PAINT,) , BitBlt from the memorydc.http://www.autoitscript.com/fileman/users/outeast/files/clock.au3http://www.autoitscript.com/fileman/users/outeast/files/gdi32.au3http://www.autoitscript.com/fileman/users/outeast/files/user32.au3 Link to comment Share on other sites More sharing options...
Lakes Posted April 14, 2006 Author Share Posted April 14, 2006 you could draw to a memorydc, GUIRegisterMsg( $WM_PAINT,) , BitBlt from the memorydc.http://www.autoitscript.com/fileman/users/outeast/files/clock.au3http://www.autoitscript.com/fileman/users/outeast/files/gdi32.au3http://www.autoitscript.com/fileman/users/outeast/files/user32.au3Wow!, lots of functions to play with! thanks! 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now