monoceres Posted July 23, 2008 Share Posted July 23, 2008 Hi!Another GDI+ animation, this is better however and that is mainly because weaponx and I cooperated on this.Screenshot:Download:http://monoceres.se/Uploads/radar.zipEnjoy muttley Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
gseller Posted July 23, 2008 Share Posted July 23, 2008 Cool effect!! Even has the targets moving.. Link to comment Share on other sites More sharing options...
McGod Posted July 23, 2008 Share Posted July 23, 2008 very nice!! [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
Andreik Posted July 23, 2008 Share Posted July 23, 2008 I detected target out of Radar. muttley When the words fail... music speaks. Link to comment Share on other sites More sharing options...
monoceres Posted July 24, 2008 Author Share Posted July 24, 2008 Thanks, remember to give credit to weaponx also muttleyI detected target out of Radar. biggrin.gifWell, someone probably used a radar jamming device outside your house, that's the only logical explanation! Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Andreik Posted July 24, 2008 Share Posted July 24, 2008 Thanks, remember to give credit to weaponx also Well, someone probably used a radar jamming device outside your house, that's the only logical explanation!I know muttley When the words fail... music speaks. Link to comment Share on other sites More sharing options...
weaponx Posted July 24, 2008 Share Posted July 24, 2008 I was thinking a game could be made out of this. It would be kind of like Missile Command. When a blip shows up on radar you could click on the target to fire a missile which would take a few seconds to impact, then if the target is within the blast radius a red halo would glow or flash around the target. Then Microsoft SAM would announce from a list of phrases "target destroyed", "enemy down", "kick ass", etc... Link to comment Share on other sites More sharing options...
Szhlopp Posted July 24, 2008 Share Posted July 24, 2008 Nice!! I'm new to the GDI stuff... How are you able to draw the line, and then remove the line so you can redraw it at the next 'step'? I was able to create something but I wasn't able to remove the graphic whenever I wanted. Is there a "Re-paint" command I don't know about? Also, What does the GetDC and ReleaseDC stuff do? Help file is useless for those commands $dc = _GDIPlus_GraphicsGetDC($backbuffer) _FillGradientTriangleRect($dc, $temp, $GRADIENT_FILL_TRIANGLE) _GDIPlus_GraphicsReleaseDC($backbuffer, $dc) Thanks for your help!! Sorry I'm a newblet at this RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+' Link to comment Share on other sites More sharing options...
monoceres Posted July 24, 2008 Author Share Posted July 24, 2008 I was thinking a game could be made out of this. It would be kind of like Missile Command. When a blip shows up on radar you could click on the target to fire a missile which would take a few seconds to impact, then if the target is within the blast radius a red halo would glow or flash around the target. Then Microsoft SAM would announce from a list of phrases "target destroyed", "enemy down", "kick ass", etc... Yeah, that would be awesome, not too hard to do either, the only hard part is getting a decent halo animation. muttley Nice!! I'm new to the GDI stuff... How are you able to draw the line, and then remove the line so you can redraw it at the next 'step'? I was able to create something but I wasn't able to remove the graphic whenever I wanted. Is there a "Re-paint" command I don't know about? I'm not only removing the line, I'm clearing everything each time the loop runs. To make this smooth I draw everything into different bitmaps in memory, you can see these as layers and then when all drawing is complete I draw everything at once into the screen ( See the last _GDIPlus_GraphicsDrawRect() call ). This is actually how all graphics programming work, clearing and redrawing. Also, What does the GetDC and ReleaseDC stuff do? Help file is useless for those commands $dc = _GDIPlus_GraphicsGetDC($backbuffer) _FillGradientTriangleRect($dc, $temp, $GRADIENT_FILL_TRIANGLE) _GDIPlus_GraphicsReleaseDC($backbuffer, $dc) Thanks for your help!! Sorry I'm a newblet at this They give me the device context (dc) of the graphics object where I want the _FillGradientTriangleRect to draw. The reason for using a dc is simply because the windows function that my _FillGradientTriangleRect() function uses only accepts a dc, not a graphics object. I'm currently writing a GDI+ tutorial which will probably be done in a couple of days, be sure to check it out Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Szhlopp Posted July 24, 2008 Share Posted July 24, 2008 They give me the device context (dc) of the graphics object where I want the _FillGradientTriangleRect to draw. The reason for using a dc is simply because the windows function that my _FillGradientTriangleRect() function uses only accepts a dc, not a graphics object.I'm currently writing a GDI+ tutorial which will probably be done in a couple of days, be sure to check it outCool, and thanks!My last question is. Is there a repaint command for your GUI? (command to force the repaint of the gui and controls) RegEx/RegExRep Tester!Nerd Olympics - Community App!Login UDFMemory UDF - "Game.exe+753EC" - CE pointer to AU3Password Manager W/ SourceDataFiler - Include files in your au3!--- Was I helpful? Click the little green '+' Link to comment Share on other sites More sharing options...
Draygoes Posted July 24, 2008 Share Posted July 24, 2008 Hello Monoceres, Could I get your radar example compiled? I am not near a machine that I can use to compile it. Thanks. Spoiler  "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.   Link to comment Share on other sites More sharing options...
monoceres Posted July 24, 2008 Author Share Posted July 24, 2008 Hello Monoceres,Could I get your radar example compiled? I am not near a machine that I can use to compile it.Thanks.Yup, replaced the zip with a new one that includes a compiled version.Enjoy! Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
James Posted July 24, 2008 Share Posted July 24, 2008 It's a bit big to view on my small 1024*768 screen. Maybe the Missile Command box could be seperatley moved? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
monoceres Posted July 24, 2008 Author Share Posted July 24, 2008 It's a bit big to view on my small 1024*768 screen. Maybe the Missile Command box could be seperatley moved?Yeah, or you could manually edit the width and height of the radar window. It's just two Consts at the top of the script Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
James Posted July 24, 2008 Share Posted July 24, 2008 (edited) Yeah, or you could manually edit the width and height of the radar window. It's just two Consts at the top of the script I knew that Edit: I thought that the radar was supposed to pcik up things in an aear not the black? Edited July 24, 2008 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
monoceres Posted July 24, 2008 Author Share Posted July 24, 2008 I knew that Ok then The window moving part will come when I update the thing to what weaponx suggested above Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
thomaatje Posted July 24, 2008 Share Posted July 24, 2008 Why does the .exe file try to edit my Process Memory?? Link to comment Share on other sites More sharing options...
monoceres Posted July 24, 2008 Author Share Posted July 24, 2008 Why does the .exe file try to edit my Process Memory??How did you figure that out?The exe is just a standard "right click on script" compile I did so Draygoes could test it. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
thomaatje Posted July 24, 2008 Share Posted July 24, 2008 (edited) How did you figure that out?The exe is just a standard "right click on script" compile I did so Draygoes could test it. Well... my virus scanner gave me a warning...Oh and its a _WinAPI_WriteProcessMemory() func and a RegWrite() to \REGISTRY\USER\S-1-5-21-1283738941-3212688771-2078699739-1006\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders Edited July 24, 2008 by Forsaken Link to comment Share on other sites More sharing options...
martin Posted July 24, 2008 Share Posted July 24, 2008 (edited) It's a great example and a huge improvement on the first version I saw. Excellent monoceres and weaponex. I think the child window moves better if you don't have the Move function, and don't register $WM_MOVE, a bit like this expandcollapse popup; Authors: Andreas Karlsson (monoceres) & weaponx ; License: Give credit back to the authors when reusing parts of the source. ; ; Notes: Width & Height can be changed but should be kept equal, otherwise errors will arise. ; Constants used by _FillGradientTriangleRect Global Const $GRADIENT_FILL_RECT_H = 0 Global Const $GRADIENT_FILL_RECT_V = 1 Global Const $GRADIENT_FILL_TRIANGLE = 2 ; End #include <GDIPlus.au3> #include <Math.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <Date.au3> Global Const $width = 600 Global Const $height = 600 Global Const $dots = 3 Global $direction = 1 Global $remx[$dots], $remy[$dots] Opt("GUIOnEventMode", 1) $hwnd = GUICreate("Radar", $width, $height,-1,-1,$WS_CAPTION);0x02000000);$WS_EX_COMPOSITED) GUISetOnEvent(-3, "close") GUISetState() GUIRegisterMsg($WM_PAINT, "_Paint") ;GUIRegisterMsg($WM_MOVE, "_Move") ; Create the dot. Global $UFO[$dots][5] For $a = 0 To UBound($UFO) - 1 $UFO[$a][0] = Random(0, $width, 1) If Random(0, 1, 1) = 0 Then $UFO[$a][1] = 0 Else $UFO[$a][1] = $height EndIf Do $UFO[$a][2] = Random(-0.5, 0.5) $UFO[$a][3] = Random(-0.5, 0.5) Until $UFO[$a][2] + $UFO[$a][3] <> 0 Next _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd) $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) $background = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics) $backgroundgraphics = _GDIPlus_ImageGetGraphicsContext($background) _AntiAlias($backgroundgraphics, 4) $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) _AntiAlias($backbuffer, 4) $brush = _GDIPlus_BrushCreateSolid(0xFF005200) $pen = _GDIPlus_PenCreate(0xFF008800, 3) $pen2 = _GDIPlus_PenCreate(0xFF00BB00, 3) DirCreate(@TempDir & "\flags\") $lang = @OSLang ConsoleWrite("Lang = " & @OSLang & @CRLF) Switch $lang Case "0809" InetGet("http://www.ensignmessage.com/images/unitedkingdom_gl.gif", @TempDir & "\flags\~flag.gif") Case "041d" $res = InetGet("http://www.evl.fi/svenska/skola/bild/flaggor/sverige.gif", @TempDir & "\flags\~flag.gif") Case "0409" InetGet("http://www.unl.pt/nova/relacoes-internacionais/usa.gif", @TempDir & "\flags\~flag.gif") Case "0413" InetGet("http://www.traveltoucan.com/files/Netherlands-flag.gif", @TempDir & "\flags\~flag.gif") Case "0407" InetGet("http://www.mapsofworld.com/images/world-countries-flags/germany-flag.gif", @TempDir & "\flags\~flag.gif") Case "042a" InetGet("http://www.tofocus.info/images/flags/vietnam-flag.gif", @TempDir & "\flags\~flag.gif") Case "0406" InetGet("http://www1.ocn.ne.jp/~infinite/PeacePath_Flags_Data/DenmarkF.gif", @TempDir & "\flags\~flag.gif") Case "0414" InetGet("http://www.mapsofworld.com/images/world-countries-flags/norway-flag.gif", @TempDir & "\flags\~flag.gif") Case "0814" InetGet("http://www.mapsofworld.com/images/world-countries-flags/norway-flag.gif", @TempDir & "\flags\~flag.gif") Case "0419" InetGet("http://www1.ocn.ne.jp/~infinite/PeacePath_Flags_Data/RussiaF.gif", @TempDir & "\flags\~flag.gif") Case "0418" InetGet("http://wwp.greenwichmeantime.com/time-zone/europe/european-union/romania/images/romania-flag.gif", @TempDir & "\flags\~flag.gif") Case "1009" InetGet("http://www.aidanandhilda.org.uk/public_html/images/flag_canada.gif", @TempDir & "\flags\~flag.gif") Case "0c0c" InetGet("http://www.aidanandhilda.org.uk/public_html/images/flag_canada.gif", @TempDir & "\flags\~flag.gif") Case "040c" InetGet("http://webmsi.free.fr/HEC-MSI-0712-GR3/france-flag.gif", @TempDir & "\flags\~flag.gif") Case "040a" InetGet("http://www.spain-flag.eu/photos/spain-flag.gif", @TempDir & "\flags\~flag.gif") Case "040b" InetGet("http://www.lsa.umich.edu/oip/Images/photo-albums/finland/finland-flag.gif", @TempDir & "\flags\~flag.gif") Case "0416" InetGet("http://blogs.zdnet.com/open-source/images/brazil%20flag.gif", @TempDir & "\flags\~flag.gif") Case "0816" InetGet("http://www.geocities.com/bretanha1954/images/portugal-flag.gif", @TempDir & "\flags\~flag.gif") Case "0411" InetGet("https://www.cia.gov/library/publications/the-world-factbook/flags/ja-lgflag.gif", @TempDir & "\flags\~flag.gif") Case "0804" InetGet("http://www.national-symbol.com/C/china/china-flag.gif", @TempDir & "\flags\~flag.gif") Case "0c09" InetGet("http://parenting.leehansen.com/downloads/clipart/Australia/images/australia-flag500.gif", @TempDir & "\flags\~flag.gif") Case "0410" InetGet("http://shawza.files.wordpress.com/2007/11/italy_flag.gif", @TempDir & "\flags\~flag.gif") Case "040d" InetGet("http://www.orionservice.biz/images/IsraelFlag.gif", @TempDir & "\flags\~flag.gif") Case "0405" InetGet("http://www.lsa.umich.edu/oip/Images/photo-albums/czech_republic/czech-flag.gif", @TempDir & "\flags\~flag.gif") Case "0439" InetGet("http://www.mapsofworld.com/images/world-countries-flags/india-flag.gif", @TempDir & "\flags\~flag.gif") Case Else InetGet("http://www.mitchmajor.com/images/jolly.gif", @TempDir & "\flags\~flag.gif") EndSwitch $tpos = WinGetPos($hwnd) $childhwnd = GUICreate("Control Panel", 500, 200, $tpos[0] + ($width - 500) / 2, $tpos[1] + $height + 30, BitOR($WS_POPUP,$WS_CHILD),BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED),$hwnd) GUICtrlCreatePic("background.gif", 0, 0, 500, 200) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreatePic(@TempDir & "\flags\~flag.gif", 45, 35, 80, 50) $edit = GUICtrlCreateEdit("Radar system started at: " & _Now(), 55, 110, 380, 50, BitOR($ES_READONLY, $ES_WANTRETURN, $ES_AUTOVSCROLL)) GUICtrlSetBkColor(-1, 0x444343) GUICtrlSetColor(-1, 0x00BB00) GUISetState() GUISetBkColor(0x123456) _API_SetLayeredWindowAttributes($childhwnd, 0x123456, 255) WinActivate($hwnd) $tpos = WinGetPos($hwnd) WinMove($childhwnd, "", $tpos[0] + ($width - 500) / 2, $tpos[1] + $height + 30) Global $whiteshades[32] For $i = 0 To UBound($whiteshades) - 1 $whiteshades[$i] = _GDIPlus_BrushCreateSolid("0x" & Hex(((32 - $i) * 8 - 1), 2) & "AAFFAA") Next _GDIPlus_GraphicsClear($backgroundgraphics, 0xFF000000) _GDIPlus_GraphicsFillEllipse($backgroundgraphics, 0, 0, $width, $height, $brush) _GDIPlus_GraphicsDrawLine($backgroundgraphics, $width / 2, 0, $width / 2, $height, $pen) _GDIPlus_GraphicsDrawLine($backgroundgraphics, 0, $height / 2, $width, $height / 2, $pen) _GDIPlus_GraphicsDrawEllipse($backgroundgraphics, 50, 50, $width - (50 * 2), $height - (50 * 2), $pen) _GDIPlus_GraphicsDrawEllipse($backgroundgraphics, 175, 175, $width - (175 * 2), $height - (175 * 2), $pen) $inc = 0 $tx = 200 $ty = 100 Do _Draw() Sleep(20) Until False Func _Draw() ; Clear the backbuffer and draw the background on it. _GDIPlus_GraphicsClear($backbuffer, 0xFF000000) _GDIPlus_GraphicsDrawImageRect($backbuffer, $background, 0, 0, $width, $height) ; Get the x and y position to draw the line on $temparray = _GetXY($inc) $x = $temparray[0] $y = $temparray[1] ; Check if the line is intercepted For $a = 0 To UBound($UFO) - 1 $result = PointDistanceFromLine($width / 2, $height / 2, $x, $y, $UFO[$a][0], $UFO[$a][1]) If CircleIntersection($result, 10) And $UFO[$a][4] = 0 Then $UFO[$a][4] = 1 $remx[$a] = $UFO[$a][0] $remy[$a] = $UFO[$a][1] If ($remx[$a] - $width / 2) ^ 2 + ($remy[$a] - $height / 2) ^ 2 <= (($width - (175 * 2)) / 2) ^ 2 Then If $remx[$a] < $width / 2 Then If $remy[$a] < $height / 2 Then _GUICtrlEdit_AppendText($edit, @CRLF & @HOUR&":"&@MIN&":"&@SEC&": "&"Object intercepted in sector A1") Else _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector A3") EndIf Else If $remy[$a] < $height / 2 Then _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector A2") Else _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector A4") EndIf EndIf ElseIf ($remx[$a] - $width / 2) ^ 2 + ($remy[$a] - $height / 2) ^ 2 <= (($width - (50 * 2)) / 2) ^ 2 Then If $remx[$a] < $width / 2 Then If $remy[$a] < $height / 2 Then _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector B1") Else _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector B3") EndIf Else If $remy[$a] < $height / 2 Then _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector B2") Else _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector B4") EndIf EndIf Else If $remx[$a] < $width / 2 Then If $remy[$a] < $height / 2 Then _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector C1") Else _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector C3") EndIf Else If $remy[$a] < $height / 2 Then _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector C2") Else _GUICtrlEdit_AppendText($edit, @CRLF &@HOUR&":"&@MIN&":"&@SEC&": "& "Object intercepted in sector C4") EndIf EndIf EndIf EndIf ConsoleWrite("Result: " & $result & @CRLF) Next _GDIPlus_GraphicsDrawLine($backbuffer, $width / 2, $height / 2, $x, $y, $pen2) Local $temp[3][3] $temp[0][0] = $width / 2 $temp[0][1] = $height / 2 $temp[0][2] = "0x00005200" $temp[1][0] = $x $temp[1][1] = $y $temp[1][2] = "0xFF00BB00" $xy = _GetXY($inc - 0.0005 * $direction * 7) $temp[2][0] = $xy[0] $temp[2][1] = $xy[1] $temp[2][2] = "0x00005200" $dc = _GDIPlus_GraphicsGetDC($backbuffer) _FillGradientTriangleRect($dc, $temp, $GRADIENT_FILL_TRIANGLE) _GDIPlus_GraphicsReleaseDC($backbuffer, $dc) ; If the dot has been found For $a = 0 To UBound($UFO) - 1 If $UFO[$a][4] > 0 Then _GDIPlus_GraphicsFillEllipse($backbuffer, $remx[$a], $remy[$a], 10, 10, $whiteshades[$UFO[$a][4] - 1]) $UFO[$a][4] += 1 If $UFO[$a][4] > 32 Then $UFO[$a][4] = 0 EndIf EndIf ; Move the dot (regardless of state) $UFO[$a][0] += $UFO[$a][2] $UFO[$a][1] += $UFO[$a][3] ; If the dot is of screen recreate it If $UFO[$a][0] > $width Or $UFO[$a][0] < 0 Or $UFO[$a][1] > $height Or $UFO[$a][1] < 0 Then $UFO[$a][0] = Random(0, $width, 1) If Random(0, 1, 1) = 0 Then $UFO[$a][1] = 0 Else $UFO[$a][1] = $height EndIf Do $UFO[$a][2] = Random(-0.5, 0.5) $UFO[$a][3] = Random(-0.5, 0.5) Until $UFO[$a][2] + $UFO[$a][3] <> 0 EndIf Next _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) $inc += 0.0005 * $direction EndFunc ;==>_Draw Func _GetXY($value) Local $array[2] $cos = Cos(_Degree($value)) $sin = Sin(_Degree($value)) $fx = $cos * ($width / 2) + ($width / 2) $fy = $sin * ($height / 2) + ($height / 2) $array[0] = $fx $array[1] = $fy Return $array EndFunc ;==>_GetXY Func close() For $i = 0 To UBound($whiteshades) - 1 _GDIPlus_BrushDispose($whiteshades[$i]) Next _GDIPlus_PenDispose($pen) _GDIPlus_PenDispose($pen2) _GDIPlus_BrushDispose($brush) _WinAPI_DeleteObject($bitmap) _WinAPI_DeleteObject($background) _GDIPlus_GraphicsDispose($backgroundgraphics) _GDIPlus_GraphicsDispose($graphics) _GDIPlus_GraphicsDispose($backbuffer) _GDIPlus_Shutdown() Exit EndFunc ;==>close Func _Paint() _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height) Return "GUI_RUNDEFMSG" EndFunc ;==>_Paint #cs Func _Move() _Draw() $tpos = WinGetPos($hwnd) WinMove($childhwnd, "", $tpos[0] + ($width - 500) / 2, $tpos[1] + $height + 30) Return "GUI_RUNDEFMSG" EndFunc ;==>_Move #ce ; Thanks weaponx for these three functions :) ;distance: Center point distance from line ;radius: circle radius Func CircleIntersection($distance, $Radius) If $distance < $Radius Then ;MsgBox(0,"","Circle intersects line") Return True Else ;MsgBox(0,"","Circle doesn't intersect line") Return False EndIf EndFunc ;==>CircleIntersection ;xa,ya: Start X,Y ;xb,yb: End X,Y ;xp,yp: Point X,Y Func PointDistanceFromLine($xa, $ya, $xb, $yb, $xp, $yp) ;Xa,Ya is point 1 on the line segment. ;Xb,Yb is point 2 on the line segment. ;Xp,Yp is the point. $xu = $xp - $xa $yu = $yp - $ya $xv = $xb - $xa $yv = $yb - $ya If ($xu * $xv + $yu * $yv < 0) Then Return Sqrt(($xp - $xa) ^ 2 + ($yp - $ya) ^ 2) EndIf $xu = $xp - $xb $yu = $yp - $yb $xv = -$xv $yv = -$yv If ($xu * $xv + $yu * $yv < 0) Then Return Sqrt(($xp - $xb) ^ 2 + ($yp - $yb) ^ 2) EndIf Return Abs(($xp * ($ya - $yb) + $yp * ($xb - $xa) + ($xa * $yb - $xb * $ya)) / Sqrt(($xb - $xa) ^ 2 + ($yb - $ya) ^ 2)) EndFunc ;==>PointDistanceFromLine Func _AntiAlias($hGraphics, $iMode) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_AntiAlias ; #FUNCTION#;=============================================================================== ; ; Name...........: _FillGradientTriangleRect() ; Description ...: Draws a gradient triangle or rect on a device context ; Syntax.........: _FillGradientTriangleRect(ByRef $hDc, ByRef $aVertexes, $iFlag) ; Parameters ....: $hDc - Handle to a device context ; $sVertexes - A 2 dimension array that specifies the triangle (or rect) The array has this structure:" ; |$aVertexes[n][0] = x coord ; |$aVertexes[n][1] = y coord ; |$aVertexes[n][2] = Color of the vertex in 0xAARRGGBB format ; $iFlag - Flag that specifies the drawing, flags: ; |$GRADIENT_FILL_RECT_H - Rectangle with horizontal gradient ; |$GRADIENT_FILL_RECT_V - Rectangle with vertical gradient ; |$GRADIENT_FILL_TRIANGLE - Triangle ; Return values .: Success - 1 ; Failure - Returns -1 and sets error to 1 ; Author ........: Andreas Karlsson (monoceres) ; Modified.......: ; Remarks .......: Pass 3 vertexes for triangles and 2 for rects ; Related .......: ; Link ..........; http://msdn.microsoft.com/en-us/library/ms532348(VS.85).aspx ; Example .......; No ; ;;========================================================================================== Func _FillGradientTriangleRect(ByRef $hDc, ByRef $aVertexes, $iFlag) Local $sTRIVERTEXString, $vTRIVERTEX, $aReturn Local $iColor Local $GRADIENT_STRUCT If $iFlag = $GRADIENT_FILL_TRIANGLE Then $GRADIENT_STRUCT = DllStructCreate("ulong V1;ulong V2;ulong V3;") DllStructSetData($GRADIENT_STRUCT, "V1", 0) DllStructSetData($GRADIENT_STRUCT, "V2", 1) DllStructSetData($GRADIENT_STRUCT, "V3", 2) Else $GRADIENT_STRUCT = DllStructCreate("ulong UpperLeft;ulong LowerRight;") DllStructSetData($GRADIENT_STRUCT, "UpperLeft", 0) DllStructSetData($GRADIENT_STRUCT, "LowerRight", 1) EndIf For $i = 0 To UBound($aVertexes) - 1 $sTRIVERTEXString &= "ulong x" & $i & ";ulong y" & $i & ";short Red" & $i & ";short Green" & $i & ";short Blue" & $i & ";" Next $vTRIVERTEX = DllStructCreate($sTRIVERTEXString) For $i = 0 To UBound($aVertexes) - 1 $iColor = StringRight($aVertexes[$i][2], 8) DllStructSetData($vTRIVERTEX, "x" & $i, $aVertexes[$i][0]) DllStructSetData($vTRIVERTEX, "y" & $i, $aVertexes[$i][1]) DllStructSetData($vTRIVERTEX, "Alpha" & $i, "0x" & Hex(Dec(StringLeft($iColor, 2)) * 256, 4)) DllStructSetData($vTRIVERTEX, "Red" & $i, "0x" & Hex(Dec(StringMid($iColor, 3, 2)) * 256, 4)) DllStructSetData($vTRIVERTEX, "Green" & $i, "0x" & Hex(Dec(StringMid($iColor, 5, 2)) * 256, 4)) DllStructSetData($vTRIVERTEX, "Blue" & $i, "0x" & Hex(Dec(StringRight($iColor, 2)) * 256, 4)) Next $aReturn = DllCall("Msimg32.dll", "int", "GradientFill", "ptr", $hDc, "ptr", DllStructGetPtr($vTRIVERTEX), "ulong", UBound($aVertexes), "ptr", DllStructGetPtr($GRADIENT_STRUCT), "ulong", 1, "ulong", $iFlag) If Not IsArray($aReturn) Or $aReturn[0] = 0 Then Return SetError(1, 0, -1) Else Return SetError(0, 0, 1) EndIf EndFunc ;==>_FillGradientTriangleRect ;=============================================================================== ; ; Function Name: _API_SetLayeredWindowAttributes ; Description:: Sets Layered Window Attributes:) See MSDN for more informaion ; Parameter(s): ; $hwnd - Handle of GUI to work on ; $i_transcolor - Transparent color ; $Transparency - Set Transparancy of GUI ; $isColorRef - If True, $i_transcolor is a COLORREF-Strucure, else an RGB-Color ; Requirement(s): Layered Windows ; Return Value(s): Success: 1 ; Error: 0 ; @error: 1 to 3 - Error from DllCall ; @error: 4 - Function did not succeed - use ; _WinAPI_GetLastErrorMessage or _WinAPI_GetLastError to get more information ; Author(s): Prog@ndy ; ;=============================================================================== ; Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False) Local Const $AC_SRC_ALPHA = 1 Local Const $ULW_ALPHA = 2 Local Const $LWA_ALPHA = 0x2 Local Const $LWA_COLORKEY = 0x1 If Not $isColorRef Then $i_transcolor = Hex(String($i_transcolor), 6) $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2)) EndIf Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA) Select Case @error Return SetError(@error, 0, 0) Case $Ret[0] = 0 Return SetError(4, 0, 0) Case Else Return 1 EndSelect EndFunc ;==>_API_SetLayeredWindowAttributes EDIT :Retracted change made to flags. Looks like it's my laptop thinks it's American! Edited July 24, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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