Jump to content

Graphic Art/Artist


Malkey
 Share

Recommended Posts

Things you can try with this script:- post-31256-1216193861_thumb.png

Change shape by dragging a point

Left mouse click on red point/dot until the tooltip about point appears and dot turn green. This point is now selected and dragable.

If point 0 (center color point) is selected to drag, go to context menu and click "Manually Move Center Color Point". This stops the center color point (point zero) from auto moving to the centroid of the graphics. Then the center color point is dragable

Save your creation as png file

Before you save the graphic image (press "Save as PNG File " on context menu), the image may look better without the dots. Press "Show points". This toggles hide/show points/dots.

Other

Change color of surround colors, center color, and Alpha channel intensity (visibility). Also you can apply Gamma correction, move center color point, save the current array values to text file (opens in Notepad), add/delete a point, multi-select points to change its color or change Alpha value, enter a margin value (use if point is placed off BkGnd transparent GUI, and auto used to center image when save to file), toggle closed curve/polygon (closed curve doesn't work too well, looks best on concave curves).

Note :- Initially, the red dot may need numerous mouse clicks to get it selected. And, if multi-select GUI is visible, dots can not be selected.

Have moved script to second post.

(Each time I've edited this post, I've copied everything. The post edit box is always blank.)

Enjoy.

Edit: Added Picture

Edit2: Fiddled with script. Now, if you change the point colour, the alpha channel for that point colour does not change.

Edit3: Fix Add /Delete point after thoughtless fiddle.

Edit4: Added Gamma Correction Toggle to context menu.

Edit5: Fixed check/uncheck on Gamma Correction menu & Removed If-Then entered T/F Variable in Gamma Correction call. Added more info about script, what it does.

Edited by Malkey
Link to comment
Share on other sites

Edit6: Made transparent background GUI full desktop size.

Edit7: Updated to run on AutoIt version 3.3.6.1 (on 31/10/2010).

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <GuiSlider.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
#include <misc.au3>
#include <GuiMenu.au3>
#include <WinAPI.au3>

Global Const $iOpacity = 255
Global $hGui, $hGraphic, $hBitmap, $hBrush, $hBrush, $SBoth, $GrnPt, $hBrushGrad, $pt = 0
Global $AutoCenterPoint, $init = 0, $centerFlagAutoOn = 1, $GammaCorrection = True
Global $iFlagSave = 0, $iCenterColor, $iMinBorder = 25, $bStatFlag = False
Global $dll = DllOpen("user32.dll")
Global $GuiSizeX = @DesktopWidth, $GuiSizeY = @DesktopHeight ; 200 ;
;Global Const $WM_LBUTTONDOWN = 0x0201 ; Drag Window 1 of 3 addin
Global $msg, $exit, $moveAll, $viewpoints, $pointsVisible = 1, $showPolC = 0, $togPolyCurve, $GammaCor
Global Const $SS_CENTER = 1
Global $aPoints, $aColors
;Clock Face
Local $aPoints24A[25][2] = [[24, 0],[215, 117],[289, 54],[269, 136],[355, 118],[306, 184],[394, 197], _
        [309, 225],[385, 274],[287, 270],[313, 346],[227, 288],[198, 366],[163, 284], _
        [88, 333],[122, 259],[35, 280],[109, 221],[25, 201],[108, 180],[41, 130], _
        [127, 138],[96, 64],[162, 121],[187, 42]]
Local $aColors24A[24] = [0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, _
        0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF000000, 0xFF00FF00, 0xFF0000FF, _
        0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, _
        0xFF00FF00, 0xFF000000, 0xFF00FF00, 0xFF000000, 0xFF00FF00, 0xFF0000FF]

Local $aPoints19A[20][2] = [[19, 0],[323, 0],[323, 69],[181, 69],[256, 173],[319, 173],[319, 225], _
        [173, 225],[173, 173],[230, 173],[147, 69],[89, 152],[120, 152],[120, 204], _
        [11, 204],[11, 152],[64, 152],[120, 69],[0, 69],[0, 0]]
; Graphic art 2
Local $aPoints19B[20][2] = [[19, 0],[342, 25],[268, 318],[545, 352],[297, 299],[360, 29],[468, 201], _
        [614, 26],[163, 148],[411, 126],[139, 404],[613, 260],[250, 239],[90, 377], _
        [28, 143],[169, 273],[128, 249],[256, 148],[84, 104],[231, 88]]
Local $aColors19A[19] = [0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, _
        0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF000000, 0xFF00FF00, 0xFF0000FF, _
        0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00]
; Graphic art
Local $aPoints10A[11][2] = [[10, 0],[618, 105],[278, 131],[334, 187],[801, 411],[52, 377],[604, 165], _
        [123, 240],[101, 137],[483, 521],[185, 97]]
; Star
Local $aPoints10B[11][2] = [[125, 125],[125, 50],[150, 100],[200, 100],[162, 125],[200, 200],[125, 154], _
        [50, 200],[87, 125],[50, 100],[100, 100]]
Local $aPoints10C[11][2] = [[10, 0],[447, 296],[164, 76],[165, 77],[431, 302],[70, 107],[69, 106], _
        [327, 25],[461, 289],[251, 50],[251, 50]] ; 3down
Local $aPoints10D[11][2] = [[10, 0],[33, 215],[33, 215],[100, 215],[198, 74],[198, 25],[25, 25], _
        [26, 72],[27, 73],[137, 72],[137, 72]] ;seven
Local $aPoints10E[11][2] = [[500, 417],[367, 53],[590, 152],[881, 185],[788, 418],[902, 667],[569, 674], _
        [308, 847],[253, 547],[56, 377],[287, 248]]
Local $aColors10A[10] = [0xFF000000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF, 0xFF000000, 0xFF00FF00, 0xFF0000FF, _
        0xFFFFFFFF, 0xFF000000, 0xFF00FF00]

Opt("MouseCoordMode", 0)
Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 2)


Start($aPoints10E, $aColors10A) ; <==== Enter Points & Color Arrays & CenterPoint Color Here
;ClosedCurveOrPolygon()

Func Start($aPoints1, $aColors1, $iCenterColor1 = 0xFFFF0000)
    $aPoints = $aPoints1
    $aColors = $aColors1
    $iCenterColor = $iCenterColor1
    ClosedCurveOrPolygon()
EndFunc ;==>Start

Func ClosedCurveOrPolygon()
    Local $0nPoint, $mouseDiffX, $mouseDiffY, $MouseStartPos, $pos

    $hGui = GUICreate("GDI+", $GuiSizeX, $GuiSizeY, -1, -1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))

    GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove") ; Drag Window 2 of 3 addin
    $ContextMenu = GUICtrlCreateContextMenu()
    $viewpoints = GUICtrlCreateMenuItem("Show points", $ContextMenu, 1)
    GUICtrlSetState($viewpoints, $GUI_CHECKED)
    GUICtrlSetOnEvent($viewpoints, "ShowaPoints")
    $GammaCor = GUICtrlCreateMenuItem("Toggle Gamma Correctin On/Off", $ContextMenu, 1)
    GUICtrlSetState($GammaCor, $GUI_CHECKED)
    GUICtrlSetOnEvent($GammaCor, "GammaCorrection")
    $AutoCenterPoint = GUICtrlCreateMenuItem("Manually Move Center Color Point", $ContextMenu, 1)
    GUICtrlSetState($AutoCenterPoint, $GUI_CHECKED)
    GUICtrlSetOnEvent($AutoCenterPoint, "AutoCenterPoint")
    $SelColor = GUICtrlCreateMenuItem("Change Center Colour", $ContextMenu)
    GUICtrlSetOnEvent($SelColor, "SelectColorCenterPt")
    $PtColor = GUICtrlCreateMenuItem("Change a Point Color", $ContextMenu)
    GUICtrlSetOnEvent($PtColor, "PointColor")
    $MultiSel = GUICtrlCreateMenuItem("Multi-change Alpha & Point Color", $ContextMenu)
    GUICtrlSetOnEvent($MultiSel, "AlphaAdjust")
    $separator1 = GUICtrlCreateMenuItem("", $ContextMenu) ; create a separator line
    $addpoint = GUICtrlCreateMenuItem("Add a point numbered after selected point number", $ContextMenu)
    GUICtrlSetOnEvent($addpoint, "AddPoint")
    $substractpoint = GUICtrlCreateMenuItem("Delete the selected (green) point ", $ContextMenu)
    GUICtrlSetOnEvent($substractpoint, "SubstractPoint")
    $separator1 = GUICtrlCreateMenuItem("", $ContextMenu) ; create a separator line
    $Currentpoints = GUICtrlCreateMenuItem("Write points to 'PolyDat.txt' file", $ContextMenu)
    GUICtrlSetOnEvent($Currentpoints, "CurrentPoints2Console")
    $SaveBitmap = GUICtrlCreateMenuItem("Save as PNG File ", $ContextMenu)
    GUICtrlSetOnEvent($SaveBitmap, "SaveBitmap")
    $Border = GUICtrlCreateMenuItem("Set Space Size around Polygon in Saved Image", $ContextMenu)
    GUICtrlSetOnEvent($Border, "Border")
    $separator1 = GUICtrlCreateMenuItem("", $ContextMenu) ; create a separator line
    $togPolyCurve = GUICtrlCreateMenuItem("Show Closed Curve", $ContextMenu)
    GUICtrlSetOnEvent($togPolyCurve, "TogPol_Curv")
    $separator1 = GUICtrlCreateMenuItem("", $ContextMenu) ; create a separator line
    $MenuItemExit = GUICtrlCreateMenuItem("Exit", $ContextMenu)
    GUICtrlSetOnEvent($MenuItemExit, "quitclk")

    GUISetState()
    Draw(-1)

    Do
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Or $exit = 1 Then ExitLoop
        If _IsPressed("01", $dll) Then ; Virtual-Key Code (0x01) Left mouse button
            $MouseStartPos = MouseGetPos()
            $0nPoint = CheckOverPoint($MouseStartPos[0], $MouseStartPos[1])
            $mouseDiffX = 0
            If $0nPoint >= 0 Then
                ToolTip(TooltipFunc($0nPoint), _ClientToScreen($hGui, $aPoints, $0nPoint, 0) - 30, _
                        _ClientToScreen($hGui, $aPoints, $0nPoint, 1) + 20)
                $moveAll = 1
                Draw($0nPoint)
                $GrnPt = $0nPoint
                While _IsPressed("01", $dll) ; Virtual-Key Code (0x01) Left mouse button
                    $pos = MouseGetPos()
                    $mouseDiffX = Int(($pos[0] - $MouseStartPos[0]))
                    $mouseDiffY = Int(($pos[1] - $MouseStartPos[1]))
                    If Abs($mouseDiffX) > 0 Or Abs($mouseDiffY) > 0 Then
                        $aPoints[$0nPoint][0] = $pos[0]
                        $aPoints[$0nPoint][1] = $pos[1]
                        Draw($0nPoint)
                        ToolTip(TooltipFunc($0nPoint), _ClientToScreen($hGui, $aPoints, $0nPoint, 0) - 30, _
                                _ClientToScreen($hGui, $aPoints, $0nPoint, 1) + 20)
                        Sleep(200)
                    EndIf
                    Sleep(20)
                WEnd
                ToolTip("")
            Else
                $moveAll = 0
                Draw(-1)
            EndIf
        EndIf ; mouse BTN 1 pressed??
        Sleep(20)
    Until _IsPressed("1B") ; ESC key
    DllClose($dll)
EndFunc ;==>ClosedCurveOrPolygon

;Check if mouse pointer is over a red/green spot
Func CheckOverPoint($MouseX, $MouseY)
    Local $x, $retValue = -1
    For $x = 0 To UBound($aPoints) - 1
        If $MouseX < $aPoints[$x][0] + 5 And $MouseX > $aPoints[$x][0] - 5 And _
                $MouseY < $aPoints[$x][1] + 5 And $MouseY > $aPoints[$x][1] - 5 Then
            $retValue = $x
        EndIf
    Next
    Return $retValue
EndFunc ;==>CheckOverPoint

Func TooltipFunc($0nPoint)
    Local $sText
    If $0nPoint = 0 Then
        $sText = "Point 0 (Center Color Point: " & $0nPoint & @CRLF & " X: " & $aPoints[$0nPoint][0] & _
                "   Y: " & $aPoints[$0nPoint][1] & @CRLF & "Center Color : " & "0x" & Hex($iCenterColor)
    Else
        $sText = "Point: " & $0nPoint & @CRLF & " X: " & $aPoints[$0nPoint][0] & _
                "   Y: " & $aPoints[$0nPoint][1] & @CRLF & "Center Color : " & "0x" & Hex($aColors[$0nPoint - 1])
    EndIf
    Return $sText
EndFunc ;==>TooltipFunc

Func Draw($pt)
    Local $hWnd, $hDC, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend, $hBrushRed, $hBrushGreen, $hPen, $aCentPt
    $GrnPt = $pt
    _GDIPlus_Startup()
    $hWnd = _WinAPI_GetDC(0)
    $hDC = _WinAPI_CreateCompatibleDC($hWnd)
    $hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd, $GuiSizeX, $GuiSizeY)
    _WinAPI_SelectObject($hDC, $hBitmap)
    $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)
    $hPen = _GDIPlus_PenCreate(0xFF010101, 1)
    ;$hBrush = _GDIPlus_BrushCreateSolid ($iCenterColor) ; Random(0xff000000, 0xffffff00, 1))
    $hBrushRed = _GDIPlus_BrushCreateSolid(0x8fff0000) ;red
    $hBrushGreen = _GDIPlus_BrushCreateSolid(0x8f00ff00) ;Green


    ;======== CreatePath =====
    ; $aResult = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $FillModeAlternate, "ptr", $pPath)
    ; $FillModeAlternate = 0
    ; $FillModeWinding = 1
    $aPath = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", 0, "int*", 1)
    $hPath = $aPath[2]

    _GDIPlus_AddPathLine2($hPath, $aPoints)

    ;GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, GpPathGradient **polyGradient)
    $hBrushGrad = DllCall($ghGDIPDll, "int", "GdipCreatePathGradientFromPath", "hwnd", $hPath, "int*", 0)

    GDIPlus_SetPathGradientCenterColor($hBrushGrad[2], $iCenterColor)

    If $init = 0 Then
        $aCentPt = GDIPlus_GetPathGradientCenterPoint($hBrushGrad[2])
        $aPoints[0][0] = $aCentPt[0]
        $aPoints[0][1] = $aCentPt[1]
        $init = 1
    EndIf

    If $centerFlagAutoOn = 0 Then
        GDIPlus_SetPathGradientCenterPoint($hBrushGrad[2], $aPoints[0][0], $aPoints[0][1])
    Else
        $aCentPt = GDIPlus_GetPathGradientCenterPoint($hBrushGrad[2])
        $aPoints[0][0] = $aCentPt[0]
        $aPoints[0][1] = $aCentPt[1]
    EndIf

    GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad[2], $aColors)
    $aResult1 = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "hwnd", $hPath)

    ;$GammaCorrection Variable contains either True or False
    GDIPlus_SetLineGammaCorrection($hBrushGrad[2], $GammaCorrection)

    ;======= Fill Path - Color path object ==
    ;GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *path)
    DllCall($ghGDIPDll, "int", "GdipFillPath", "hwnd", $hGraphic, "hwnd", $hBrushGrad[2], "hwnd", $hPath)
    ;=======> End of Fill Path ==============

    _GDIPlus_GraphicsClear($hGraphic)

    If $showPolC = 1 Then
        GDIPlus_GraphicsFillClosedCurve($hGraphic, $aPoints, $hBrushGrad[2])
        ;_GDIPlus_AddPathClosedCurve($hPath, $aPoints)
        GDIPlus_GraphicsDrawClosedCurve($hGraphic, $aPoints, $hPen)
    Else
        GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints, $hBrushGrad[2])
        GDIPlus_GraphicsDrawPolygon($hGraphic, $aPoints, $hPen)
    EndIf

    If $pointsVisible = 1 Then
        For $x = 0 To UBound($aPoints) - 1
            If $x = $pt Then
                _GDIPlus_GraphicsFillEllipse($hGraphic, $aPoints[$x][0] - 5, $aPoints[$x][1] - 5, 10, 10, $hBrushGreen)
            Else
                _GDIPlus_GraphicsFillEllipse($hGraphic, $aPoints[$x][0] - 5, $aPoints[$x][1] - 5, 10, 10, $hBrushRed)
            EndIf
            _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$x][0] - 5, $aPoints[$x][1] - 5, 10, 10)
        Next
    EndIf
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", $GuiSizeX)
    DllStructSetData($tSize, "Y", $GuiSizeY)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrushGrad[2])
    _GDIPlus_BrushDispose($hBrushRed)
    _GDIPlus_BrushDispose($hBrushGreen)
    _GDIPlus_GraphicsDispose($hGraphic)
    DllCall($ghGDIPDll, "int", "GdipDeletePath", "hwnd", $hPath)
    If $iFlagSave = 0 Then
        _WinAPI_DeleteObject($hBitmap)
        _GDIPlus_Shutdown()
    EndIf
    _WinAPI_ReleaseDC(0, $hWnd)
    _WinAPI_DeleteDC($hDC)

    Return
EndFunc ;==>Draw

;Called from context menu check / uncheck Show Points
Func ShowaPoints()
    If $pointsVisible = 1 Then
        GUICtrlSetState($viewpoints, $GUI_UNCHECKED)
        $pointsVisible = 0
    Else
        GUICtrlSetState($viewpoints, $GUI_CHECKED)
        $pointsVisible = 1
    EndIf
    Draw(-1)
    Return
EndFunc ;==>ShowaPoints

;Called from context menu check / uncheck Gamma Correction
Func GammaCorrection()
    If $GammaCorrection Then ; same as If $GammaCorrection = true Then
        GUICtrlSetState($GammaCor, $GUI_UNCHECKED)
        $GammaCorrection = False
    Else
        GUICtrlSetState($GammaCor, $GUI_CHECKED)
        $GammaCorrection = True
    EndIf
    Draw(-1)
    Return
EndFunc ;==>GammaCorrection

;Called from context menu check / uncheck Show Points
Func AutoCenterPoint()
    If $centerFlagAutoOn = 1 Then
        GUICtrlSetState($AutoCenterPoint, $GUI_UNCHECKED)
        GUICtrlSetData($AutoCenterPoint, "Manually Move Center Color Point")
        $centerFlagAutoOn = 0
    Else
        GUICtrlSetState($AutoCenterPoint, $GUI_CHECKED)
        GUICtrlSetData($AutoCenterPoint, "Auto - Move Center Color Point")
        $centerFlagAutoOn = 1
    EndIf
    Draw(-1)
    Return
EndFunc ;==>AutoCenterPoint

;Called from context menu Write Current points to console
Func CurrentPoints2Console()
    If WinExists("PolyDat.txt") Then
        WinActivate("PolyDat.txt")
        WinWaitActive("PolyDat.txt")
        Send("^s")
        WinWaitActive("PolyDat.txt")
        Send("{ALT}")
        Send("f")
        Send("x")
    EndIf
    $hFile = FileOpen("PolyDat.txt", 1)

    $FromStats = SizeStats()
    $text = "Local $aPoints[" & UBound($aPoints) & "][2] = [[" & $aPoints[0][0] & "," & $aPoints[0][1] & "],"

    For $x = 1 To UBound($aPoints) - 1
        If Mod($x, 7) = 0 Then $text &= " _" & @CRLF & "    "
        $text &= "[" & $aPoints[$x][0] & "," & $aPoints[$x][1] & "],"
    Next
    $text = StringTrimRight($text, 1) & "]"
    FileWriteLine($hFile, "; =========== " & _Now() & " ===================" & @CRLF & @CRLF)
    FileWriteLine($hFile, $text & @CRLF & @CRLF)
    $text = "Local $aColors[" & UBound($aColors) & "] = [" & "0x" & Hex($aColors[0], 8) & ", "
    For $x = 1 To UBound($aColors) - 1
        If Mod($x, 6) = 0 Then $text &= "_" & @CRLF & "     "
        $text &= "0x" & Hex($aColors[$x]) & ", "
    Next
    $text = StringTrimRight($text, 1) & "]"
    FileWriteLine($hFile, $text & @CRLF & @CRLF)
    FileWriteLine($hFile, " Center Color is = " & "0x" & Hex($iCenterColor) & @CRLF & @CRLF)
    FileWriteLine($hFile, "Recommended GUI size     : Width X Height = " & $FromStats[4] & " X " & $FromStats[5] & @CRLF & _
            "About the points in array: MiniX, MiniY = " & $FromStats[0] & ", " & $FromStats[1] & _
            " MaxX, MaxY = " & $FromStats[2] & ", " & $FromStats[3] & _
            " Border set to " & $iMinBorder & @CRLF & @CRLF)
    FileClose($hFile)
    Run("Notepad.exe PolyDat.txt")
    Return
EndFunc ;==>CurrentPoints2Console

; Called from context menu Exit script.
Func quitclk()
    $exit = 1 ; Chr(27) ;
EndFunc ;==>quitclk

; Called from context menu toggle between Closed Curves and Polygon
Func TogPol_Curv()
    If $showPolC = 0 Then
        GUICtrlSetData($togPolyCurve, "Show Polygon")
        $showPolC = 1
    Else
        GUICtrlSetData($togPolyCurve, "Show Closed Curve")
        $showPolC = 0
    EndIf

    Draw(-1)
    Return
EndFunc ;==>TogPol_Curv

;Called from context menu check / uncheck Show Both Polygon and Closed Curve
Func PointColor()
    Local $col
    If $GrnPt = -1 Then
        MsgBox(0, "To add a color to a Point", "Select a point. (Click on a red point to turn it green)", 0, $hGui);WinGetHandle('Program Manager'))
    Else
        $col = _ChooseColor(2, 0xffff80, 2)
        If $col <> -1 Then
            ;$iPtColor = $aColors[$x - 1] = "0x" & hex(bitor(BitAND($aColors[$x - 1], 0xFF000000),BitAND($col, 0x00FFFFFF)));"0xFF" & StringTrimLeft($col, 2)
            For $r = 1 To UBound($aPoints) - 1
                If $r = $GrnPt Then $aColors[$GrnPt - 1] = "0x" & Hex(BitOR(BitAND($aColors[$GrnPt - 1], 0xFF000000), BitAND($col, 0x00FFFFFF)));$aColors[$GrnPt - 1] = $iPtColor
            Next
            If $GrnPt = 0 Then $iCenterColor = "0x" & Hex(BitOR(BitAND($iCenterColor, 0xFF000000), BitAND($col, 0x00FFFFFF)))
            Draw(-1)
        EndIf
    EndIf
    Return

EndFunc ;==>PointColor

; Returns a suitable Width and Height to encompass polygon for use in
; save as image and write to console. Max & Min points are just for info.
Func SizeStats()
    Local $iMinX = $aPoints[1][0], $iMaxX = $aPoints[1][0], $x = 0, $y = 0
    Local $iMinY = $aPoints[1][1], $iMaxY = $aPoints[1][1]
    Local $iMinWidth, $iMinHeigth

    For $r = 1 To UBound($aPoints) - 1
        If $aPoints[$r][0] < $iMinX Then $iMinX = $aPoints[$r][0]
        If $aPoints[$r][1] < $iMinY Then $iMinY = $aPoints[$r][1]
        If $aPoints[$r][0] > $iMaxX Then $iMaxX = $aPoints[$r][0]
        If $aPoints[$r][1] > $iMaxY Then $iMaxY = $aPoints[$r][1]
    Next

    Local $iMaxBorder = 80
    If Not $bStatFlag Then
        If $iMinX < $iMinBorder Then $x = $iMinBorder - $iMinX
        If $iMinY < $iMinBorder Then $y = $iMinBorder - $iMinY
        If ($iMinX - $iMinBorder) > $iMaxBorder Then $x = $x - ($iMinX - $iMinBorder)
        If ($iMinY - $iMinBorder) > $iMaxBorder Then $y = $y - ($iMinY - $iMinBorder)
        If $x <> 0 Or $y <> 0 Then $aPoints = arrayplusScalarPoint($aPoints, $x, $y)
        $bStatFlag = True
        SizeStats()
    EndIf
    $bStatFlag = False

    $iMinWidth = $iMinX + $iMaxX ; = (2 * $iMinX) + actual width
    $iMinHeigth = $iMinY + $iMaxY ; = (2 * $iMinY) + actual height

    Local $aStats[6] = [$iMinX, $iMinY, $iMaxX, $iMaxY, $iMinWidth, $iMinHeigth]
    Draw(-1)
    Return $aStats
EndFunc ;==>SizeStats

;Called from context menu. Save Graphics to script directory as Poly.png.
Func SaveBitmap()
    SizeStats()
    $FromStats = SizeStats()
    ;CurrentPoints2Console()
    Draw(-1)
    $GuiSizeX = $FromStats[4]
    $GuiSizeY = $FromStats[5]
    $iFlagSave = 1 ; In Draw() function will not delete $hBitmap
    Draw(-1)
    $iFlagSave = 0 ; Next Draw() function call, will delete $hBitmap.
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    _GDIPlus_ImageSaveToFile($hImage1, "Poly.png")
    ShellExecute("Poly.png")

    ; Clean up resources
    _WinAPI_DeleteObject($hBitmap)
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_Shutdown()
    $GuiSizeX = @DesktopWidth * 3 / 4
    $GuiSizeY = @DesktopWidth * 3 / 4
    Return
EndFunc ;==>SaveBitmap

;Called from context menu. Adds a points. eg. if point3 is selected (green) then a new point 4 is added
Func AddPoint()
    Local $LastColor
    If $GrnPt <= 0 Then
        MsgBox(0, "Add a Point", "Select a point. (Click on a red point to turn it green)", 0, WinGetHandle('Program Manager'));$hGui );
    Else
        Dim $aRET[UBound($aPoints) + 1][2]
        Dim $aTempColor[UBound($aColors) + 1]

        For $r = 1 To UBound($aPoints) - 1
            If $r = $GrnPt Then
                $aRET[$r][0] = $aPoints[$r][0]
                $aRET[$r][1] = $aPoints[$r][1]
                $aRET[$r + 1][0] = $aPoints[$r][0] + 10
                $aRET[$r + 1][1] = $aPoints[$r][1] + 10
                $aTempColor[$r - 1] = $aColors[$r - 1]
                $aTempColor[$r] = $aColors[$r - 1]
            ElseIf $r > $GrnPt Then
                $aRET[$r + 1][0] = $aPoints[$r][0]
                $aRET[$r + 1][1] = $aPoints[$r][1]
                $aTempColor[$r] = $aColors[$r - 1]
            Else
                $aRET[$r][0] = $aPoints[$r][0]
                $aRET[$r][1] = $aPoints[$r][1]
                $aTempColor[$r - 1] = $aColors[$r - 1]
            EndIf
        Next
        $aPoints = $aRET
        $aRET = ""
        $aColors = $aTempColor
        $aTempColor = ""
        Draw(-1)
    EndIf
    Return
EndFunc ;==>AddPoint

; Called from context menu. Deletes the selected (green) point.
Func SubstractPoint()
    If $GrnPt <= 0 Then
        MsgBox(0, "Substract a point", "Select a point. (Click on a red point to turn it green", 0, $hGui)
    Else
        Dim $aRET[UBound($aPoints) - 1][2]
        Dim $aTempColor[UBound($aColors) - 1]

        For $r = 1 To UBound($aRET) - 1
            If $r >= $GrnPt Then
                $aRET[$r][0] = $aPoints[$r + 1][0]
                $aRET[$r][1] = $aPoints[$r + 1][1]
                $aTempColor[$r - 1] = $aColors[$r]
            Else
                $aRET[$r][0] = $aPoints[$r][0]
                $aRET[$r][1] = $aPoints[$r][1]
                $aTempColor[$r - 1] = $aColors[$r - 1]
            EndIf
        Next
        $aPoints = $aRET
        $aRET = ""
        $aColors = $aTempColor
        $aTempColor = ""
        Draw(-1)
    EndIf
    Return
EndFunc ;==>SubstractPoint

; Called from context menu. Change Center point color
Func SelectColorCenterPt()
    Local $col
    $col = _ChooseColor(2, 0xffff80, 2)
    If $col <> -1 Then $iCenterColor = "0x" & Hex(BitOR(BitAND($iCenterColor, 0xFF000000), BitAND($col, 0x00FFFFFF)))
    Draw(-1)
    Return
EndFunc ;==>SelectColorCenterPt

Func Border()
    Local $x = 0, $y = 0
    $Bdr = InputBox("Change border space size around the image to be saved", _
            "Current border size is " & $iMinBorder & @CRLF & @CRLF & _
            "Enter new border size, or Cancel" & @CRLF & @CRLF, $iMinBorder, "", 400, 150, -1, -1, -1, $hGui)
    If Not @error And Number($Bdr) > 0 Then $iMinBorder = Number($Bdr) ; Min border size = 1
    SizeStats()
    Draw(-1)
    Return
EndFunc ;==>Border

;Matrix $a plus a Scalar (number) $k (Used in Margin/border Utility)
Func arrayplusScalarPoint(ByRef $pts, $x = 0, $y = 0)
    Dim $aRET[UBound($pts)][2]

    For $r = 0 To UBound($pts) - 1
        $aRET[$r][0] = $pts[$r][0] + $x
        $aRET[$r][1] = $pts[$r][1] + $y
    Next
    Return $aRET
EndFunc ;==>arrayplusScalarPoint

; =================================================================
; Drag Window 3 of 3 addin
; =================================================================
Func _WinMove($hWnd, $Command, $wParam, $lParam)
    If BitAND(WinGetState($hWnd), 32) Then Return $GUI_RUNDEFMSG
    If $moveAll = 0 Then
        ;DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0)
        DllCall("user32.dll", "int", "SendMessage", "hWnd", $hWnd, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
    EndIf
    Return
EndFunc ;==>_WinMove

;***** Slider Funcs & Multi select GUI ***********
Func AlphaAdjust()
    Opt("GUIOnEventMode", 0)

    Global $Horizontal_Label, $vertical_Label, $Horizontal_Slider, $vertical_Slider
    Local $SliderForm = GUICreate("SliderForm", 660, 331, 194, 516, $WS_POPUP, $WS_EX_TOPMOST)
    Local $col, $iSetX = 60, $iSetY = 50
    GUISetBkColor(0xf0f0FF, $SliderForm)
    Dim $aCheckBoxes[UBound($aPoints)]
    Dim $aButtons[2][5] = [[0, 0, 0, 0, 0],["Multi-Select a Color", "Select All", "Select Every 2nd", "Flip All", "Finish"]]
    GUICtrlCreateLabel("Multi-Select Alpha Adjustment Slider control", 200, 33)
    GUICtrlCreateLabel("Point Nos", 5, $iSetY)
    GUICtrlCreateLabel(0, $iSetX, $iSetY)
    $aCheckBoxes[0] = GUICtrlCreateCheckbox("", $iSetX, $iSetY + 15)
    $iSetX += 20
    For $x = 1 To UBound($aPoints) - 1
        GUICtrlCreateLabel($x, $iSetX, $iSetY)
        $aCheckBoxes[$x] = GUICtrlCreateCheckbox("", $iSetX, $iSetY + 15)
        $iSetX += 20
        If Mod($x, 20) = 0 Then ; 28
            $iSetY += 40
            $iSetX = 60
            If UBound($aPoints) - 1 - $x > 0 Then GUICtrlCreateLabel("Point Nos", 5, $iSetY)
        EndIf
    Next
    $iSetX = 20
    $iSetY = 290
    For $x = 0 To 4
        $aButtons[0][$x] = GUICtrlCreateButton($aButtons[1][$x], $iSetX, $iSetY, 100)
        $iSetX += 130
    Next
    ;$Button_1 = GUICtrlCreateButton("Finish", 300, 290, 100)
    SliderVert_Horiz(1)
    GUISetState(@SW_SHOW)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case -3, $aButtons[0][4]
                GUIDelete($SliderForm)
                ExitLoop
            Case $Horizontal_Slider
                If GUICtrlRead($aCheckBoxes[0]) = 1 Then $iCenterColor = "0x" & Hex(BitOR(BitShift(GUICtrlRead($Horizontal_Slider), -24), BitAND($iCenterColor, 0x00FFFFFF)))
                For $x = 1 To UBound($aPoints) - 1
                    If GUICtrlRead($aCheckBoxes[$x]) = 1 Then $aColors[$x - 1] = "0x" & Hex(BitOR(BitShift(GUICtrlRead($Horizontal_Slider), -24), BitAND($aColors[$x - 1], 0x00FFFFFF))) ; Hex(GUICtrlRead($Horizontal_Slider) * 0x1000000 + BitAND($aColors[$x - 1], 0x00FFFFFF))
                Next
                Draw(-1)
            Case $aButtons[0][0] ;"Multi-Select a Color"
                $col = _ChooseColor(2, 0xffff80, 2)
                If $col <> -1 Then
                    If GUICtrlRead($aCheckBoxes[0]) = 1 Then $iCenterColor = "0x" & Hex(BitOR(BitAND($iCenterColor, 0xFF000000), BitAND($col, 0x00FFFFFF)))
                    For $x = 1 To UBound($aPoints) - 1
                        If GUICtrlRead($aCheckBoxes[$x]) = 1 Then $aColors[$x - 1] = "0x" & Hex(BitOR(BitAND($aColors[$x - 1], 0xFF000000), BitAND($col, 0x00FFFFFF))) ;Hex(Dec(Hex($col, 8)) + (BitAND($aColors[$x - 1], 0xFF000000)))

                    Next
                    Draw(-1)
                EndIf

            Case $aButtons[0][1] ; Select All
                For $x = 0 To UBound($aPoints) - 1
                    GUICtrlSetState($aCheckBoxes[$x], 1)
                Next
            Case $aButtons[0][2] ; Select Every 2nd
                For $x = 0 To UBound($aPoints) - 1 Step 2
                    GUICtrlSetState($aCheckBoxes[$x], 1)
                Next
            Case $aButtons[0][3] ; Flip All
                For $x = 0 To UBound($aPoints) - 1
                    If GUICtrlRead($aCheckBoxes[$x]) = 1 Then
                        GUICtrlSetState($aCheckBoxes[$x], 4)
                    Else
                        GUICtrlSetState($aCheckBoxes[$x], 1)
                    EndIf
                Next

        EndSwitch
        GUICtrlSetData($Horizontal_Label, GUICtrlRead($Horizontal_Slider))
        GUICtrlSetData($vertical_Label, GUICtrlRead($vertical_Slider))
        Sleep(10)
    WEnd
    Opt("GUIOnEventMode", 1)
    Return
EndFunc ;==>AlphaAdjust

Func SliderVert_Horiz($tick = 0)
    $Horizontal_Label = GUICtrlCreateLabel("", 3, 0, 48, 31, BitOR($SS_CENTER, $WS_BORDER))
    GUICtrlSetFont(-1, 14, 1000, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xa00000)
    GUICtrlSetBkColor($Horizontal_Label, 0xe0e000)

    $Horizontal_Slider = _GUICtrlCreateSliderB(51, 0, 604, 31)
    If $tick = 0 Then
        GUICtrlSetStyle($Horizontal_Slider, BitOR($TBS_TOP, $TBS_HORZ, $TBS_NOTICKS, $WS_CLIPSIBLINGS))
    Else
        GUICtrlSetStyle($Horizontal_Slider, BitOR($TBS_TOP, $TBS_HORZ, $TBS_AUTOTICKS, $WS_CLIPSIBLINGS))
    EndIf
    GUICtrlSetLimit($Horizontal_Slider, 0xFF)
    GUICtrlSetData($Horizontal_Slider, Hex(100))
    GUICtrlSetData($Horizontal_Label, Hex(GUICtrlRead($Horizontal_Slider), 2))
    GUICtrlSetBkColor($Horizontal_Slider, 0xff0000)
    _GUICtrlSlider_SetTicFreq($Horizontal_Slider, 2)

EndFunc ;==>SliderVert_Horiz

Func _GUICtrlCreateSliderB($x, $y, $w, $h)
    Local $sld = GUICtrlCreateSlider($x, $y, $w, $h, $WS_CLIPSIBLINGS)
    GUICtrlCreateLabel("", $x, $y - 1, $w, 2)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("", $x, $y + $h - 1, $w, 2)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("", $x - 1, $y, 2, $h)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("", $x + $w - 1, $y, 2, $h)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Return $sld
EndFunc ;==>_GUICtrlCreateSliderB
;*****>End of Slider Funcs ***********


;************** Copied & Modified from GDIPlus.au3 ****
;Note:
Func GDIPlus_GraphicsDrawClosedCurve($hGraphics, $aPoints, $hPen = 0)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError

    $iCount = UBound($aPoints) - 1 ; Modified was $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("int[" & $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

    ;$hPen = _GDIPlus_PenCreate()
    $aResult = DllCall($ghGDIPDll, "int", "GdipDrawClosedCurveI", "hwnd", $hGraphics, "hwnd", $hPen, "ptr", $pPoints, "int", $iCount)
    $tmpError = @error
    $tmpExError = @extended
    _GDIPlus_PenDispose($hPen)
    If $tmpError Then Return SetError($tmpError, $tmpExError, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>GDIPlus_GraphicsDrawClosedCurve

Func GDIPlus_GraphicsFillClosedCurve($hGraphics, $aPoints, $hBrush = 0)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError

    $iCount = UBound($aPoints) - 1 ; Modified was $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("int[" & $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

    ;$hBrush = _GDIPlus_BrushCreateSolid()
    $aResult = DllCall($ghGDIPDll, "int", "GdipFillClosedCurveI", "hwnd", $hGraphics, "hwnd", $hBrush, "ptr", $pPoints, "int", $iCount)
    $tmpError = @error
    $tmpExError = @extended
    _GDIPlus_BrushDispose($hBrush)
    If $tmpError Then Return SetError($tmpError, $tmpExError, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>GDIPlus_GraphicsFillClosedCurve

Func GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush = 0)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError

    $iCount = UBound($aPoints) - 1 ; Modified was $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("int[" & $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

    ;$hBrush = _GDIPlus_BrushCreateSolid()
    $aResult = DllCall($ghGDIPDll, "int", "GdipFillPolygon2I", "hwnd", $hGraphics, "hwnd", $hBrush, "ptr", _
            $pPoints, "int", $iCount)
    $tmpError = @error
    $tmpExError = @extended
    _GDIPlus_BrushDispose($hBrush)
    If $tmpError Then Return SetError($tmpError, $tmpExError, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>GDIPlus_GraphicsFillPolygon

Func GDIPlus_GraphicsDrawPolygon($hGraphics, $aPoints, $hPen = 0)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError

    $iCount = UBound($aPoints) - 1 ; Modified was $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("int[" & $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

    ;$hPen = _GDIPlus_PenCreate()
    $aResult = DllCall($ghGDIPDll, "int", "GdipDrawPolygonI", "hwnd", $hGraphics, "hwnd", $hPen, "ptr", $pPoints, "int", $iCount)
    $tmpError = @error
    $tmpExError = @extended
    _GDIPlus_PenDispose($hPen)
    If $tmpError Then Return SetError($tmpError, $tmpExError, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>GDIPlus_GraphicsDrawPolygon
;**************> End of Copied & Modified from GDIPlus.au3 ****

;_ClientToScreen() Function - Converts client (gui) coordinates to Screen coordinates
;Input - $hwnd - Handle from GUICreate() function
;   $cPoint - Array of points in $cPoint[n+1][2] = [[n,0],[x1,y1],[x2,y2],...[xn,yn]] format
;   Where n = Number of points
;   $index - Index of array e.g for point $cPoint[2][0] and $cPoint[2][1] $index = 2
;   $xy     - if 0 then returns screen coordinate of x
;   - If 1 then returns screen coordinate of y
;   - if 2 then returns array where return array[0] = x, and array[1] = y value
Func _ClientToScreen($hWnd, ByRef $cPoint, $index, $xy = 2)
    Local $tpoint = DllStructCreate("int X;int Y")
    Local $ret[2]
    DllStructSetData($tpoint, "X", $cPoint[$index][0])
    DllStructSetData($tpoint, "Y", $cPoint[$index][1])
    _WinAPI_ClientToScreen($hWnd, $tpoint)
    $ret[0] = DllStructGetData($tpoint, "X")
    $ret[1] = DllStructGetData($tpoint, "Y")
    If $xy = 0 Then Return $ret[0] ; x value
    If $xy = 1 Then Return $ret[1] ; y value
    If $xy = 2 Then Return $ret ; array
EndFunc ;==>_ClientToScreen


;GpStatus WINGDIPAPI GdipAddPathLine2(GpPath *path, GDIPCONST GpPointF *points, INT count)
Func _GDIPlus_AddPathLine2($hPath, $aPoints)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError

    $iCount = UBound($aPoints) - 1
    $tPoints = DllStructCreate("int[" & $iCount * 2 & "]")
    $pPoints = DllStructGetPtr($tPoints)
    For $iI = 1 To $iCount
        DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][0]), (($iI - 1) * 2) + 1)
        DllStructSetData($tPoints, 1, _WinAPI_FloatToInt($aPoints[$iI][1]), (($iI - 1) * 2) + 2)
    Next
    $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathLine2", "hwnd", $hPath, "ptr", _
            $pPoints, "int", $iCount)
    $tmpError = @error
    $tmpExError = @extended
    If $tmpError Then Return SetError($tmpError, $tmpExError, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>_GDIPlus_AddPathLine2

;================> GDIPlus_SetPathGradientCenterColor ===============
; Description   Sets the center color of this path gradient brush. The center color is the
;   color that appears at the brush's center point.
;Parameters
;brush  [in] Pointer to the PathGradientBrush object.
;colors [in] An ARGB color that specifies the center color.
;Remarks    By default the center point is the centroid of the brush's boundary path,
;   but you can set the center point to any location inside or outside the path.
;
Func GDIPlus_SetPathGradientCenterColor($hBrush, $iARGB)
    Local $aResult
    $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterColor", "hwnd", $hBrush, "int", $iARGB)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult ;SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>GDIPlus_SetPathGradientCenterColor
;=================================================

;=================> GDIPlus_SetPathGradientCenterPoint ================================
;Description    Sets the center point of this path gradient brush. By default,
;   the center point is at the centroid of the brush's boundary path, but you
;   can set the center point to any location inside or outside the path.
;Parameters brush   [in] Pointer to the PathGradientBrush object.
;   points  [out] Pointer to a PointF structure that receives the center point.
;Remarks    By default, the center point of a PathGradientBrush object is at the centroid of
;   the brush's boundary path, but you can set the center point to any location, inside
;   or outside the path, by calling the GdipSetPathGradientCenterPoint function.
Func GDIPlus_SetPathGradientCenterPoint($hBrush, $iX, $iY)
    Local $tpoint, $pPoint, $aResult
    $tpoint = DllStructCreate("int X;int Y")
    $pPoint = DllStructGetPtr($tpoint)
    DllStructSetData($tpoint, "X", _WinAPI_FloatToInt($iX))
    DllStructSetData($tpoint, "Y", _WinAPI_FloatToInt($iY))
    $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientCenterPoint", "hwnd", $hBrush, "ptr", $pPoint)
    Return $aResult

EndFunc ;==>GDIPlus_SetPathGradientCenterPoint

;GdipGetPathGradientCenterPoint( GpPathGradient *brush, GpPointF* points)
;
Func GDIPlus_GetPathGradientCenterPoint($hBrush)
    Local $aResult, $res, $iX, $iY, $pt, $aPt[2]
    $pt = DllStructCreate("int X;int Y")
    $pPt = DllStructGetPtr($pt)
    $aResult = DllCall($ghGDIPDll, "int", "GdipGetPathGradientCenterPoint", "hwnd", $hBrush, "ptr", $pPt)
    $iX = Round(_WinAPI_IntToFloat(DllStructGetData($pt, 'X')), 0)
    $iY = Round(_WinAPI_IntToFloat(DllStructGetData($pt, 'Y')), 0)
    ;$res = "GdipGetPathGradientCenterPoint" & @CRLF
    $aPt[0] = $iX
    $aPt[1] = $iY
    ;$res &= "$iX " & $aPt[0] & @CRLF
    ;$res &= "$iY " & $aPt[1] & @CRLF
    ;For $x = 0 To 2
    ; $res &= $x & " " & $aResult[$x] & @CRLF
    ;Next
    ;ConsoleWrite($res & @CRLF)
    Return $aPt
EndFunc ;==>GDIPlus_GetPathGradientCenterPoint

;===========================================================
; Description: Specifies whether gamma correction is enabled for this linear gradient brush.
; Parameters
; $hBrush   - [in] Pointer to the LinearGradientBrush object.
; $useGammaCorrection - [in] Boolean value that specifies whether gamma correction occurs
;   during rendering. TRUE specifies that gamma correction is enabled,
;   and FALSE specifies that gamma correction is not enabled. By default,
;   gamma correction is disabled during construction of a
;   LinearGradientBrush object.
;GdipSetLineGammaCorrection(GpLineGradient *brush, BOOL useGammaCorrection)
;
Func GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True)
    Local $aResult

    $aResult = DllCall($ghGDIPDll, "int", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", $useGammaCorrection)
    Return $aResult[0]
EndFunc ;==>GDIPlus_SetLineGammaCorrection
;=================================================


;==============> GDIPlus_SetPathGradientSurroundColorsWithCount ===================================
;Description    Sets the surround colors of this path gradient brush. The surround colors are colors
;   specified for discrete points on the brush's boundary path.
;Parameters
;brush  [in] Pointer to the PathGradientBrush object.
;colors [in] Pointer to an array of ARGB colors that specify the surround colors.
;count  [in, out] Pointer to a long integer that, on input, specifies the number of Color objects
;   in the colors array. If the method succeeds, this parameter, on output, receives the number
;   of surround colors set. If the method fails, this parameter does not receive a value.
;Remarks    A path gradient brush has a boundary path and a center point. The center point is set
;   to a single color, but you can specify different colors for several points on the boundary.
;   For example, suppose you specify red for the center color, and you specify blue, green,
;   and yellow for distinct points on the boundary. Then as you move along the boundary,
;   the color will change gradually from blue to green to yellow and back to blue.
;   As you move along a straight line from any point on the boundary to the center point,
;   the color will change from that boundary point's color to red.
;
Func GDIPlus_SetPathGradientSurroundColorsWithCount($hBrush, $aArgb)
    Local $iI, $iCount, $aResult, $res, $x, $pArgb, $tArgb
    $iCount = UBound($aArgb)
    $tArgb = DllStructCreate("int[" & $iCount & "]")
    $pArgb = DllStructGetPtr($tArgb)
    For $iI = 0 To $iCount - 1
        DllStructSetData($tArgb, 1, $aArgb[$iI], $iI + 1)
    Next

    $aResult = DllCall($ghGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "hwnd", $hBrush, "ptr", $pArgb, "int*", $iCount)
    ;$res = "SetPathGradientSurroundColorsWithCount" & @CRLF
    ;For $x = 0 To 3
    ; $res &= $x & " " & $aResult[$x] & @CRLF
    ;Next
    ;ConsoleWrite($res & @CRLF)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult ;SetError($aResult[0], 0, $aResult[2])
EndFunc ;==>GDIPlus_SetPathGradientSurroundColorsWithCount
Edited by Malkey
Link to comment
Share on other sites

  • 1 month later...

Edit6: Made transparent background GUI full desktop size.

Took me a bit, very impressed now that I get it!

One note though: I was able to move a point outside of some sort of invisible bound on the side and was then no longer able to select it. Does that make sense? I can try posting a screenshot if not...

Link to comment
Share on other sites

Took me a bit, very impressed now that I get it!

One note though: I was able to move a point outside of some sort of invisible bound on the side and was then no longer able to select it. Does that make sense? I can try posting a screenshot if not...

The invisible bound on the side is the invisible GUI - the size of the desktop. When the image is dragged, it is really the whole GUI that is dragged. This is using the _WinMove() function.

On the context menu (Right click button on image) you can set the border width around the image. This moves the image within the GUI. In most cases this should reposition the image on the GUI enabling the point which was off the GUI to be positioned back onto the GUI - making it visible again.

Really glad you like it.

Link to comment
Share on other sites

The invisible bound on the side is the invisible GUI - the size of the desktop. When the image is dragged, it is really the whole GUI that is dragged. This is using the _WinMove() function.

On the context menu (Right click button on image) you can set the border width around the image. This moves the image within the GUI. In most cases this should reposition the image on the GUI enabling the point which was off the GUI to be positioned back onto the GUI - making it visible again.

Really glad you like it.

Yep, I figured it was something like that. Can't believe more people haven't commented on this, it's awesome!

Thanks you!

Link to comment
Share on other sites

  • 5 months later...

I know, it's an 'old' topic(Until now, I discover this topic) but a have to say: wonderful job, Malkey! :)

Thanks Josbe

I continually use this script as a utility to generate an array of points of a polygon when needed in another script.

I have always regretted the thread's title.

I think my next graphics project that followed on from this one was the Bezier curve at

http://www.autoitscript.com/forum/index.ph...st&p=592598

Funny thing is, I haven't needed a bezier curve or its points since.

Malkey

Link to comment
Share on other sites

  • 7 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...