AlmarM Posted March 1, 2010 Share Posted March 1, 2010 (edited) Hiya! I'm experimenting some with AutoIt now, and I would like to know how to do some color blending. I need to start with like 2 variables, "StartColor" and "EndColor", basicly from color, blend to EndColor. I know that the total steps is 315. This is the script im using, it totally fails right now. The reason? I have no clue where to start. expandcollapse popupHotKeySet("{ESC}", "_Exit") Global $A = 375 Global $B = 275 Global $R = 200 Global $Angle = 0 Global $Pi = 3.14 Global $Draw = True Global $StartColor = 0x000000 Global $EndColor = 0xFF0000 Global $Color Global $objNum = 0 $GUI = GUICreate("", 800, 600) $obj = GUICtrlCreateLabel("", 10, 580, 15, 15) $Label = GUICtrlCreateLabel("", 10, 500, 200, 100) GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit EndSwitch $Angle += 0.02 $X = Round($R * Sin($Angle), 0) $Y = Round($R * Cos($Angle), 0) If $Angle > $Pi * 2 Then $Angle = 0 Draw() $Draw = False EndIf GUICtrlSetPos($obj, $X + $A, $Y + $B) Draw() GUICtrlSetData($Label, "Angle: " & Round($Angle, 2) & @CRLF & _ "X Raw: " & $X & @CRLF & _ "Y Raw: " & $Y & @CRLF & _ "X Add: " & $X + $A & @CRLF & _ "Y Add: " & $Y + $B & @CRLF & _ "Color: " & "0x" & Hex($Color, 6) & @CRLF & _ "objNum: " & $objNum) Sleep(50) WEnd Func Draw() If $Draw Then $Color += $EndColor ; Do something with $Color GUICtrlCreateLabel("", $X + $A, $Y + $B, 15, 15) GUICtrlSetBkColor(-1, "0x" & Hex($Color, 6)) $objNum += 1 EndIf EndFunc Func _Exit() Exit EndFunc Where should I start, or does anyone eventually has an example for me? AlmarM Edited March 1, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2010 Moderators Share Posted March 1, 2010 AlmarM, Here is your script modified a bit to show how i would go about getting the colours to change as you go round. I think the comments are clear enough: expandcollapse popup#Include <Color.au3> HotKeySet("{ESC}", "_Exit") Global $A = 375 Global $B = 275 Global $R = 200 Global $Angle = 0 Global $Pi = 3.14159265358979 Global $Draw = True Global $StartColor = 0x805060 Global $EndColor = 0xFFA070 Global $sColor = $StartColor Global $objNum = 0 ; Get colour elements for StartColor $iStartRed = _ColorGetRed($StartColor) $nRed = $iStartRed $iStartGreen = _ColorGetGreen($StartColor) $nGreen = $iStartGreen $iStartBlue = _ColorGetBlue($StartColor) $nBlue = $iStartBlue ; Get colour elements for EndColor $iEndRed = _ColorGetRed($EndColor) $iEndGreen = _ColorGetGreen($EndColor) $iEndBlue = _ColorGetBlue($EndColor) ; Determine delta to add to each colour at each iteration (set at 360) $nDeltaRed = ($iEndRed - $iStartRed) / 360 $nDeltaGreen = ($iEndGreen - $iStartGreen) / 360 $nDeltaBlue = ($iEndBlue - $iStartBlue) / 360 $GUI = GUICreate("", 800, 600) $obj = GUICtrlCreateLabel("", 10, 580, 15, 15) $Label = GUICtrlCreateLabel("", 10, 500, 200, 100) GUISetState() Do Switch GUIGetMsg() Case -3 Exit EndSwitch $Angle += 2 * $Pi / 360 ; 360 iterations $X = Round($R * Sin($Angle), 0) $Y = Round($R * Cos($Angle), 0) GUICtrlSetPos($obj, $X + $A, $Y + $B) Draw() GUICtrlSetData($Label, "Angle: " & Round($Angle, 2) & @CRLF & _ "X Raw: " & $X & @CRLF & _ "Y Raw: " & $Y & @CRLF & _ "X Add: " & $X + $A & @CRLF & _ "Y Add: " & $Y + $B & @CRLF & _ "Color: " & "0x" & Hex($sColor, 6) & @CRLF & _ "objNum: " & $objNum) Sleep(50) Until $Angle > 2 * $Pi ; Full circle reached While 1 If GUIGetMsg() = -3 Then Exit WEnd Func Draw() ; Add delta to each colour element $nRed += $nDeltaRed $nGreen += $nDeltaGreen $nBlue += $nDeltaBlue ; Construct colour $sColor = "0x" & Hex(Int($nRed), 2) & Hex(Int($nGreen), 2) & Hex(Int($nBlue), 2) GUICtrlCreateLabel("", $X + $A, $Y + $B, 15, 15) GUICtrlSetBkColor(-1, $sColor) $objNum += 1 EndFunc Func _Exit() Exit EndFunc You might also want to look at Yashied's WinAPIEx.au3 UDF - it has some nice gradient functions which take away all of the hard work! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AlmarM Posted March 1, 2010 Author Share Posted March 1, 2010 Thanks! That realy helped me out. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now