#include <GDIPlus.au3>
#include <GDIPlusConstants.au3>

Opt("GUIOnEventMode", 1)

Global $hWnd, $hGraphic, $hBitmap, $backbuffer
Global $title = "GDI+ LiveEditor", _
	   $width = 300, _
	   $height = 300

_Startup()

While 1
	Sleep(100)
	_Update()
WEnd

Func _Startup()
	$hWnd = GUICreate($title, $width, $height, -1, -1)
	GUISetOnEvent(-3, "_Shutdown")
	GUISetState()

	_GDIPlus_Startup()
	$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
	$hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
	$backbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
EndFunc

Func _Shutdown()
	_GDIPlus_GraphicsDispose($backbuffer)
	_GDIPlus_BitmapDispose($hBitmap)
	_GDIPlus_GraphicsDispose($hGraphic)
	_GDIPlus_Shutdown()
	GUIDelete($hWnd)
	Exit
EndFunc

Func _Update()
	_GDIPlus_GraphicsClear($backbuffer, 0xFFFFFFFF)
	_GDIPlus_GraphicsDrawLine($backbuffer, 137, 137, 162, 163)
	_GDIPlus_GraphicsDrawLine($backbuffer, 162, 137, 137, 163)
	_GDIPlus_GraphicsDrawLine($backbuffer, 137, 137, 1, 163)
	_GDIPlus_GraphicsDrawLine($backbuffer, 137, 163, 1, 137)
	_GDIPlus_GraphicsDrawLine($backbuffer, 137, 0, 162, 137)
	_GDIPlus_GraphicsDrawLine($backbuffer, 162, 0, 137, 137)
	_GDIPlus_GraphicsDrawLine($backbuffer, 162, 137, 298, 163)
	_GDIPlus_GraphicsDrawLine($backbuffer, 298, 137, 162, 163)
	_GDIPlus_GraphicsDrawLine($backbuffer, 137, 163, 162, 298)
	_GDIPlus_GraphicsDrawLine($backbuffer, 162, 163, 137, 298)
	_GDIPlus_GraphicsDrawLine($backbuffer, 0, 0, 299, 299)
	_GDIPlus_GraphicsDrawLine($backbuffer, 299, 0, 0, 299)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 0, 0, 299, 299)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 1, 137, 136, 26)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 1, 25, 136)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 162, 163, 136, -26)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 163, 25, 135)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 137, 25, 26)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 0, 0, 137, 137)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 299, 0, -137, 137)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 163, -137, 136)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 162, 163, 137, 136)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 163, -93, 92)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 162, 163, 93, 92)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 162, 137, 93, -93)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 137, -93, -93)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 20, 20, 24, 24)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 279, 20, -24, 24)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 279, 279, -24, -24)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 20, 279, 24, -24)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 298, -93, -43)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 0, 163, 44, 92)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 1, 137, 43, -93)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 137, 1, -93, 43)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 162, 1, 93, 43)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 298, 137, -43, -93)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 298, 163, -43, 92)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 162, 298, 93, -43)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 0, 299, 44, -44)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 0, 0, 44, 44)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 299, 0, -44, 44)
	_GDIPlus_GraphicsDrawEllipse($backbuffer, 299, 299, -44, -44)
	_GDIPlus_GraphicsDrawRect($backbuffer, 0, 0, 299, 299)
	_GDIPlus_GraphicsDrawRect($backbuffer, 1, 137, 297, 26)
	_GDIPlus_GraphicsDrawRect($backbuffer, 137, 1, 25, 297)
	_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height)
EndFunc
