[Color]
Color ($color = 0x000000, $alpha = 0xff)

	Sets the drawing color in RGB format. The color will be used until changed.
	Decimal and Hexadecimal formats can be used. 	

	Example:

	Color (0xFF0000)
	Color (0x00FF00)
	Color (0x0000FF)  

	To change only the alpha value, set the color value to -1
	Alpha values are in between 0 and 255	

	Color (-1, 0xFF)     
	Color (-1, 255)    
	Color (-1, 30) 

	The RGB function is created for this case.

[RGB]
RGB ($R, $g, $b)

	Combines 3 values into a value useable by the color function.	

	R,G,B can be in the range of 0 to 255 (0x0 to 0xFF)
	Use this function to set the Rgb values in the color function.

	Example:
		Color (RGB(255,255,255))
		Color (RGB(0x11,0xFF,0x3F))
		Cls (RGB(255,0,0))

[GetColor]
GetColor ($x, $y)

	Returns the Pixel color from the current buffer at the specified coordinates.
	The returned value is in decimal. The alpha value is saved in $GetColorAlpha
	p.s. Clear the canvas with Cls(-1,0) to get the alpha color values, or you will get
	the wrong alpha values. 

	Example:
		$c=GetColor(10,30)

[PenSize]
PenSize ($size = 1)

	Sets the size of the Pen for the drawing functions that supports them.

	(Line, Rect, Circle, Ellipse, Pie, Polygon) 
	p.s. works only in non filled mode.

[Plot]
Plot ($x, $y, $size = 1)

	Draws a pixel on the current buffer. Increased size makes a filled Square.

[Line]
Line ($x, $y, $x1, $y1)

	Draws a Line at the specified coordinates.

[Rect]
Rect ($x, $y, $w, $h, $f = 0)

	Draws a Rectangle/Square at the specified coordinates with Width and Height as size
	 $f  = 1 creates a filled Rectangle	

[Circle]
Circle ($x, $y, $s, $f = 0)

	Draws a circle at the x,y coordinates with S as size
	$f  = 1 creates a filled Circle
	p.s. X,Y coordinate are at the top left side of the Circle 

[Ellipse]
Ellipse ($x, $y, $sx, $sy, $f = 0)

	Draws a Ellipse at the x,y coordinates with SX and SY as size
	$f  = 1 creates a filled Ellipse
	p.s. X,Y coordinate are at the top left side of the Ellipse 

[Pie]
Pie ($x, $y, $w, $h, $a1, $a2, $f = 0)

	Draws a Pie at the x,y coordinates with Width and Height as size
	a1  The angle, in degrees, between the X axis and the starting point of the arc that 
	      defines the pie. A positive value specifies clockwise rotation.
	a2 Same as a1 but for the End point.
	$f  = 1 creates a filled Pie
	p.s. X,Y coordinate are at the top left side of the Pie 

[Polygon]
Polygon ($f = 0, $str = "10,10;60,10;30,30;10,10")

	Draws a polygon. f 0/1 determines if it is filled or not. 
	This polygon type is Fixed, it is not freely moveable.
	Str needs to have a coordinate pairs, in X,Y format, in a STRING 
	The coordinates are separared by ; 
	You need at least 3 pairs of coordinates.
	The polygon needs to have Start and end points at the same coordinates. 
	If not, an ending line between start and end will be automatically added. (by the GDIP)

[DrawImage]
DrawImage ($hImage, $x, $y)

	Draws a loaded or created image at the x,y position without any scaling.

[DrawImageSize]
DrawImageSize ($hImage, $x, $y, $w, $h)

	Draws a loaded or created image at the X,Y position with Width and Height as size

[DrawImageZoom]
DrawImageZoom ($hImage, $sx, $sy, $sw, $sh, $dx, $dy, $dw, $dh)

	Copies a part of loaded or created image from a starting position SX,SY and SW,SH 
	(Width/Height) 
	and draws it at the DX,DY position with DW,DH (Width/Height) as size

[DrawAnimImage]
DrawAnimImage ($hImage, $x, $y, $w, $h, $frame = 1, $flip = 0)

	Draws an animated image at the position X,Y with W,H (Width/Height) 
	with frame as numbers in between 1 and xxx as pre-calculated by the SetAnimImage
	The image can be Flipped/Mirrored (see DrawImageFlip for the numbers)	

[SetAnimImage]
SetAnimImage ($hImage, $w, $h, $fw, $fh)

	Precalculates an image to be used with DrawAnimImage. 
	W,H determines the size of the single frame
	Fw,Fh = Frame count Horizontally/Vertically

	p.s. there is no error checking. 
	Image frames are positioned as in this example (fw=4 and fh=3):

********************
* 1 *  2 *  3 *  4 *
* 5 *  6 *  7 *  8 *
* 9 * 10 * 11 * 12 *
********************

[DrawImageFlip]
DrawImageFlip ($hImage, $x, $y, $w, $h, $flip)

	Draws an image to X,Y coordinates with W,H (Width/Height) size flipped or mirrored.	

 $a determines the rotation which can be one of this:
 0 - No rotation and no flipping (A 180-degree rotation, a horizontal flip and then a vertical flip)
 1 - A 90-degree rotation without flipping (A 270-degree rotation, a horizontal flip and then
       a vertical flip)
 2 - A 180-degree rotation without flipping 
      (No rotation, a horizontal flip followed by a vertical flip)
 3 - A 270-degree rotation without flipping 
      (A 90-degree rotation, a horiz. flip and then a vertical flip)
 4 - No rotation and a horizontal flip (A 180-degree rotation followed by a vertical flip)
 5 - A 90-degree rotation followed by a horizontal flip (A 270-degree rotation with a vertical flip)
 6 - A 180-degree rotation followed by a horizontal flip (No rotation and a vertical flip)
 7 - A 270-degree rotation followed by a horizontal flip (A 90-degree rotation with a vertical flip)	

[DrawRotate]
DrawRotate ($hImage, $iX, $iY, $w, $h, $fAngle, $flip)

	Draws an X,Y coordinates with W,H (Width/Height) size and freely rotated with fAngle
	Negative angle numbers will rotate it Anti-Clockwise. $flip flips the image 
	See DrawImageFlip for the explanation.	

[BlendMode]
BlendMode ($blend)

	Experimental - may or may not work, depending on the case.
	Turns the blending mode off or on (0/1) for the follow up commands (until changed)
	(the transparent bits of an image are drawn in solid color when turned on) 

[Flip]
Flip ($fps = 50, $sleep = 0) 

	This is needed for the canvas to be drawn at all. Standard fps value is 50.
	fps is optional and delays the frame rate down to the set fps value.
	p.s. It is a simple frame limiter for the faster machines, attempting to hold the set fps rate. 
	(may or may not be accurate).	When $sleep is set to 1 it adds a sleep (10) to each waiting 
	loop, but only if the frame rate is achieved. Calls a GetMouseCoords() as well.
	There is a known bug: Flip() does not show anything when it is called the first time.

[Cls]		
Cls ($c = -1, $a = -1)

	Clears the current (active) buffer in the Color and Alpha values.
	Cls remembers the values so that the next calls without parameters will use the same 
	color settings.

	Example:
		Cls (0x0)
		Cls (RGB(0xFF,255,255))

[SetBuffer]
SetBuffer ($b) 

	Changes a buffer to be used. all follow up commands will perform their operation on it.

	Usage example: SetBuffer (BackBuffer()) 
			 SetBuffer (ImageBuffer($hImage))

[BackBuffer]
BackBuffer () 

	Returns the handle of the BackBuffer. 
	Used in combination with SetBuffer()

[ImageBuffer]
ImageBuffer ($hImage)

	Returns the handle of one of the Images 
	Used in combination with SetBuffer()

[SaveImage]
SaveImage ($hImage, $FileName, $direct = 0)	

	Saves an Image  under the FileName path.
	if direct is set to 1, you can actually pass a custom loaded image handle 
	instead of the built in handle.
	Caution: This will overwrite any existing file, or may not save if the file is locked.

[LoadImage]
LoadImage ($sImage) 

	Loads an image into the ImageArray and returns the handle.
	Remember to always free an image before loading another into the same variable.

[CreateImage]
CreateImage ($w, $h)

	Creates an empty image with W/H (Width/Height) as size

[CloneImage]
CloneImage ($hImage, $direct = 0) 

	Creates a copy of an existing image and returns the handle to it.
	direct 1 is used to copy custom loaded images.

[ScreenShotImage]
ScreenShotImage ($x = 0, $y = 0, $x1 = -1, $y1 = -1, $hide = 0)			

	Takes a screenshot and Creates an image.
	if $x1 or $y1 are set to -1 then the Desktop Width/Height will be used
	if $hide is set to 1, the Gui Window will be hidden before the capture.

	Important: Multi monitor setups with different scaling sizes may take wrong screenshots
	Use the SetProcessDpiAwareness(2) at the top of your Screenshot taking script.

[FreeImage]
FreeImage ($hImage, $direct = 0) 

	Releases the used ressources.
	direct is used to release custom loaded image with _GDIPlus_BitmapDispose($hImage)


[ImageToClipboard]
ImageToClipboard ($hImage, $direct = 0)

	Copies an Image to the Clipboard.
	direct is used to copy a custom loaded image. (untested)

[CanvasToClipboard]
CanvasToClipboard ()
	
	Copies the current Canvas image into Clipboard.

[ClipboardToImage]
ClipboardToImage ()

	Copies the content of the Clipboard into one image slot and returns a handle to the image.

	Example:
		$clipimage = ClipboardToImage()
		DrawImage ($clipimage,0,0)

[AppTitle]
AppTitle ($newtitle = "GDIP Canvas")

	Sets a new app title 
	
	Example:
		AppTitle("Hello World")

[ImageWidth]
ImageWidth ($hImage, $direct = 0)
	
	Returns the width value of an loaded/created image.
	direct is used for the custom loaded images

	$image=LoadImage("test.png")
	$iw=ImageWidth($image)

[ImageHeight]
ImageHeight ($hImage, $direct = 0)

	Returns the Height value of an loaded/created image.
	direct is used for the custom loaded images
	
	$ih=ImageHeight($image)

[AnimWidth]
AnimWidth ($hImage)

	Returns the Width of a previously created AnimImage $hImage

[AnimHeight]
AnimHeight ($hImage) 

	Returns the Height of a previously created AnimImage $hImage

[CanvasWidth]
CanvasWidth ()

	Returns the total Width of the Canvas

[CanvasHeight]
CanvasHeight ()

	Returns the Total Height of the Canvas

[CanvasDrawWidth]
CanvasDrawWidth ()

	Returns the drawn Width of the Canvas

[CanvasDrawHeight]
CanvasDrawHeight ()

	Returns the drawn Height of the Canvas

[Rand]
Rand ($min = 0, $max = 1)

	Returns a random integer numbers in range of min, max

[Text]
Text ($txt, $x, $y, $font = "Arial", $size = 12, $format = 0x0)

	Draws a Text at X,Y coordinates with Custom defined Font, size and format bypassing 
	the built in font.

Format flags can be one or more of the following. Default = 0 :
0x0001 -  Reading order is right to left
0x0002 - Individual lines of text are drawn vertically on the display device
0x0004 - Parts of characters are allowed to overhang the string's layout rectangle
0x0020 - Unicode layout control characters are displayed with a representative character
0x0400 - An alternate font is used for characters that are not supported in the requested font
0x0800 - The space at the end of each line is included in a string measurement
0x1000 - The wrapping of text to the next line is disabled
0x2000 - Only entire lines are laid out in the layout rectangle
0x4000 - Characters overhanging the layout rectangle and text extending outside the 
	    layout rectangle are allowed to show

	Example:
		Text ("A U T O  IT", 20, 30, "Arial", 12, BitOr(0x1,0x2,0x4, 0x20) )

[Print]
Print ($txt, $x, $y)

	Draws a text at X,Y coordinates.
	See SetFont() and LoadFont() commands

	Example:
		LoadFont(1,"Arial", 9, FontStyle(0,1,0,0))
		SetFont (1)
		Print ("Hello", 3,10)

[SetFont]
SetFont ($nr)

	Changes a font to a previously loaded font. (p.s. It ignores any unused numbers.)
	In multiple font settings, if a font is released and switched to the freed number, it will not
	change the font and previous font may be used.
	Nr can be in range of 1-20 (by default) ... unless it was changed in the GDIP_Canvas.au3

[FontStyle]
FontStyle ($bold = 0, $Italic = 0, $Underline = 0, $strikethrough = 0)		 

	Sets a font style flags (or combination of them).
	Used with the LoadFont () command

	Example 
		LoadFont(1,"Arial", 9, FontStyle(0,1,1,0))

[LoadFont]
LoadFont ($nr, $FontName = "Arial", $size = 12, $style = 0)			

	$nr has to be in range of 1 to Ubound($CanvasINC_Font,1)-1
	Font name has to be a valid font family name like "Arial" or "Consolas"	
	Font size may or may not work for every font.
	The style of the typeface can be a combination of the following 
	(or use the FontStyle() command) : 

		0 - Normal weight or thickness of the typeface
		1 - Bold typeface
		2 - Italic typeface
		4 - Underline
		8 - Strikethrough

	Example:
		LoadFont(1,"Consolas", 11, 3)

[FreeFont]
FreeFont ($nr)
	
	Releases the font ressources used for the Print command.
	If you release an currently used font number, the print command will display nothing.

[FontSize]
FontSize ()
	
	Returns the current font Size 

[FontName]
FontName ()

	Returns the current font Name.

[MouseX]
MouseX () 
	
	Returns the MouseX coordinates when the GetMouseCoords() was used, previously
	This is Canvas (size) based X coordinate.

	Example:
		While 1
			GetMouseCoords()
			$mx=MouseX()
			Print ($mx,0,0)
			Flip()
		Wend

[MouseY]
MouseY ()

	Returns the MouseY coordinates when the GetMouseCoords() was used, previously.
	This is Canvas (size) based Y coordinate.

	Example:
		While 1
			GetMouseCoords()
			$my=MouseY()
			Print ($my,0,0)
			Flip()
		Wend

[MouseRX]
MouseRX ()

	Returns the MouseRY coordinates when the GetMouseCoords() was used, previously
	This is Global but Relative to the client area X coordinate.

[MouseRY]
MouseRY () 

	Returns the MouseRY coordinates when the GetMouseCoords() was used, previously
	This is Global but Relative to the client area Y coordinate. 

[MouseGX]
MouseGX () 

	Returns the MouseGY coordinates when the GetMouseCoords() was used, previously
	This is Global (desktop) X mouse coordinate. 

[MouseGY]
MouseGY ()  

	Returns the MouseGY coordinates when the GetMouseCoords() was used, previously
	This is Global (desktop) Y mouse coordinate.	

[MouseZ]
MouseZ () 
	
	Returns the Mouse Wheel position. 

	Example:

		Global $TMPMW="" , $tmp , $x=0

		While GUIGetMsg()<>-3
			cls()

			$TMPMW=MouseZ()
			$x=$x+$TMPMW
	
			if $TMPMW=1 then
				$tmp="Up"
			ElseIf $TMPMW=-1 Then
				$tmp="Down"
			EndIf
	
			Print ("Mouse Wheel is moving " & $tmp,0,0)
			Print ($x,0,20)
			Flip(20)
		Wend

[GetMouseCoords]
GetMouseCoords ()        

	Use this function once in the main loop to get the mouse coordinates
	(p.s. Flip() is calling this function as well. If you are using flip then you do not need to
	use this again. It is added for the cases where you might want to get the coordinates 
	without using the canvas at all.)

[KeyDown]
KeyDown ($key = "")

	Available keys:

	Up, Down, Left, Right, Space, Ctrl, Alt, Shift, Enter,
	Lmouse, Rmouse, Mmouse,
	LShift, RShift, Lctrl, Rctrl, ESC
	F1-F12
	
	Example:
		If Keydown("up") then Print ("Arrow up",0,0)
		If Keydown("left") then Print ("Arrow Left",0,20)
		If Keydown("Mmouse") then Print ("Middle Mouse Button",0,40)
		If Keydown("F1") then Print ("F1 Pressed",0,60)

[Window]
Window ($title = "Canvas", $WW = 320, $WH = 240, $PX = -1, $PY = -1)	

	Opens the Gui Window for use with the canvas. 
	Canvas command is opening this automatically, if the gui window is not open.

	Example:
		Window ("Example 01", 600,300)

[Canvas]
Canvas ($width = 320, $height = 240, $PosX = 0, $PosY = 0) 

	Creates the canvas with the Specified Width and Height and optionally sets the 
	drawing place	which defaults to the 0,0 position.
	Canvas will call the Window function automatically, if it is not open. The window will 
	have the Width and the Height of the Canvas.

	Example:
		Canvas (320,320,0,30)

[SetCanvas]
SetCanvas ($x = -1, $y = -1, $w = -1, $h = -1, $ZoomOff = 0)

	Sets (changes) the Canvas to a new Coordinate or to a new Size.
	If the opened canvas Width and Height are smaller than this command Width/Height, 
	the Canvas will be displayed as zoomed in or Zoomed out (if smaller).
	ZoomOff when set to 1 will resize the Canvas to the new size.
	If the new canvas size is bigger than the Created size, the canvas will be 
	automatically Resized.This may cause a loss of whatever was drawn on it, previously.

	Example:
		Window("Scaled up Canvas",640,320)		
		Canvas(320,160)		;Small sized canvas
		SetCanvas (0,0,640,320)	;Creates a Canvas scaled up to the Window size.

[SetGuiStyle]
SetGuiStyle ($style = BitOR($WS_SIZEBOX, $WS_CAPTION))			

	Sets a Style for the window. This needs to be called Before the window is opened.
	
	Example:
		SetGuiStyle ($WS_POPUP)
		Window ("Popup window style",640,480,0,30)

[SetGuiExStyle]
SetGuiExStyle ($style = $WS_EX_WINDOWEDGE)

	Sets an Extended Style for the window. This needs to be called Before the window is
	opened.

	Example:
		SetGuiExStyle (BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
		Window ("Layered window EX style",640,480,0,30)

[GuiHWND]
GuiHWND ()                                                                                                                                  
	Returns the handle of the window, which is alternatively saved in the $hGui 

[Debug] 
Debug ($on = 1)                                                                                                                               	
	Turns the debugging information on/off. ( 0 or 1)
 	Not every command has debugging information available.
	The error information will be displayed in the Scite console.
	The error codes numbers are listed at the bottom of this document.

[GetLoadNameDialog]
GetLoadNameDialog($file = @ScriptDir, $title = "Open Image", $typ = 1) 	

	Opens an  File Open dialog and returns the filename. 
	
	$file should contain the folder to be opened.
	$typ 1 will set the filter to image files (png, jpg, bmp, gif, tiff)
	$typ 0 will ser the filter to All Files (*.*)
	
	Example usage:
		$fname = GetLoadNameDialog()
		If @error=0 Then
			ConsoleWrite("Filename: " & $fname & @crlf)
		Else
			ConsoleWrite("Invalid filename" & $fname & @crlf )
		EndIf

	p.s. always check if @error is 0 because the returned filename is the same as $file, if
	the selection was invalid or cancelled.

[GetSaveNameDialog]
GetSaveNameDialog($file = @ScriptDir, $title = "Save Image", $typ = 1)            

	Opens an File Save dialog, and returns a valid Filename (with extension)
	
	$file should contain the folder to be opened.

	$typ 1 will set the filter to image files (png, jpg, bmp, gif, tiff)
	the extension will be added for the selected image type.

	$typ 0 will ser the filter to All Files (*.*)
	the extension will not be added here.	

	If a filename exists, the user will be asked to overwrite the file or to change the name.

	Example usage:
		$fname = @scriptdir & "test.png"
		$fname = GetSaveNameDialog($fname)
		If @error=0 Then
			ConsoleWrite("Filename: " & $fname & @crlf)
		Else
			ConsoleWrite("Invalid filename" & $fname & @crlf )
		EndIf

	p.s. always check if @error is 0 because the returned filename is the same as $file, if
	the selection was invalid or cancelled.

	p.p.s this does not check if the place has writing permissions.

[SetProcessDpiAwareness]
SetProcessDpiAwareness($DPIAware=2)

	Sets the DpiAwareness for the Current App. 
	This is needed for taking Screenshots on differently scaled (multi-monitor) setups !
	Use it at the beginning of your Script with the default value of 2

	Valid arguments are:

	$PROCESS_DPI_UNAWARE 		    = 0
	$PROCESS_SYSTEM_DPI_AWARE 	    = 1
	$PROCESS_PER_MONITOR_DPI_AWARE  = 2
