Wieso nicht alle Farben?

  • Hallo.

    ich hab da mal ein kleines Script welches ausgehend von dem Slider die gewählte Farbe darstellt. Aber wieso werden so wenige angezigt und nicht alle möglichen?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <Color.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $aiInput[3] = [0, 255, 255]
    Global $aiRGB

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Gui", 800, 400)
    For $i = 0 To 255
    GUICtrlCreateLabel("", 20 + (3 * $i), 10, 3, 20)
    $aiInput[0] = $i
    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $Hex = Hex(Int($aiRGB[0]), 2) & Hex(Int($aiRGB[1]), 2) & Hex(Int($aiRGB[2]), 2)
    GUICtrlSetBkColor(-1, "0x" & $Hex)
    Next
    $hSlider = GUICtrlCreateSlider(11, 40, 785, 20)
    GUICtrlSetLimit(-1, 255)
    $hLabel = GUICtrlCreateLabel("", 20, 80, 50, 50)
    $hInput = GUICtrlCreateInput("", 80, 90, 60, 20)
    $aiInput[0] = GUICtrlRead($hSlider)
    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $Hex = Hex(Int($aiRGB[0]), 2) & Hex(Int($aiRGB[1]), 2) & Hex(Int($aiRGB[2]), 2)
    GUICtrlSetBkColor($hLabel, "0x" & $Hex)
    GUICtrlSetData($hInput, $Hex)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $hSlider
    $aiInput[0] = GUICtrlRead($hSlider)
    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $Hex = Hex(Int($aiRGB[0]), 2) & Hex(Int($aiRGB[1]), 2) & Hex(Int($aiRGB[2]), 2)
    GUICtrlSetBkColor($hLabel, "0x" & $Hex)
    GUICtrlSetData($hInput, $Hex)
    EndSwitch
    WEnd

    [/autoit]

    Einmal editiert, zuletzt von m-obi (9. Mai 2010 um 19:26)

  • HSL hat andere Werte als RGB.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <Color.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $aiInput[3] = [0, 180, 160]
    Global $aiRGB

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Gui", 800, 400)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To 255
    GUICtrlCreateLabel("", 20 + (3 * $i), 10, 3, 20)
    $aiInput[0] = $i
    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $Hex = Hex(Int($aiRGB[0]), 2) & Hex(Int($aiRGB[1]), 2) & Hex(Int($aiRGB[2]), 2)
    GUICtrlSetBkColor(-1, "0x" & $Hex)
    Next
    $hSlider = GUICtrlCreateSlider(11, 40, 785, 20)
    GUICtrlSetLimit(-1, 255)
    $hLabel = GUICtrlCreateLabel("", 20, 80, 50, 50)
    $hInput = GUICtrlCreateInput("", 80, 90, 60, 20)
    $aiInput[0] = GUICtrlRead($hSlider)
    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $Hex = Hex(Int($aiRGB[0]), 2) & Hex(Int($aiRGB[1]), 2) & Hex(Int($aiRGB[2]), 2)
    GUICtrlSetBkColor($hLabel, "0x" & $Hex)
    GUICtrlSetData($hInput, $Hex)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    $aiInput[0] = GUICtrlRead($hSlider)
    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $Hex = Hex(Int($aiRGB[0]), 2) & Hex(Int($aiRGB[1]), 2) & Hex(Int($aiRGB[2]), 2)
    GUICtrlSetBkColor($hLabel, "0x" & $Hex)
    GUICtrlSetData($hInput, $Hex)
    EndSwitch
    $aiInput[0] = GUICtrlRead($hSlider)
    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $Hex = Hex(Int($aiRGB[0]), 2) & Hex(Int($aiRGB[1]), 2) & Hex(Int($aiRGB[2]), 2)
    If GUICtrlRead($hInput) <> $Hex Then
    GUICtrlSetBkColor($hLabel, "0x" & $Hex)
    GUICtrlSetData($hInput, $Hex)
    EndIf
    WEnd

    [/autoit]
  • Ich weiß das HSL andere Werte hat. Sonst hätte ich ja auch alle Werte verändert und nicht nur den ersten mit dem Slider ;).
    Jedenfalls müsste dahin:

    [autoit]

    [0, 240, 120]

    [/autoit]

    Damit habe ich schöne kräftige Farben.
    Aber trotzdem danke nochmal.