Sign in to follow this  
Followers 0
monoceres

Math + GDI+ question

10 posts in this topic

Hi!

I have struggled with this function today and just when I thought that it was perfect I find a bug that I can't get my head around how to solve.

Here's the function, and sample code that shows the problem.

#include <GDIPLuS.au3>
#include <math.au3>
Global Const $width = 500
Global Const $height = 300
Global Const $PI = 3.14159
Opt("GUIOnEventMode", 1)

$hwnd = GUICreate("Arrow", $width, $height)
GUISetOnEvent(-3, "close")
GUISetState()

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$pen2 = _GDIPlus_PenCreate(0xFF0000FF, 1)
_AntiAlias($graphics,4)

; Works like it should:
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2-50, 450, $height / 2+50, 20, 25, $pen2)
Sleep(2000)
_GDIplus_GraphicsClear($graphics,0xFFFFFFFF)
; $iY1 > $iY2 so the arrow f's up
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2, 450, $height / 2-50, 20, 25, $pen2)

Func _GDIplus_GraphicsDrawArrow($hGraphics, $iX1, $iY1, $iX2, $iY2,  $iArrowLength,$iArrowBase, $hPen)
    
    If $iY1>$iY2 Then
       ; Do something intelligent
    EndIf
    
    Local $iLength
    Local $iLengthWithoutArrow
    Local $iAngle
    Local $iArrowX
    Local $iArrowY
    Local $iC
    Local $iXRatio
    Local $iYRatio
    
    $iArrowBase /= 2
    $iLength = Sqrt(($iX2 - $iX1) ^ 2 + ($iY2 - $iY1) ^ 2); Thx to pythagora
    $iLengthWithoutArrow = $iLength - $iArrowLength; = Length without the arrow
    $iAngle = ASin(($iX2 - $iX1) / $iLength); The angle of the entire line, relative to the Y axis
    $iArrowX = $iX1 + ($iLengthWithoutArrow * Sin($iAngle)) 
    $iArrowY = $iY1 + ($iLengthWithoutArrow * Cos($iAngle)) 

   ;MsgBox(0,"",$iAngle)
    $iC = Sqrt(($iArrowLength) ^ 2); The longest side in the triangle

    $iXRatio = $iC * Cos($iAngle) / ($iArrowLength / $iArrowBase) 
    $iYRatio = $iC * Sin($iAngle) / ($iArrowLength / $iArrowBase)

    _GDIPlus_GraphicsDrawLine($hGraphics, $iArrowX, $iArrowY, $iArrowX - $iXRatio, $iArrowY + $iYRatio, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iX2, $iY2, $iArrowX - $iXRatio, $iArrowY + $iYRatio, $hPen)

    _GDIPlus_GraphicsDrawLine($hGraphics, $iArrowX, $iArrowY, $iArrowX + $iXRatio, $iArrowY - $iYRatio, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iX2, $iY2, $iArrowX + $iXRatio, $iArrowY - $iYRatio, $hPen)


    _GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $iArrowX, $iArrowY, $hPen)
EndFunc  ;==>_GDIplus_GraphicsDrawArrow



Do
    Sleep(100)
Until False

Func _AntiAlias($hGraphics, $iMode)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "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

I just can't get my head around getting it to work when $iY1>$iY2.

Thanks in advance :P


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I think it's that line when assigning $iArrowY

edit:

try this

#include <GDIPLuS.au3>
#include <math.au3>
Global Const $width = 500
Global Const $height = 400
Global Const $PI = 3.14159
Opt("GUIOnEventMode", 1)

$hwnd = GUICreate("Arrow", $width, $height)
GUISetOnEvent(-3, "close")
GUISetState()

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$pen2 = _GDIPlus_PenCreate(0xFF0000FF, 1)
_AntiAlias($graphics,4)

; Works like it should:
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2-50, 450, $height / 2+50, 20, 25, $pen2)
Sleep(2000)
_GDIplus_GraphicsClear($graphics,0xFFFFFFFF)
; $iY1 > $iY2 so the arrow f's up
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2-50, 450, $height / 2-50, 20, 25, $pen2)

Func _GDIplus_GraphicsDrawArrow($hGraphics, $iX1, $iY1, $iX2, $iY2, $iArrowLength, $iArrowBase, $hPen)

    If $iY1 > $iY2 Then
        ; Do something intelligent
    EndIf

    Local $iLength
    Local $iLengthWithoutArrow
    Local $iAngle
    Local $iArrowX
    Local $iArrowY
    Local $iC
    Local $iXRatio
    Local $iYRatio

    $iArrowBase /= 2
    $iLength = Sqrt(($iX2 - $iX1) ^ 2 + ($iY2 - $iY1) ^ 2); Thx to pythagora
    $iLengthWithoutArrow = $iLength - $iArrowLength; = Length without the arrow
    $iAngle = ASin(($iX2 - $iX1) / $iLength); The angle of the entire line, relative to the Y axis
    $iArrowX = $iX1 + ($iLengthWithoutArrow * Sin($iAngle))
    $iArrowY = $iY1 - ($iLengthWithoutArrow * Cos($iAngle)) ; <-- this line!!!

    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



Do
    Sleep(100)
Until False

Func _AntiAlias($hGraphics, $iMode)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "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

I had to make it a bit larger. :P

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is my attempt.

#include <GDIPLuS.au3>
#include <math.au3>
Global Const $width = 500
Global Const $height = 300
Global Const $PI = 3.14159
Opt("GUIOnEventMode", 1)

$hwnd = GUICreate("Arrow", $width, $height)
GUISetOnEvent(-3, "close")
GUISetState()

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$pen2 = _GDIPlus_PenCreate(0xFF0000FF, 1)
_AntiAlias($graphics, 4)

_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2 - 50, 450, $height / 2 + 50, 20, 25, $pen2)
Sleep(2000)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
_GDIplus_GraphicsDrawArrow($graphics, 450, $height / 2, 50, $height / 2 - 50, 20, 25, $pen2)
Sleep(2000)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2+50, 450, $height / 2 - 50, 20, 25, $pen2)
Sleep(2000)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
_GDIplus_GraphicsDrawArrow($graphics, 450, $height / 2 - 50, 50, $height / 2 , 20, 25, $pen2)
Sleep(2000)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
_GDIplus_GraphicsDrawArrow($graphics, 450, $height / 2 - 50, 50, $height / 2 - 50, 20, 25, $pen2)
Sleep(2000)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2 - 50, 450, $height / 2 - 50, 20, 25, $pen2)
Sleep(2000)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2 - 50, 50, $height / 2 + 50, 20, 25, $pen2)
Sleep(2000)
_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)
_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2 + 50, 50, $height / 2 - 50, 20, 25, $pen2)

Do
    Sleep(100)
Until False

Func _GDIplus_GraphicsDrawArrow($hGraphics, $iX1, $iY1, $iX2, $iY2, $iArrowLength, $iArrowBase, $hPen)
    Local $m = ATan(($iY2 - $iY1) / ($iX2 - $iX1))
    $m = $m + ((($iY2 - $iY1) >= 0)  And (($iX2 - $iX1) >= 0)) * $PI
    $m = $m + ((($iY2 - $iY1) <  0)  And (($iX2 - $iX1) >= 0)) * $PI
    Local $By = $iY2 + ($iArrowLength * Sin(($m)))
    Local $Bx = $iX2 + ($iArrowLength * Cos(($m)))
    Local $By1 = $By + ($iArrowBase / 2 * Sin(($m - $PI / 2)))
    Local $Bx1 = $Bx + ($iArrowBase / 2 * Cos(($m - $PI / 2)))
    Local $By2 = $By + ($iArrowBase / 2 * Sin(($m + $PI / 2)))
    Local $Bx2 = $Bx + ($iArrowBase / 2 * Cos(($m + $PI / 2)))

    _GDIPlus_GraphicsDrawLine($hGraphics, $iX2, $iY2, $Bx1, $By1, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iX2, $iY2, $Bx2, $By2, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $Bx, $By, $Bx1, $By1, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $Bx, $By, $Bx2, $By2, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $Bx, $By, $hPen)
EndFunc   ;==>_GDIplus_GraphicsDrawArrow

Func _AntiAlias($hGraphics, $iMode)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "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
Edited by Malkey

Share this post


Link to post
Share on other sites

Thanks Malkey & trancexx. Both your scripts works well, Malkey's solution was a bit more advanced so I will have to study it before understanding it properly.

Thanks again :P


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

When testing trancexx's example, I noticed that these two _GDIplus_GraphicsDrawArrow() function calls display the arrow pointing up.

_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2 - 50, 50, $height / 2 + 50, 20, 25, $pen2)

Sleep(2000)

_GDIPlus_GraphicsClear($graphics, 0xFFFFFFFF)

_GDIplus_GraphicsDrawArrow($graphics, 50, $height / 2 + 50, 50, $height / 2 - 50, 20, 25, $pen2)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I was doing something with math these days and came up with this (for this) along the road:

#include <GDIPLuS.au3>
Global Const $width = 460
Global Const $height = 400

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate("Arrows", $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($ghGDIPDll, "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
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

I was doing something with math these days and came up with this (for this) along the road:

#include <GDIPLuS.au3>
Global Const $width = 460
Global Const $height = 400

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate("Arrows", $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($ghGDIPDll, "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
i am running it now , it is amazing

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

i am running it now , it is amazing

yes, it's kind of hipnotising

try randomizing $iArrowLength or $iArrowBase or even color of the pen to have more effects.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

it does some amazing effects on changing them , look at that one

you know this function could be a great intro in a program by changing the variables for several effects

#include <GDIPLuS.au3>
Global Const $width = 460
Global Const $height = 400

Opt("GUIOnEventMode", 1)

$hwnd = GUICreate("Arrows", $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, 100, 900, $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($ghGDIPDll, "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
Edited by komalo

[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0