Hi,
ich finde irgendwie nicht die Lösung die 4 Punkte so zu verschieben, sodass dieser Effekt entsteht:
Das ist mein bisheriger Code:
C
#pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico")
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so /pe /rm
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3"
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
Global $hGUI, $hCanvas, $hPen, $iFPS = 0, $iShowFPS = 0, $bExit
Global Const $iW = 800, $iH = 600, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ Test"
Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi
AutoItSetOption("GUIOnEventMode", 1)
AutoItSetOption("MouseCoordMode", 0)
GDIPlus_Test()
AutoItSetOption("GUIOnEventMode", 0)
_GDIPlus_Shutdown()
Func GDIPlus_Test()
$bExit = False
$hGUI = GUICreate($sTitle, $iW, $iH) ;, 0, 0, $WS_POPUP)
GUISetState(@SW_SHOW, $hGUI)
;~ GUISetCursor(16, 1)
;create canvas elements
Local Const $hDC = _WinAPI_GetDC($hGUI)
Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC)
Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap)
$hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer)
_GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
_GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFF000000), _
$hBrush_FPS = _GDIPlus_BrushCreateSolid(0xF0A0A0A0), _
$hFormat_FPS = _GDIPlus_StringFormatCreate(), _
$hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _
$hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _
$tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 60, 16)
$hPen = _GDIPlus_PenCreate(0xFFFFFFFF)
$iFPS = 0
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About")
AdlibRegister("CalcFPS", 1000)
Local $moveForce = 40, $rotateForce = 80, $aMpos, $moveX, $moveY
Local $tCoords = DllStructCreate("float x1; float y1;float x2; float y2;float x3; float y3;float x4; float y4")
$tCoords.x1 = 200
$tCoords.y1 = 100
$tCoords.x2 = 600
$tCoords.y2 = 100
$tCoords.x3 = 200
$tCoords.y3 = 500
$tCoords.x4 = 600
$tCoords.y4 = 500
Do
DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, _
"float", $iW, "float", $iH) ;erase canvas background
DrawRect($tCoords, $moveForce, $rotateForce)
_GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS, $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) ;draw background message text
_WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI
$iFPS += 1
If $bExit Then ExitLoop
Until Not Sleep(30)
AdlibUnRegister("CalcFPS")
;release resources
_GDIPlus_FontDispose($hFont_FPS)
_GDIPlus_FontFamilyDispose($hFamily_FPS)
_GDIPlus_StringFormatDispose($hFormat_FPS)
_GDIPlus_BrushDispose($hBrush_Clr)
_GDIPlus_BrushDispose($hBrush_FPS)
_GDIPlus_GraphicsDispose($hCanvas)
_WinAPI_SelectObject($hDC_backbuffer, $DC_obj)
_WinAPI_DeleteDC($hDC_backbuffer)
_WinAPI_DeleteObject($hHBitmap)
_WinAPI_ReleaseDC($hGUI, $hDC)
GUIDelete($hGUI)
EndFunc ;==>GDIPlus_Test
Func DrawRect(ByRef $tCoords, $moveForce, $rotateForce)
Local $aMpos = GUIGetCursorInfo($hGUI)
$moveX = ($aMpos[0] - $iWh) / $iWh * -$moveForce
$moveY = ($aMpos[1] - $iHh) / $iHh * -$moveForce
$rotateX = -(($aMpos[1] / $iH * $rotateForce * 2) - $rotateForce) * $fRad
$rotateY = (($aMpos[0] / $iW * $rotateForce * 2) - $rotateForce) * $fRad
;xy1 xy2
;
;xy3 xy4
Local $x1 = $tCoords.x1 + $moveX * Cos($rotateX), $y1 = $tCoords.y1 + $moveY * Sin($rotateY), _
$x3 = $tCoords.x3 - $moveX * Cos(-$rotateX), $y3 = $tCoords.y3 - $moveY * Sin(-$rotateY), _
$x2 = $tCoords.x2 + $moveX * Sin($rotateX), $y2 = $tCoords.y2 + $moveY * Cos($rotateY), _
$x4 = $tCoords.x4 - $moveX * Sin(-$rotateX), $y4 = $tCoords.y4 - $moveY * Cos(-$rotateY)
_GDIPlus_GraphicsDrawLine($hCanvas, $x1, $y1, $x2, $y2, $hPen)
_GDIPlus_GraphicsDrawLine($hCanvas, $x3, $y3, $x4, $y4, $hPen)
_GDIPlus_GraphicsDrawLine($hCanvas, $x1, $y1, $x3, $y3, $hPen)
_GDIPlus_GraphicsDrawLine($hCanvas, $x2, $y2, $x4, $y4, $hPen)
EndFunc
Func _Exit_About()
$bExit = True
EndFunc ;==>_Exit_About
Func CalcFPS() ;display FPS
$iShowFPS = $iFPS
$iFPS = 0
EndFunc ;==>CalcFPS
Alles anzeigen
Hat jemand die Idee, wie ich die 4 Punkte gemäß des CodePen Demos bewegen kann?