GuiCtrlCreateGraphic einfärben

  • Hi leute!

    Ich hab mal ein problem: nämlich möchte ich ein Progrämmelchen erstellen, das farbübergänge von vier ecken Berechnet und das dann in einer GUI darstellt. Werte kommen raus (vermutlich noch falsch :rolleyes: aber das kommt noch) aber dargestellt werden sie nicht.

    Ich bitte um Hilfe.

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <Color.au3>
    #include <Array.au3>
    $hGUI=GUICreate("Color Mutation",300,80,0,0)
    GUICtrlCreateLabel("Start Color (hex)",0,3,100,20)
    $start=GUICtrlCreateInput("",100,0,200,20)
    GUICtrlCreateLabel("End Color (hex)",0,23,100,20)
    $end=GUICtrlCreateInput("",100,20,200,20)
    GUICtrlCreateLabel("Parts (int)",0,43,100,20)
    $parts=GUICtrlCreateInput("",100,40,200,20)
    $run=GUICtrlCreateButton("Start mutation",0,60,300,20)
    $Newgui=1234
    GUISetState()
    While True
    $msg=GUIGetMsg()
    If $msg=$run Then
    GUIDelete($Newgui)
    If True Then
    $startColor=GUICtrlRead($start)
    $endColor=GUICtrlRead($end)
    $partsNumber=GUICtrlRead($parts)
    $startRGB=_ColorGetRGB($startColor)
    $endRGB=_ColorGetRGB($endColor)
    $rStep=($startRGB[0]-$endRGB[0])/$partsNumber
    $gStep=($startRGB[1]-$endRGB[1])/$partsNumber
    $bStep=($startRGB[2]-$endRGB[2])/$partsNumber
    Dim $Colors[$partsNumber+1]
    $Colors[0]=$partsNumber
    Dim $TempColors[3]
    For $i=1 To $partsNumber
    $TempColors[0]=$startRGB[0]-($rStep*$i)
    $TempColors[1]=$startRGB[1]-($gStep*$i)
    $TempColors[2]=$startRGB[2]-($bStep*$i)
    $Colors[$i]=StringTrimRight(StringFormat("%#06x\t",_ColorSetRGB($TempColors)),1)
    Next
    $Newgui=GUICreate("",$partsNumber,100,-1,-1,$WS_POPUP)
    Dim $Graphic[$partsNumber+1]
    $Graphic[0]=$partsNumber
    For $i=1 To $partsNumber
    $Graphic=GUICtrlCreateGraphic($i-1,0,1,100)
    GUICtrlSetBkColor($Graphic,$Colors[$i])
    Next
    $Graphic=""
    GUISetState()
    EndIf
    EndIf
    If $msg=$GUI_EVENT_CLOSE Then Exit
    WEnd

    [/autoit]

    Schon mal danke im Vorraus.

  • Hi,

    Zitat

    Werte kommen raus (vermutlich noch falsch aber das kommt noch) aber dargestellt werden sie nicht.

    Was wird nicht dargestellt? Der Farbverlauf wird bei mir mit XP32 dargestellt
    Parameter:
    112233
    667788
    100
    ergibt ein Fenster mit einem Farbverlauf

  • Tut mir leid

    Mir ist gerade aufgefallen, das ich nicht das richtige Script reingestellt habe :(

    Das ist das richtige:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <Color.au3>
    #include <Array.au3>
    $hGUI=GUICreate("Color Mutation",600,80,0,0)
    GUICtrlCreateLabel("UL (hex)",0,3,100,20)
    $UL=GUICtrlCreateInput("",100,0,200,20)
    GUICtrlCreateLabel("DL (hex)",0,23,100,20)
    $DL=GUICtrlCreateInput("",100,20,200,20)
    GUICtrlCreateLabel("UR (hex)",300,3,100,20)
    $UR=GUICtrlCreateInput("",400,0,200,20)
    GUICtrlCreateLabel("DR (hex)",300,23,100,20)
    $DR=GUICtrlCreateInput("",400,20,200,20)
    GUICtrlCreateLabel("Vertical Parts (int)",0,43,100,20)
    $yparts=GUICtrlCreateInput("",100,40,200,20)
    GUICtrlCreateLabel("Horizontal Parts (int)",300,43,100,20)
    $xparts=GUICtrlCreateInput("",400,40,200,20)
    $run=GUICtrlCreateButton("Start mutation",0,60,600,20)
    $Newgui=1234
    GUISetState()
    While True
    $msg=GUIGetMsg()
    If $msg=$run Then
    GUIDelete($Newgui)
    If True Then
    $xparts_read=GUICtrlRead($xparts)
    $yparts_read=GUICtrlRead($yparts)
    $UL_Color=GUICtrlRead($UL)
    $UL_RGBArray=_ColorGetRGB($UL_Color)
    $UR_Color=GUICtrlRead($UR)
    $UR_RGBArray=_ColorGetRGB($UR_Color)
    $DL_Color=GUICtrlRead($DL)
    $DL_RGBArray=_ColorGetRGB($DL_Color)
    $DR_Color=GUICtrlRead($DR)
    $DR_RGBArray=_ColorGetRGB($DR_Color)

    $UStepLen_r=($UL_RGBArray[0]-$UR_RGBArray[0])/$xparts_read
    $UStepLen_g=($UL_RGBArray[1]-$UR_RGBArray[1])/$xparts_read
    $UStepLen_b=($UL_RGBArray[2]-$UR_RGBArray[2])/$xparts_read
    MsgBox(0,"u",$UStepLen_r&@LF&$UStepLen_g&@LF&$UStepLen_b)

    $RStepLen_r=($UR_RGBArray[0]-$DR_RGBArray[0])/$yparts_read
    $RStepLen_g=($UR_RGBArray[1]-$DR_RGBArray[1])/$yparts_read
    $RStepLen_b=($UR_RGBArray[2]-$DR_RGBArray[2])/$yparts_read
    MsgBox(0,"r",$RStepLen_r&@LF&$RStepLen_g&@LF&$RStepLen_b)

    $DStepLen_r=($DL_RGBArray[0]-$DR_RGBArray[0])/$xparts_read
    $DStepLen_g=($DL_RGBArray[1]-$DR_RGBArray[1])/$xparts_read
    $DStepLen_b=($DL_RGBArray[2]-$DR_RGBArray[2])/$xparts_read
    MsgBox(0,"d",$DStepLen_r&@LF&$DStepLen_g&@LF&$DStepLen_b)

    $LStepLen_r=($UL_RGBArray[0]-$DL_RGBArray[0])/$yparts_read
    $LStepLen_g=($UL_RGBArray[1]-$DL_RGBArray[1])/$yparts_read
    $LStepLen_b=($UL_RGBArray[2]-$DL_RGBArray[2])/$yparts_read
    MsgBox(0,"l",$LStepLen_r&@LF&$LStepLen_g&@LF&$LStepLen_b)

    $StartColor_r=$UR_RGBArray[0]
    $StartColor_g=$UR_RGBArray[1]
    $StartColor_b=$UR_RGBArray[2]

    $Newgui=GUICreate("Mutated!!!",$xparts_read,$yparts_read,-1,-1)
    For $i_x=1 To $xparts_read
    For $i_y=1 To $yparts_read
    $TMPRGBCOLOR="0x"&Hex($StartColor_r+$RStepLen_r*$i_y+$DStepLen_r*$i_x,2)&Hex($StartColor_g+$RStepLen_g*$i_y+$DStepLen_g*$i_x,2)&Hex($StartColor_b+$RStepLen_b*$i_y+$DStepLen_b*$i_x,2)
    ToolTip($i_x&" - "&$i_y&@LF&$TMPRGBCOLOR)
    $TMPGRAPHIC=GUICtrlCreateGraphic($i_x-1,$i_y-1,1,1)
    GUICtrlSetBkColor($TMPGRAPHIC,$TMPRGBCOLOR)
    Next
    Next

    GUISetState(@SW_SHOW,$Newgui)
    EndIf
    EndIf
    If $msg=$GUI_EVENT_CLOSE Then Exit
    WEnd

    [/autoit]
  • Hi,
    ändere mal die Grösse der Controls...z.B.

    [autoit]

    $TMPGRAPHIC=GUICtrlCreateGraphic($i_x-1,$i_y-1,2,2)

    [/autoit]