Jump to content

GUISetBKColor(For 0xFF0000 To 0x0000FF Step -1 Next)


Info
 Share

Recommended Posts

I want to make a continuously from the red color (0xFF0000) to the far blue color (0x0000FF) wich will appear in the backround color in my GUI...

Thanks for the helpers :D

Edited by Info
Link to comment
Share on other sites

I want to make a continuously from the red color (0xFF0000) to the far blue color (0x0000FF) wich will appear in the backround color in my GUI...

Thanks for the helpers :D

Use the for next loop to get an index value:

For $i = 0 To 0xFF
    ; Do stuff
Next

During the loop you can add the index to 0 to get increasing values for one, and subtract the same index from 0xFF to get decreasing values for the other:

$iRed = 0 + $i
$iBlue = 0xFF - $i
$iColor = (0x010000 * $iRed) + $iBlue

Going back the other way just means switching the values:

$iRed = 0xFF - $i
$iBlue = 0 + $i
$iColor = (0x010000 * $iRed) + $iBlue

I did a demo a ways back that continuously varies the BKColor of a progress bar by changing all three primary colors with only slightly more math, but I don't have a link handy at the moment.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Func XSkinGradient($nXSkinGUI, $nStartColor, $nEndColor)
    Local $nSize = WinGetClientSize($nXSkinGUI)
    Local $nX=0, $nY=0, $nWidth=$nSize[0], $nHeight=$nSize[1]
    Local $color1R = _ColorGetRed($nStartColor)
    Local $color1G = _ColorGetGreen($nStartColor)
    Local $color1B = _ColorGetBlue($nStartColor)
    Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight
    Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight
    Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight
    $nGraph = GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    For $i = 0 To $nHeight - $nY
        $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
    Next
    GUICtrlSetState( $nGraph, $GUI_DISABLE)
    Return $nGraph
EndFunc

Be sure to #include <Color.au3>

.... more here

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

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I made a Gradient Function some time ago:

;===============================================================================
;
; Function Name:   _Gradient($RGB_Color1 ,$RGB_Color2, $Count)
; Description::    Returns an Array of Gradient Colors
; Parameter(s):    $RGB_Color1 : The Start-Color in RGB Hexadecimal
;                  $RGB_Color2 : The End-Color in RGB Hexadecimal
;                  $Count :      The number of Colors in the Gradient
; Requirement(s):  
; Return Value(s): An Array with the Colors
; Author(s):       Prog@ndy
;
;===============================================================================
;

Func _Gradient($RGB_Color1 ,$RGB_Color2, $Count)
    Local $Color1_R, $Color1_G, $Color1_B, $Color2_R, $Color2_G, $Color2_B, $NeuCol_R, $NeuCol_G, $NeuCol_B
    
    $Color1_R = BitAND( BitShift($RGB_Color1, 16), 0xff)
    $Color1_G = BitAND( BitShift($RGB_Color1, 8), 0xff)
    $Color1_B = BitAND($RGB_Color1, 0xff)
    
    $Color2_R = BitAND( BitShift($RGB_Color2, 16), 0xff)
    $Color2_G = BitAND( BitShift($RGB_Color2, 8), 0xff)
    $Color2_B = BitAND($RGB_Color2, 0xff)
    
    $Count -= 1 ; 0-basiert !
    Dim $arColors[$Count+1], $pos1
    
    For $i = 0 To $Count
        $pos1 = $Count - $i
        $NeuCol_R = ($Color1_R * $pos1 + $Color2_R * $i) / ($Count)
        $NeuCol_G = ($Color1_G * $pos1 + $Color2_G * $i) / ($Count)
        $NeuCol_B = ($Color1_B * $pos1 + $Color2_B * $i) / ($Count)
        $arColors[$i] = Execute("0x" & Hex($NeuCol_R,2) & Hex($NeuCol_G,2) & Hex($NeuCol_B,2))
    Next
    Return $arColors
EndFunc

In each step, the Value of each color-component is combined from the decrementing value of the source-color and the incrementing amount of the destination-color. In the end, we have all color components from Color 2

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

@Valuater, You just gave me a code without explaining anyting...

....WOW

do you see this

XSkinGradient($nXSkinGUI, $nStartColor, $nEndColor)

did you even bother to click the link to the demo and pictures and example ?????????????????????????? ?????????????????????

?

8)

NEWHeader1.png

Link to comment
Share on other sites

I played a little and found this to be quite interesting:

#include <GUIConstantsEx.au3>
Opt("GuiOnEventMode", 1)
GUICreate("test")
GUISetState()
GUISetOnEvent(-3, "close")
Dim $color, $redm=1, $bluem=2, $greenm=3, $index
While 1
    Sleep(10)
    $index+=0.01
    $color="0x"&Hex(255*((Sin($index*$redm)+1)/2),2)& Hex(255*((Sin($index*$greenm)+1)/2),2)&Hex(255*((Sin($index*$bluem)+1)/2),2)
    GUISetBkColor($color)
WEnd
Func close()
    Exit
EndFunc   ;==>close

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

Link to comment
Share on other sites

I played a little and found this to be quite interesting:

#include <GUIConstantsEx.au3>
Opt("GuiOnEventMode", 1)
GUICreate("test")
GUISetState()
GUISetOnEvent(-3, "close")
Dim $color, $redm=1, $bluem=2, $greenm=3, $index
While 1
    Sleep(10)
    $index+=0.01
    $color="0x"&Hex(255*((Sin($index*$redm)+1)/2),2)& Hex(255*((Sin($index*$greenm)+1)/2),2)&Hex(255*((Sin($index*$bluem)+1)/2),2)
    GUISetBkColor($color)
WEnd
Func close()
    Exit
EndFunc   ;==>closeoÝ÷ Ûú®¢×¢ÐZw}÷ß}Üæ§yØ­º§u8Ê
"h¦Vz+b­¢+V­ªiz»ºÚ"µÍÚ[ÛYH  ÑÕRPÛÛÝ[Ñ^]LÉÝÂ[H  ÌÍØÛÛÜ    ÌÍÜYHHK  ÌÍØY[HH  ÌÍÙÜY[HHË  ÌÍÚ[^ÕRPÜX]J   ][ÝÝÝ    ][ÝÊBÕRTÙ]Ý]J
BÚ[HÕRQÙ]ÙÊ
H   ÉÝÈLÂÛY
L
B   ÌÍÚ[^
ÏHB    ÌÍØÛÛÜH   ][ÝÌ  ][ÝÈ  [È^
MH


Ú[ ÌÍÚ[^
    ÌÍÜYJH
ÈJHÈKH    [È^
MH


Ú[ ÌÍÚ[^
    ÌÍÙÜY[JH
ÈJHÈKH    [È^
MH


Ú[ ÌÍÚ[^
    ÌÍØY[JH
ÈJHÈKBÕRTÙ]ÐÛÛÜ ÌÍØÛÛÜBÑ[

8)

NEWHeader1.png

Link to comment
Share on other sites

I played a little and found this to be quite interesting:

#include <GUIConstantsEx.au3>
Opt("GuiOnEventMode", 1)
GUICreate("test")
GUISetState()
GUISetOnEvent(-3, "close")
Dim $color, $redm=1, $bluem=2, $greenm=3, $index
While 1
    Sleep(10)
    $index+=0.01
    $color="0x"&Hex(255*((Sin($index*$redm)+1)/2),2)& Hex(255*((Sin($index*$greenm)+1)/2),2)&Hex(255*((Sin($index*$bluem)+1)/2),2)
    GUISetBkColor($color)
WEnd
Func close()
    Exit
EndFunc   ;==>close
Thanks :D

Helped me a lot :D

Edit:

Is there a way to convert it to a .gif image?

Edited by Info
Link to comment
Share on other sites

record it :D

Example:

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Original Post:

Asking for continuously from the red to blue (Gradient)

I want to make a continuously from the red color (0xFF0000) to the far blue color (0x0000FF) wich will appear in the backround color in my GUI...

Midway Post:

Accepting the "changing color" GUI (Not Gradient)

Thanks :D

Helped me a lot :D

Last Post/Edit

Wanting it to be a "Picture"

Edit:

Is there a way to convert it to a .gif image?

????

8)

NEWHeader1.png

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...