8月22022
GDI+示例2
GDI绘制
#include <GDIPLuS.au3>
Global Const $width = 460
Global Const $height = 400
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate("", $width, $height)
GUISetBkColor(0xFFFFFF)
GUISetOnEvent(-3, "close")
GUISetState()
_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$pen2 = _GDIPlus_PenCreate(0x4FBB00C7, 1)
_GDIPlus_GraphicsDrawLine($graphics, 230, 15, 230, 390, $pen2)
_GDIPlus_GraphicsDrawLine($graphics, 10, 200, 450, 200, $pen2)
_AntiAlias($graphics, 4)
Global $t = 0, $s
While 1
While $s < 4
For $i = 1 To 56
_GDIplus_GraphicsDrawArrow($graphics, 230, 200, 300, 7 * $i, 40, 60, $pen2)
Sleep(30)
;_GDIplus_GraphicsClear($graphics,0xFFFFFFFF)
Next
$s += 1
WEnd
Sleep (500)
_GDIplus_GraphicsClear($graphics,0xFFFFFFFF)
_GDIPlus_GraphicsDrawLine($graphics, 230, 15, 230, 390, $pen2)
_GDIPlus_GraphicsDrawLine($graphics, 10, 200, 450, 200, $pen2)
$s = 0
WEnd
Do
Sleep(100)
Until False
Func _GDIplus_GraphicsDrawArrow($hGraphics, $iX1, $iY1, $iX2, $iY2, $iArrowLength, $iArrowBase, $hPen)
Local $iLength
Local $iLengthWithoutArrow
Local $iAngle
Local $iArrowX
Local $iArrowY
$iArrowBase /= 2
$iLength = Sqrt(($iX2 - $iX1) ^ 2 + ($iY2 - $iY1) ^ 2)
$iLengthWithoutArrow = $iLength - $iArrowLength
Switch $s
Case 0
$iAngle = _ATan2(($iX1 - $iX2), ($iY1 - $iY2))
Case 1
$iAngle = _ATan2(($iX2 - $iX1), ($iY2 - $iY1))
Case 2
$iAngle = _ATan2(($iY2 - $iY1), ($iX2 - $iX1))
Case 3
$iAngle = _ATan2(($iY1 - $iY2), ($iX1 - $iX2))
EndSwitch
$iArrowX = $iX1 + ($iLengthWithoutArrow * Sin($iAngle))
$iArrowY = $iY1 - ($iLengthWithoutArrow * Cos($iAngle))
Local $Xa, $Ya, $Xb, $Yb, $Xc, $Yc
$Xa = $iArrowX - $iArrowBase * Cos($iAngle)
$Ya = $iArrowY - $iArrowBase * Sin($iAngle)
$Xb = $iArrowX + $iArrowBase * Cos($iAngle)
$Yb = $iArrowY + $iArrowBase * Sin($iAngle)
$Xc = $iArrowX + $iArrowLength * Sin($iAngle)
$Yc = $iArrowY - $iArrowLength * Cos($iAngle)
_GDIPlus_GraphicsDrawLine($hGraphics, $Xa, $Ya, $Xb, $Yb, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphics, $Xa, $Ya, $Xc, $Yc, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphics, $Xb, $Yb, $Xc, $Yc, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $iArrowX, $iArrowY, $hPen)
EndFunc ;==>_GDIplus_GraphicsDrawArrow
Func _AntiAlias($hGraphics, $iMode)
Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode)
If @error Then Return SetError(@error, @extended, False)
Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>_AntiAlias
Func close()
Exit
EndFunc ;==>close
Func _ATan2($nY, $nX)
Return SetError(0, 0, ATan($nY / $nX) + ((($nY <= 0) And ($nX < 0)) + (($nY > 0) And ($nX < 0)) - 2 * (($nY < 0) And ($nX < 0))) * 3.14159265358979323846)
EndFunc ;==>_ATan2
扫描二维码,在手机上阅读
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!