Hi
In der GDIp.au3 gibt es die Funktion _GDIPlus_MatrixTransformPoints
damit kann man z.B. Koordinaten, die sich in einem normalen Array befinden mit einer GDI+Matrix multiplizieren
Kann manchmal ganz nützlich sein
Hier ein kurzes Beispiel:
Spoiler anzeigen
#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{ESC}", "_Exit")
[/autoit] [autoit][/autoit] [autoit]Global Const $PI = ATan(1) * 4
Global Const $DegToRad = $PI / 180
Global $aPoints[10][2]
$aPoints[0][0] = 9
For $i = 1 To 9
$aPoints[$i][0] = Cos($i * 40 * $DegToRad) * 200 + 400
$aPoints[$i][1] = Sin($i * 40 * $DegToRad) * 200 + 300
Next
Global $aGui[10]
For $i = 1 To 9
$aGui[$i] = GUICreate("", 100, 100, $aPoints[$i][0], $aPoints[$i][1])
GUISetState()
Next
_GDIPlus_Startup()
Global $hMatrixRotate = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrixRotate, 400, 300)
_GDIPlus_MatrixRotate($hMatrixRotate, 1)
_GDIPlus_MatrixTranslate($hMatrixRotate, -400, -300)
Global $hMatrixScale = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($hMatrixScale, 400, 300)
_GDIPlus_MatrixScale($hMatrixScale, 2, 1)
_GDIPlus_MatrixTranslate($hMatrixScale, -400, -300)
Global $aPointsNew
[/autoit] [autoit][/autoit] [autoit]While 1
$aPoints = _GDIPlus_MatrixTransformPoints($hMatrixRotate, $aPoints)
$aPointsNew = _GDIPlus_MatrixTransformPoints($hMatrixScale, $aPoints)
For $i = 1 To $aPointsNew[0][0]
WinMove($aGui[$i], "", $aPointsNew[$i][0], $aPointsNew[$i][1], 100, 100)
Next
Sleep(10)
WEnd
Func _Exit()
_GDIPlus_MatrixDispose($hMatrixRotate)
_GDIPlus_MatrixDispose($hMatrixScale)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_MatrixTransformPoints
; Description ...: Multiplies each point in an array by a matrix
; Syntax.........: _GDIPlus_MatrixTransformPoints($hMatrix, $aPoints)
; Parameters ....: $hMatrix - Pointer to a Matrix object
; $aPoints - Array of points to be transformed:
; |[0][0] - Number of points
; |[1][0] - Point 1 X coordinate
; |[1][1] - Point 1 Y coordinate
; |[2][0] - Point 2 X coordinate
; |[2][1] - Point 2 Y coordinate
; |[n][0] - Point n X coordinate
; |[n][1] - Point n Y coordinate
; Return values .: Success - Array containing the transformed points:
; |[0][0] - Number of points
; |[1][0] - Transformed point 1 X coordinate
; |[1][1] - Transformed point 1 Y coordinate
; |[2][0] - Transformed point 2 X coordinate
; |[2][1] - Transformed point 2 Y coordinate
; |[n][0] - Transformed point n X coordinate
; |[n][1] - Transformed point n Y coordinate
; Failure - -1 and either:
; |@error and @extended are set if DllCall failed
; |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: Each point in the array is treated as a row matrix. The multiplication is performed with the row matrix on the
; +left and the matrix on the right
; Related .......: _GDIPlus_MatrixTransformPointsI
; Link ..........; @@MsdnLink@@ GdipTransformMatrixPoints
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_MatrixTransformPoints($hMatrix, $aPoints)
Local $iI, $iCount, $tPoints, $pPoints, $aResult
$iCount = $aPoints[0][0]
$tPoints = DllStructCreate("float[" & $iCount * 2 & "]")
$pPoints = DllStructGetPtr($tPoints)
For $iI = 1 To $iCount
DllStructSetData($tPoints, 1, $aPoints[$iI][0], ($iI - 1) * 2 + 1)
DllStructSetData($tPoints, 1, $aPoints[$iI][1], ($iI - 1) * 2 + 2)
Next
$aResult = DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", $pPoints, "int", $iCount)
If @error Then Return SetError(@error, @extended, -1)
$GDIP_STATUS = $aResult[0]
If $GDIP_STATUS Then Return -1
For $iI = 1 To $iCount
$aPoints[$iI][0] = DllStructGetData($tPoints, 1, ($iI - 1) * 2 + 1)
$aPoints[$iI][1] = DllStructGetData($tPoints, 1, ($iI - 1) * 2 + 2)
Next
Return $aPoints
EndFunc ;==>_GDIPlus_MatrixTransformPoints
Bei großen Arrays sollte man gleich DllStructs statt Arrays verwenden, damit nicht jedesmal umgewandelt werden muß...
E