Jump to content

Canvas udf flowchartlike examples


Recommended Posts

Hi @junkew, I do not know if this could be useful, however, at this link (https://www.autoitscript.com/forum/topic/168043-realtime-node-framework-like-blenders-node-interface/) there was a script that generated nice diagrams, but it seems that script is no longer available in that topic. By chance I had a copy of it in a folder, which I upload here if it can help you ....

Opt("GUIOnEventMode", 1)

Global Const $iGUIWidth = 1000
Global Const $iGUIHeight = 600


GUICreate("Node Test", $iGUIWidth, $iGUIHeight, -1, -1, -1, 34078728)
GUISetBkColor(0x404040)
GUISetOnEvent(-3, "exut")
GUISetFont(7)

Dim $aMovables[1][7]

$g = GUICtrlCreateGraphic(0,0)
GUICtrlSetState(-1, 128)

$aMovables[0][0] = GUICtrlCreateButton("Render Framework" & @LF & "mode: init", 20, 20, 100, 40, 0x2000)
$aMovables[0][1] = 20
$aMovables[0][2] = 20
$aMovables[0][3] = 100
$aMovables[0][4] = 40
$aMovables[0][5] = "1,2,3"
$aMovables[0][6] = 0xFFFFFF

;AddObject(Text, Pos, Pos, Pos, Pos, Connected Nodes)
AddObject("type: value" & @LF & "mode: per frame" & @LF & "name: SunX", 160, 40, 100, 50, "4")
AddObject("type: value" & @LF & "mode: per frame" & @LF & "name: AmbientLight", 80, 140, 100, 50, "4")
AddObject("type: value" & @LF & "mode: per frame" & @LF & "name: SunRed", 20, 240, 100, 50, "4")
AddObject("type: loop" & @LF & "mode: general" & @LF & "name: ""MainLoop""", 300, 110, 100, 50, "5,6,7,18,23,28,32,37")
AddObject("type: value" & @LF & "mode: per pixel" & @LF & "name: DirectLight", 320, 20, 100, 50, "")
AddObject("type: variable" & @LF & "mode: per pixel" & @LF & "name: ColorARGB", 450, 20, 100, 50, "")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Tree Trunks", 580, 20, 100, 50, "8")
AddObject("formula: tt_01", 740, 20, 100, 20, "9,17")
AddObject("bool: AND", 880, 35, 60, 20, "10")
AddObject("formula: tt_02", 740, 50, 100, 20, "11,17")
AddObject("bool: AND", 880, 65, 60, 20, "12")
AddObject("formula: tt_03", 740, 80, 100, 20, "13,17")
AddObject("bool: AND", 880, 95, 60, 20, "14")
AddObject("formula: tt_04", 740, 110, 100, 20, "15,17")
AddObject("bool: AND", 880, 125, 60, 20, "16")
AddObject("formula: tt_05", 740, 140, 100, 20, "17")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 580, 80, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Light Leaves", 450, 75, 100, 50, "19")
AddObject("formula: ll_01", 580, 140, 100, 20, "20,22")
AddObject("bool: AND", 740, 170, 60, 20, "21")
AddObject("formula: ll_02", 580, 170, 100, 20, "22")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 450, 135, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Dark Leaves", 880, 150, 100, 50, "24")
AddObject("formula: dl_01", 740, 200, 100, 20, "25,27")
AddObject("bool: AND", 880, 210, 60, 20, "26")
AddObject("formula: dl_02", 740, 230, 100, 20, "27")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 580, 200, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Ground", 320, 180, 100, 50, "29")
AddObject("formula: g_01", 450, 200, 100, 20, "30")
AddObject("bool: AND", 360, 240, 60, 20, "31")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 450, 230, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Water", 510, 290, 100, 50, "33")
AddObject("formula: w_01", 365, 290, 100, 20, "34,36")
AddObject("bool: AND", 270, 270, 60, 20, "35")
AddObject("formula: w_02", 365, 330, 100, 20, "36")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 230, 330, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Sun", 630, 260, 100, 50, "38")
AddObject("formula: s_01", 800, 310, 100, 20, "39")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 870, 240, 100, 50, "40")
AddObject("Render Framework" & @LF & "mode: flush", 800, 500, 100, 40, "")



Func AddObject($sText, $iLeft, $iTop, $iWidth, $iHeight, $sNodes, $iColor = 0xFFFFFF)
    $Bound = UBound($aMovables)
    ReDim $aMovables[$Bound+1][7]
    $aMovables[$Bound][0] = GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth, $iHeight, 0x2000)
    $aMovables[$Bound][1] = $iLeft
    $aMovables[$Bound][2] = $iTop
    $aMovables[$Bound][3] = $iWidth
    $aMovables[$Bound][4] = $iHeight
    $aMovables[$Bound][5] = $sNodes
    $aMovables[$Bound][6] = $iColor
EndFunc

DrawBounds()

GUISetState()


While Sleep(20)
    $cur = GUIGetCursorInfo()
    If Not IsArray($cur) Then ContinueLoop
    If $cur[2] = 1 Then
        For $nCtrl = 0 To UBound($aMovables)-1
            If $cur[4] = $aMovables[$nCtrl][0] Then
                $end = GUIGetCursorInfo()
                If Not IsArray($end) Then ContinueLoop
                $dx = $end[0] - $aMovables[$nCtrl][1]
                $dy = $end[1] - $aMovables[$nCtrl][2]
                $iDrawn = 0
                $iTimer = TimerInit()
                Do
                    $end = GUIGetCursorInfo()
                    $aMovables[$nCtrl][1] = $end[0]-$dx
                    $aMovables[$nCtrl][2] = $end[1]-$dy
                    If $aMovables[$nCtrl][1] <= 6 Then $aMovables[$nCtrl][1] = 6
                    If $aMovables[$nCtrl][2] <= 6 Then $aMovables[$nCtrl][2] = 6
                    If $aMovables[$nCtrl][1]+$aMovables[$nCtrl][3] >= ($iGUIWidth-6) Then $aMovables[$nCtrl][1] = ($iGUIWidth-6)-$aMovables[$nCtrl][3]
                    If $aMovables[$nCtrl][2]+$aMovables[$nCtrl][4] >= ($iGUIWidth-26) Then $aMovables[$nCtrl][2] = ($iGUIHeight-26)-$aMovables[$nCtrl][4]
                    $aMovables[$nCtrl][6] = 0x00FF00
                    $back = $g
                    $g = GUICtrlCreateGraphic(0,0)
                    GUICtrlSetState(-1, 128)
                    DrawBounds()
                    For $tCtrl = 0 To UBound($aMovables)-1
                        If $aMovables[$tCtrl][5] <> "" Then
                            $aNodes = StringSplit($aMovables[$tCtrl][5], ",", 3)
                            For $nConnection = 0 To UBound($aNodes)-1
                                If Not IsNodeInObject($aNodes[$nConnection], $tCtrl) Then DrawConnection($tCtrl, $aNodes[$nConnection], $aMovables)
                                $iDrawn += 1
                            Next
                        EndIf
                    Next
                    GUICtrlDelete($back)
                    GUICtrlSetPos($aMovables[$nCtrl][0], $aMovables[$nCtrl][1], $aMovables[$nCtrl][2])
                    $aMovables[$nCtrl][6] = 0xFFFFFF
                Until $end[2] = 0
            EndIf
        Next
    EndIf
WEnd

Func IsNodeInObject(ByRef $iObj, $nNode)
    If $aMovables[$iObj][5] = "" Then Return False
    $f = StringSplit($aMovables[$iObj][5], ",", 3)
    For $b = 0 To UBound($f)-1
        If $f[$b] = $nNode Then Return True
    Next
    Return False
EndFunc

Func DrawConnection($n1,$n2, ByRef $a)
GUICtrlSetGraphic($g,8,$a[$n1][6])
If $a[$n1][1]+$a[$n1][3]<=$a[$n2][1] Then
$n=DrawWire(5+$a[$n1][1]+$a[$n1][3],$a[$n1][2]+($a[$n1][4]/2),$a[$n2][1]-5,$a[$n2][2]+($a[$n2][4]/2))+g($g,12,1+$a[$n1] _
[1]+$a[$n1][3],$a[$n1][2]+($a[$n1][4]/2)-4,9,9)+g($g,12,$a[$n2][1]-10,$a[$n2][2]+($a[$n2][4]/2)-4,9,9)
ElseIf $a[$n1][1]+$a[$n1][3]>=$a[$n2][1] And $a[$n1][1]<=$a[$n2][1]+$a[$n2][3] And $a[$n1][2]+$a[$n1][4]<=$a[$n2][2] Then
$n=DrawWire($a[$n1][1]+($a[$n1][3]/2),$a[$n1][2]+$a[$n1][4]+5,$a[$n2][1]+($a[$n2][3]/2),$a[$n2][2]-6)+g($g,12,$a[$n1][1 _
]+($a[$n1][3]/2)-4,$a[$n1][2]+$a[$n1][4]+1,9,9)+g($g,12,$a[$n2][1]+($a[$n2][3]/2)-4,$a[$n2][2]-10,9,9)
ElseIf $a[$n1][1]+$a[$n1][3]>=$a[$n2][1] And $a[$n1][1]<=$a[$n2][1]+$a[$n2][3] And $a[$n1][2]>=$a[$n2][2]+$a[$n2][4] Then
$n=DrawWire($a[$n1][1]+($a[$n1][3]/2),$a[$n1][2]-6,$a[$n2][1]+($a[$n2][3]/2),$a[$n2][2]+$a[$n2][4]+5)+g($g,12,$a[$n1][1 _
]+($a[$n1][3]/2)-4,$a[$n1][2]-10,9,9)+g($g,12,$a[$n2][1]+($a[$n2][3]/2)-4,$a[$n2][2]+$a[$n2][4]+1,9,9)
ElseIf $a[$n1][1]>=$a[$n2][1]++$a[$n2][3] Then
$n=DrawWire($a[$n1][1]-6,$a[$n1][2]+($a[$n1][4]/2),$a[$n2][1]+$a[$n2][3]+6,$a[$n2][2]+($a[$n2][4]/2))+g($g,12,$a[$n1][1 _
]-10,$a[$n1][2]+($a[$n1][4]/2)-4,9,9)+g($g,12,1+$a[$n2][1]+$a[$n2][3],$a[$n2][2]+($a[$n2][4]/2)-4,9,9)
EndIf
EndFunc

Func g($1, $2, $3, $4, $5, $6)
    GUICtrlSetGraphic($1, $2, $3, $4, $5, $6)
EndFunc

Func DrawBounds()
    GUICtrlSetGraphic($g, 8, 0xFFFFFF)
    GUICtrlSetGraphic($g, 10, 5, 5, ($iGUIWidth-10), ($iGUIHeight-10))
EndFunc

Func DrawWire($x, $y, $x1, $y1)
    $d = ($x1-$x) / 2
    GUICtrlSetGraphic($g, 6, $x, $y)
    GUICtrlSetGraphic($g, 4, $x1, $y1, $x+$d, $y, $x+$d, $y1)
EndFunc

Func exut()
    Exit
EndFunc

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Outside the AutoIt world, there is a very interesting library called jSPlumb (https://github.com/jsplumb/jsplumb). It is a javascript library and it exists in 2 versions: Toolkit Edition (it has a commercial license), and the Community Edition (licensed with the MIT or GPL2 license). The toolkit edition is based on the community edition However. (see demos, down, in the community edition section)
A while ago I thought about creating a wrapper for AutoIt for this very interesting javascript library using the community edition, but I never started.
just another good intention still lying in the dreams box....

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

I am impressed how simple things can be and now found more examples in forum with search on GUICtrlSetGraphic

Rewritten in a more understandable way without magic numbers and simplified array in drawfunctions

Opt("GUIOnEventMode", 1)

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Global Const $iGUIWidth = 1000
Global Const $iGUIHeight = 600

GUICreate("Node Test", $iGUIWidth, $iGUIHeight, -1, -1, -1, 34078728)
GUISetBkColor(0x404040)
GUISetOnEvent($GUI_EVENT_CLOSE, "onExit")
GUISetFont(7)

Dim $aMovables[1][7]

$g = GUICtrlCreateGraphic(0,0)
GUICtrlSetState(-1, 128)

Enum $CNST_ControlID, $CNST_Left, $CNST_Top, $CNST_Width, $CNST_Height, $CNST_NodesConnextedTo, $CNST_Color

$aMovables[0][$CNST_ControlID] = GUICtrlCreateButton("Render Framework" & @LF & "mode: init", 20, 20, 100, 40, 0x2000)
$aMovables[0][$CNST_Left] = 20
$aMovables[0][$CNST_Top] = 20
$aMovables[0][$CNST_Width] = 100
$aMovables[0][$CNST_Height] = 40
$aMovables[0][$CNST_NodesConnextedTo] = "1,2,3"
$aMovables[0][$CNST_Color] = 0xFFFFFF

;AddObject(Text, Pos, Pos, Pos, Pos, Connected Nodes)
AddObject("type: value" & @LF & "mode: per frame" & @LF & "name: SunX", 160, 40, 100, 50, "4")
AddObject("type: value" & @LF & "mode: per frame" & @LF & "name: AmbientLight", 80, 140, 100, 50, "4")
AddObject("type: value" & @LF & "mode: per frame" & @LF & "name: SunRed", 20, 240, 100, 50, "4")
AddObject("type: loop" & @LF & "mode: general" & @LF & "name: ""MainLoop""", 300, 110, 100, 50, "5,6,7,18,23,28,32,37")
AddObject("type: value" & @LF & "mode: per pixel" & @LF & "name: DirectLight", 320, 20, 100, 50, "")
AddObject("type: variable" & @LF & "mode: per pixel" & @LF & "name: ColorARGB", 450, 20, 100, 50, "")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Tree Trunks", 580, 20, 100, 50, "8")
AddObject("formula: tt_01", 740, 20, 100, 20, "9,17")
AddObject("bool: AND", 880, 35, 60, 20, "10")
AddObject("formula: tt_02", 740, 50, 100, 20, "11,17")
AddObject("bool: AND", 880, 65, 60, 20, "12")
AddObject("formula: tt_03", 740, 80, 100, 20, "13,17")
AddObject("bool: AND", 880, 95, 60, 20, "14")
AddObject("formula: tt_04", 740, 110, 100, 20, "15,17")
AddObject("bool: AND", 880, 125, 60, 20, "16")
AddObject("formula: tt_05", 740, 140, 100, 20, "17")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 580, 80, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Light Leaves", 450, 75, 100, 50, "19")
AddObject("formula: ll_01", 580, 140, 100, 20, "20,22")
AddObject("bool: AND", 740, 170, 60, 20, "21")
AddObject("formula: ll_02", 580, 170, 100, 20, "22")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 450, 135, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Dark Leaves", 880, 150, 100, 50, "24")
AddObject("formula: dl_01", 740, 200, 100, 20, "25,27")
AddObject("bool: AND", 880, 210, 60, 20, "26")
AddObject("formula: dl_02", 740, 230, 100, 20, "27")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 580, 200, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Ground", 320, 180, 100, 50, "29")
AddObject("formula: g_01", 450, 200, 100, 20, "30")
AddObject("bool: AND", 360, 240, 60, 20, "31")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 450, 230, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Water", 510, 290, 100, 50, "33")
AddObject("formula: w_01", 365, 290, 100, 20, "34,36")
AddObject("bool: AND", 270, 270, 60, 20, "35")
AddObject("formula: w_02", 365, 330, 100, 20, "36")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 230, 330, 100, 50, "40")
AddObject("type: element" & @LF & "mode: per pixel" & @LF & "name: Sun", 630, 260, 100, 50, "38")
AddObject("formula: s_01", 800, 310, 100, 20, "39")
AddObject("type: modifier" & @LF & "mode: requested" & @LF & "name: SetColor", 870, 240, 100, 50, "40")
AddObject("Render Framework" & @LF & "mode: flush", 800, 500, 100, 40, "")

Func AddObject($sText, $iLeft, $iTop, $iWidth, $iHeight, $sNodes, $iColor = 0xFFFFFF)
    $Bound = UBound($aMovables)
    ReDim $aMovables[$Bound+1][7]
    $aMovables[$Bound][$CNST_ControlID] = GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth, $iHeight, 0x2000)
    $aMovables[$Bound][$CNST_Left] = $iLeft
    $aMovables[$Bound][$CNST_Top] = $iTop
    $aMovables[$Bound][$CNST_Width] = $iWidth
    $aMovables[$Bound][$CNST_Height] = $iHeight
    $aMovables[$Bound][$CNST_NodesConnextedTo] = $sNodes
    $aMovables[$Bound][$CNST_Color] = $iColor
EndFunc

DrawBounds()
DrawTheScene(0,0,0,0,0)

GUISetState()

While Sleep(20)
    $cur = GUIGetCursorInfo()
    If isArray($cur) Then 
        drawTheScene($cur[0],$cur[1],$cur[2],$cur[3],$cur[4])
    EndIf
WEnd

func drawTheScene($x, $y, $primaryDown, $secondaryDown, $hoveredControlId)
    if $primaryDown=0 then Return
    For $nCtrl = 0 To UBound($aMovables)-1
        If $hoveredControlId=$aMovables[$nCtrl][$CNST_ControlID] Then
            $end = GUIGetCursorInfo()
            If Not IsArray($end) Then ContinueLoop
            $dx = $end[0] - $aMovables[$nCtrl][$CNST_Left]
            $dy = $end[1] - $aMovables[$nCtrl][$CNST_Top]
            $iDrawn = 0
            $iTimer = TimerInit()
            Do
                $end = GUIGetCursorInfo()
                $aMovables[$nCtrl][$CNST_Left] = $end[0]-$dx
                $aMovables[$nCtrl][$CNST_Top] = $end[1]-$dy

;~ 'Keep it in the bounds. defect for the bottom
                If $aMovables[$nCtrl][$CNST_Left] <= 6 Then $aMovables[$nCtrl][$CNST_Left] = 6
                If $aMovables[$nCtrl][$CNST_Top] <= 6 Then $aMovables[$nCtrl][$CNST_Top] = 6
                If $aMovables[$nCtrl][$CNST_Left]+$aMovables[$nCtrl][$CNST_Width] >= ($iGUIWidth-6) Then $aMovables[$nCtrl][$CNST_Left] = ($iGUIWidth-6)-$aMovables[$nCtrl][$CNST_Width]
                If $aMovables[$nCtrl][$CNST_Top]+$aMovables[$nCtrl][$CNST_Height] >= ($iGUIWidth-26) Then $aMovables[$nCtrl][$CNST_Top] = ($iGUIHeight-26)-$aMovables[$nCtrl][$CNST_Height]
                $aMovables[$nCtrl][$CNST_Color] = 0x00FF00

                $back = $g
                $g = GUICtrlCreateGraphic(0,0)
                GUICtrlSetState(-1, 128)

                DrawBounds()
                
                For $tCtrl = 0 To UBound($aMovables)-1
                    If $aMovables[$tCtrl][$CNST_NodesConnextedTo] <> "" Then
                        $aNodes = StringSplit($aMovables[$tCtrl][$CNST_NodesConnextedTo], ",", 3)
                        For $nConnection = 0 To UBound($aNodes)-1
;~ '                            If Not IsNodeInObject($aNodes[$nConnection], $tCtrl) Then DrawConnection($tCtrl, $aNodes[$nConnection], $aMovables)
                            If Not IsNodeInObject($aNodes[$nConnection], $tCtrl) Then DrawConnection(_ArrayRow($amovables,$tCtrl), _ArrayRow($aMovables, $aNodes[$nConnection]), $aMovables)
                            $iDrawn += 1
                        Next
                    EndIf
                Next
                GUICtrlDelete($back)
                GUICtrlSetPos($aMovables[$nCtrl][$CNST_ControlID], $aMovables[$nCtrl][$CNST_Left], $aMovables[$nCtrl][$CNST_Top])
                $aMovables[$nCtrl][$CNST_Color] = 0xFFFFFF
            Until $end[2] = 0
        EndIf
    Next

EndFunc

Func IsNodeInObject(ByRef $iObj, $nNode)
    If $aMovables[$iObj][$CNST_NodesConnextedTo] = "" Then Return False
    $f = StringSplit($aMovables[$iObj][$CNST_NodesConnextedTo], ",", 3)
    For $b = 0 To UBound($f)-1
        If $f[$b] = $nNode Then Return True
    Next
    Return False
EndFunc

;~ To get only one row to get passed to other function
Func _ArrayRow($array,$iRow)
    Local $aRow[UBound($array,2)]
    For $i = 0 To UBound($aRow) - 1
        $aRow[$i] = $array[$iRow][$i]
    Next
    Return $aRow
EndFunc

Func DrawConnection($n1, $n2, ByRef $a)
    GUICtrlSetGraphic($g,$GUI_GR_COLOR,$n1[$CNST_Color])
    If $n1[$CNST_Left]+$n1[$CNST_Width]<=$n2[$CNST_Left] Then
        drawWire(5+$n1[$CNST_Left]+$n1[$CNST_Width], $n1[$CNST_Top]+($n1[$CNST_Height]/2), $n2[$CNST_Left]-5, $n2[$CNST_Top]+($n2[$CNST_Height]/2))
        drawAnchor($g,$GUI_GR_ELLIPSE, 1+$n1[$CNST_Left]+$n1[$CNST_Width], $n1[$CNST_Top]+($n1[$CNST_Height]/2)-4, 9, 9) 
        drawAnchor($g,$GUI_GR_ELLIPSE, $n2[$CNST_Left]-10, $n2[$CNST_Top]+($n2[$CNST_Height]/2)-4, 9, 9)
    ElseIf $n1[$CNST_Left]+$n1[$CNST_Width]>=$n2[$CNST_Left] And $n1[$CNST_Left]<=$n2[$CNST_Left]+$n2[$CNST_Width] And $n1[$CNST_Top]+$n1[$CNST_Height]<=$n2[$CNST_Top] Then
        drawWire($n1[$CNST_Left]+($n1[$CNST_Width]/2),$n1[$CNST_Top]+$n1[$CNST_Height]+5,$n2[$CNST_Left]+($n2[$CNST_Width]/2),$n2[$CNST_Top]-6)
        drawAnchor($g,$GUI_GR_ELLIPSE, $n1[$CNST_Left]+($n1[$CNST_Width]/2)-4,$n1[$CNST_Top]+$n1[$CNST_Height]+1,9,9) 
        drawAnchor($g,$GUI_GR_ELLIPSE, $n2[$CNST_Left]+($n2[$CNST_Width]/2)-4,$n2[$CNST_Top]-10,9,9)
    ElseIf $n1[$CNST_Left]+$n1[$CNST_Width]>=$n2[$CNST_Left] And $n1[$CNST_Left]<=$n2[$CNST_Left]+$n2[$CNST_Width] And $n1[$CNST_Top]>=$n2[$CNST_Top]+$n2[$CNST_Height] Then
        drawWire($n1[$CNST_Left]+($n1[$CNST_Width]/2),$n1[$CNST_Top]-6,$n2[$CNST_Left]+($n2[$CNST_Width]/2),$n2[$CNST_Top]+$n2[$CNST_Height]+5) 
        drawAnchor($g,$GUI_GR_ELLIPSE, $n1[$CNST_Left]+($n1[$CNST_Width]/2)-4,$n1[$CNST_Top]-10,9,9)
        drawAnchor($g,$GUI_GR_ELLIPSE, $n2[$CNST_Left]+($n2[$CNST_Width]/2)-4,$n2[$CNST_Top]+$n2[$CNST_Height]+1,9,9)
    ElseIf $n1[$CNST_Left]>=$n2[$CNST_Left]++$n2[$CNST_Width] Then
        drawWire($n1[$CNST_Left]-6,$n1[$CNST_Top]+($n1[$CNST_Height]/2),$n2[$CNST_Left]+$n2[$CNST_Width]+6,$n2[$CNST_Top]+($n2[$CNST_Height]/2))
        drawAnchor($g,$GUI_GR_ELLIPSE, $n1[$CNST_Left]-10,$n1[$CNST_Top]+($n1[$CNST_Height]/2)-4,9,9)
        drawAnchor($g,$GUI_GR_ELLIPSE, 1+$n2[$CNST_Left]+$n2[$CNST_Width],$n2[$CNST_Top]+($n2[$CNST_Height]/2)-4,9,9)
    EndIf
EndFunc

Func drawAnchor($controlID, $type, $3, $4, $5, $6)
    GUICtrlSetGraphic($controlID, $type, $3, $4, $5, $6)
EndFunc

Func DrawBounds()
    GUICtrlSetGraphic($g, $GUI_GR_COLOR, 0xFFFFFF)
    GUICtrlSetGraphic($g, $GUI_GR_RECT, 5, 5, ($iGUIWidth-10), ($iGUIHeight-10))
EndFunc

Func DrawWire($x, $y, $x1, $y1)
    $d = ($x1-$x) / 2
    GUICtrlSetGraphic($g, $GUI_GR_MOVE, $x, $y)
    GUICtrlSetGraphic($g, $GUI_GR_BEZIER, $x1, $y1, $x+$d, $y, $x+$d, $y1)
EndFunc

Func onExit()
    Exit
EndFunc

 

Link to comment
Share on other sites

Ok been reading a little more in the forum and basically found out below (besides beeing surprised we can handle this in AutoIt)

  1. GUICtrlCreateGraphic / GUICtrlSetGraphic / GUICtrlCreatePic
  2. USE GDIPlus (feels more complicated/much more coding and wrappers to write)
  3. Combine 1 and 2 
    ControlGetHandle from GUICtrlCreateGraphic
    _GDIPlus_GraphicsCreateFromHWND
    "regular" GDI stuff
  4. ....
  • Any thoughts on what will work better in the end?
    Benefits like speed, flickering, .... when using one over the other
    Dragging/dropping/moving seems to be easier with GUICtrlCreateGraphic
  • Goal is simple procesflow/flowchart drawing (with MS Visio/PPT objCreate it can easily be exported if people want to have more functionality) into GUI of AutoIt build executable.
  • So a simple next step could be to have the choice symbol drawn on the screen but then I would like to understand a little better which approach will work out better lets assume staying below 500 graphical objects.

 

 

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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