; ; This UDF is made for learning how Graphics in AutoIt v.3 work. ; The content of this work is licensed under Creative Commons license. ; Autor: campweb ; Last Change: 18.8.2011 ; ; #INDEX# ========================================================================================= ; Functions: ; ;_GDE_Create() ;_GDE_Line() ;_GDE_Line() ;_GDE_Rect() ;_GDE_Ellipse() ;_GDE_Pie() ;_GDE_Pie() ;_GDE_Point() ;_GDE_Pixel() ;_GDE_Bezier() ;_GDE_Dispose() ;_GDE_Triangle() ;_GDE_CustomRect() ;_GDE_Update() ; ; ================================================================================================= ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_CustomRect() ; Description ...: Draws a Rect with 4 Costum Points ; Syntax ........: _GDE_CustomRect($hGraphics, $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $Color[, $Size = 1]) ; Parameters ....: $hGraphics - The GDE Handle to draw to ; $x1 - The x of the bottom-left Point of the Rect ; $y1 - The y of the bottom-left Point of the Rect ; $x2 - The x of the up-left Point of the Rect ; $y2 - The y of the up-left Point of the Rect ; $x3 - The x of the up-right Point of the Rect ; $y3 - The y of the up-right Point of the Rect ; $x4 - The x of the bottom-right Point of the Rect ; $y4 - The y of the bottom-right Point of the Rect ; $Color - The Color of the Pen to draw with ; $Size - [optional] The Size of the Pen to draw with (default:1) ; Author ........: campweb ; Modified ......: 18.8.2011 ; ================================================================================================= Func _GDE_CustomRect($hGraphics, $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $Color, $Size = 1) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x1, $y1) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x2, $y2) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x2, $y2) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x3, $y3) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x3, $y3) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x4, $y4) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x4, $y4) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x1, $y1) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Bezier() ; Description ...: Draws a Bezier with 2 Controlpoints ; Syntax ........: _GDE_Bezier($hGraphics, $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $Color[, $Size = 1]) ; Parameters ....: $hGraphics - GDE Handle to draw to. ; $x1 - X Coordinate of the Start Point ; $y1 - Y Coordinate of the Start Point ; $x2 - X Coordinate of the first Control Point ; $y2 - Y Coordinate of the first Control Point ; $x3 - X Coordinate of the second Control Point ; $y3 - Y Coordinate of the second Control Point ; $x4 - X Coordinate of the End Point ; $y4 - Y Coordinate of the End Point ; $Color - Color of the Pen to draw with. Set it to 0 will set the Pen Black ; $Size - [optional] Size of the Pen to draw with (default:1) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Bezier($hGraphics, $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $Color, $Size = 1) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x4, $y4) GUICtrlSetGraphic($hGraphics, $GUI_GR_BEZIER, $x1, $y1, $x2, $y2, $x3, $y3) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Create() ; Description ...: Creates a GDE Handle from a Window ; Syntax ........: _GDE_Create($hWnd) ; Parameters ....: $hWnd - Control ID of the GUI ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Create($hWnd) GUISwitch($hWnd) $size = WinGetPos("[active]") $Obj = GUICtrlCreateGraphic(0, 0, $size[2], $size[3]) Return $Obj EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Dispose() ; Description ...: Deletes the given GDE Handle ; Syntax ........: _GDE_Dispose($hGraphics) ; Parameters ....: $hGraphics - The GDE Handle to delete ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: ; ================================================================================================= Func _GDE_Dispose($hGraphics) GUICtrlDelete($hGraphics) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Ellipse() ; Description ...: Draws an Ellipse ; Syntax ........: _GDE_Ellipse($hGraphics, $Left, $Top, $Width, $Height, $Color[, $Size = 1[, $BackColor = $GUI_GR_NOBKCOLOR]]) ; Parameters ....: $hGraphics - GDE Handle to draw to ; $Left - Distance to the Left Window Corner ; $Top - Distance to the Upper Window Corner ; $Width - Width of the Ellipse ; $Height - Height of the Ellipse ; $Color - Color of the Pen to draw with ; $Size - [optional] Size of the Pen to draw with (default:1) ; $BackColor - [optional] Color to fill with (default:$GUI_GR_NOBKCOLOR) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Ellipse($hGraphics, $Left, $Top, $Width, $Height, $Color, $Size = 1, $BackColor = $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color, $BackColor) GUICtrlSetGraphic($hGraphics, $GUI_GR_ELLIPSE, $Left, $Top, $Width, $Height) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Line() ; Description ...: Draws a Line ; Syntax ........: _GDE_Line($hGraphics, $x1, $y1, $x2, $y2, $Color[, $Size = 1]) ; Parameters ....: $hGraphics - GDE Handle to draw to ; $x1 - X Coordinate of the Startpoint ; $y1 - Y Coordinate of the Startpoint ; $x2 - X Coordinate of the Endpoint ; $y2 - Y Coordinate of the Endpoint ; $Color - Color of the Pen to draw with ; $Size - [optional] Size of the Pen to draw with (default:1) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Line($hGraphics, $x1, $y1, $x2, $y2, $Color, $Size = 1) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x1, $y1) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x2, $y2) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Pie() ; Description ...: Draw a Pie ; Syntax ........: _GDE_Pie($hGraphics, $Left, $Top, $Radius, $StartAngle, $Sweepangle, $Color[, $Size = 1[, $BackColor = $GUI_GR_NOBKCOLOR]]) ; Parameters ....: $hGraphics - GDE Handle to draw to ; $Left - Distance to the Left Window Corner ; $Top - Distance to the Upper Window Corner ; $Radius - Radius of the Pie ; $StartAngle - Start Angle of the Pie ; $Sweepangle - Stop Angle of the Pie ; $Color - Color of the Pen to draw with ; $Size - [optional] Size of the Pen to draw with (default:1) ; $BackColor - [optional] The Color to fill the Pie with (default:$GUI_GR_NOBKCOLOR) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Pie($hGraphics, $Left, $Top, $Radius, $StartAngle, $Sweepangle, $Color, $Size = 1, $BackColor = $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color, $BackColor) GUICtrlSetGraphic($hGraphics, $GUI_GR_PIE, $Left, $Top, $Radius, $StartAngle, $SweepAngle) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Pixel() ; Description ...: Draws a Single Pixel ; Syntax ........: _GDE_Pixel($hGraphics, $Left, $Top, $Color[, $BackColor = $GUI_GR_NOBKCOLOR]) ; Parameters ....: $hGraphics - The GDE Handle to draw to ; $Left - The Distance to the Left Window Corner ; $Top - The Distanc to the Upper Window Corner ; $Color - The Color of the Pen to draw with ; $BackColor - [optional] The Color to fill the Pixel with (default:$GUI_GR_NOBKCOLOR) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Pixel($hGraphics, $Left, $Top, $Color, $BackColor = $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color, $BackColor) GUICtrlSetGraphic($hGraphics, $GUI_GR_PIXEL, $Left, $Top) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Point() ; Description ...: Draws a square Point ; Syntax ........: _GDE_Point($hGraphics, $Left, $Top, $Color[, $Size = 1[, $BackColor = $GUI_GR_NOBKCOLOR]]) ; Parameters ....: $hGraphics - The GDE Handle to draw to ; $Left - The Distance to the Left Window Corner ; $Top - The Distance to the Upper Window Corner ; $Color - The Color of the Pen to draw with ; $Size - [optional] The Size of the Pen to draw with (default:1) ; $BackColor - [optional] The Color to fill the Point with (default:$GUI_GR_NOBKCOLOR) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Point($hGraphics, $Left, $Top, $Color, $Size = 1, $BackColor = $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color, $BackColor) GUICtrlSetGraphic($hGraphics, $GUI_GR_DOT, $Left, $Top) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Rect() ; Description ...: Draws an Rectangle ; Syntax ........: _GDE_Rect($hGraphics, $Left, $Top, $Width, $Height, $Color[, $Size = 1[, $BackColor = $GUI_GR_NOBKCOLOR]]) ; Parameters ....: $hGraphics - The GDE Handle to draw to ; $Left - The Distance to the Left Window Corner ; $Top - The Distance to the Upper Window Corner ; $Width - The Width of the Rect ; $Height - The Height of the Rect ; $Color - The Color of the Pen to draw with ; $Size - [optional] The Size of the Pen to draw with (default:1) ; $BackColor - [optional] The Color to fill the Rect with (default:$GUI_GR_NOBKCOLOR) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Rect($hGraphics, $Left, $Top, $Width, $Height, $Color, $Size = 1, $BackColor = $GUI_GR_NOBKCOLOR) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color) GUICtrlSetGraphic($hGraphics, $GUI_GR_RECT, $Left, $Top, $Width, $Height) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Triangle() ; Description ...: Description ; Syntax ........: _GDE_Triangle($hGraphics, $x1, $y1, $x2, $y2, $x3, $y3, $Color[, $Size = 1]) ; Parameters ....: $hGraphics - The GDE Handle to draw to ; $x1 - The X Coordinate of the A Point of the Triangle ; $y1 - The Y Coordinate of the A Point of the Triangle ; $x2 - The X Coordinate of the C Point of the Triangle ; $y2 - The Y Coordinate of the C Point of the Triangle ; $x3 - The X Coordinate of the B Point of the Triangle ; $y3 - The Y Coordinate of the B Point of the Triangle ; $Color - The Color of the Pen to draw with ; $Size - [optional] The Size of the Pen to draw with (default:1) ; Author ........: campweb ; Modified ......: 18.8.2011 ; Related .......: _GDE_Create ; ================================================================================================= Func _GDE_Triangle($hGraphics, $x1, $y1, $x2, $y2, $x3, $y3, $Color, $Size = 1) GUICtrlSetGraphic($hGraphics, $GUI_GR_PENSIZE, $Size) GUICtrlSetGraphic($hGraphics, $GUI_GR_COLOR, $Color) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x1, $y1) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x2, $y2) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x2, $y2) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x3, $y3) GUICtrlSetGraphic($hGraphics, $GUI_GR_MOVE, $x1, $y1) GUICtrlSetGraphic($hGraphics, $GUI_GR_LINE, $x3, $y3) GUICtrlSetGraphic($hGraphics, $GUI_GR_CLOSE) EndFunc ; #FUNCTION# ====================================================================================== ; Name ..........: _GDE_Update() ; Description ...: Updates a dynamic GDE Handle ; Syntax ........: _GDE_Update($hGraphics) ; Parameters ....: $hGraphics - The GDE Handle to update ; Author ........: campweb ; Modified ......: 20.8.2011 ; ================================================================================================= Func _GDE_Update($hGraphics) GUICtrlSetGraphic($hGraphics, $GUI_GR_REFRESH) EndFunc