Jump to content

Search the Community

Showing results for tags 'Hue'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hey everyone. I want to add a theming engine to a program of mine, so that there is multiple hues, ie red, green, orange, blue and so on. I also want to be able to change the brightness of the background, ie you can choose between a range oflight greys through to dark greys. I have searched the forum and came across this: #include<Array.au3> #include<Color.au3> #include<GUIConstantsEx.au3> GUICreate("",360,350) $gra = GUICtrlCreateGraphic(0,0,360,20) GUISetState() $Color = 0xFFff00 GUISetBkColor($Color) ConsoleWrite("Color: 0x" & Hex($Color, 6) & @CRLF) ConsoleWrite("Saturation: " & _Color_GetSaturation($Color) & " %" & @CRLF) ConsoleWrite("Brightness: " & _Color_GetBrightness($Color) & " %" & @CRLF) ConsoleWrite("Hue: " & _Color_GetHue($Color) & " º" & @CRLF) Sleep(1000) ConsoleWrite("Complementary color: " & _Color_FindComplementary($Color) & @CRLF & @CRLF) $i = 0 While $i < 2 $i += 1 GUISetBkColor(_Color_FindComplementary($Color)) Sleep(500) GUISetBkColor($Color) Sleep(500) WEnd GUISetBkColor(0) For $x = 0 To 360 Step 2 $hue = _Color_SetHue($Color, $x) ConsoleWrite("Hue: " & $x & " º" & $hue & @CRLF) ;~ GUISetBkColor($hue) GUICtrlSetGraphic($gra,$GUI_GR_COLOR,$hue,$hue) GUICtrlSetGraphic($gra,$GUI_GR_RECT,$x,0,2,20) GUICtrlSetGraphic($gra,$GUI_GR_REFRESH) Sleep(30) Next Sleep(500) GUISetBkColor($Color) GUICtrlDelete($gra) $gra = GUICtrlCreateGraphic(0,0,350,20) $gra2 = GUICtrlCreateGraphic(0,20,350,20) ConsoleWrite(" Saturation: Brightness:" & @CRLF) For $x = 0 To 100 $sat = _Color_SetSaturation($Color, $x) $brigth = _Color_SetBrightness($Color, $x) ConsoleWrite($x & " % " & $sat & " " & $brigth & @CRLF) GUICtrlSetGraphic($gra,$GUI_GR_COLOR,$sat,$sat) GUICtrlSetGraphic($gra2,$GUI_GR_COLOR,$brigth,$brigth) GUICtrlSetGraphic($gra,$GUI_GR_RECT,350*$x/100,0,Ceiling (350/100),20) GUICtrlSetGraphic($gra2,$GUI_GR_RECT,350*$x/100,0,Ceiling( 350/100),20) GUICtrlSetGraphic($gra,$GUI_GR_REFRESH) GUICtrlSetGraphic($gra2,$GUI_GR_REFRESH) Sleep(30) Next Func _Color_SetSaturation($iColor, $nPercent) Local $aColorArray[4] $nPercent = 1 - ($nPercent / 100) $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) If $aColorArray[1] = $aColorArray[2] And $aColorArray[2] = $aColorArray[3] Then Return -1 $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $IndexMin = _ArrayMinIndex($aColorArray, 1, 1) $IndexMid = 6 - ($IndexMax + $IndexMin) $aColorArray[$IndexMid] = ($aColorArray[$IndexMax] * ($aColorArray[$IndexMid] - $aColorArray[$IndexMin])) / ($aColorArray[$IndexMax] - $aColorArray[$IndexMin]) $aColorArray[$IndexMid] = Round($aColorArray[$IndexMid] + ($aColorArray[$IndexMax] - $aColorArray[$IndexMid]) * $nPercent, 0) $aColorArray[$IndexMin] = Round($aColorArray[$IndexMax] * $nPercent, 0) Return 0 & "x" & Hex($aColorArray[1], 2) & Hex($aColorArray[2], 2) & Hex($aColorArray[3], 2) EndFunc ;==>_Color_SetSaturation Func _Color_GetSaturation($iColor) Local $aColorArray[4] $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $IndexMin = _ArrayMinIndex($aColorArray, 1, 1) $IndexMid = 6 - ($IndexMax + $IndexMin) Return Round((1 - $aColorArray[$IndexMin] / $aColorArray[$IndexMax]) * 100, 0) EndFunc ;==>_Color_GetSaturation Func _Color_SetBrightness($iColor, $nPercent) Local $aColorArray[4] $nPercent = $nPercent / 100 $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $ActBrightness = $aColorArray[$IndexMax] / 255 For $i = 1 To 3 $aColorArray[$i] = Round($aColorArray[$i] * $nPercent / $ActBrightness, 0) Next Return 0 & "x" & Hex($aColorArray[1], 2) & Hex($aColorArray[2], 2) & Hex($aColorArray[3], 2) EndFunc ;==>_Color_SetBrightness Func _Color_GetBrightness($iColor) Local $aColorArray[4] $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) Return Round(($aColorArray[$IndexMax] / 255) * 100, 0) EndFunc ;==>_Color_GetBrightness Func _Color_SetHue($iColor, $iHue) Local $aColorArray[4] $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $iMax = _ArrayMax($aColorArray, 1, 1) $iMin = _ArrayMin($aColorArray, 1, 1) If $iHue >= 61 And $iHue <= 180 Then $IndexMax = 2 If $iHue < 120 Then $IndexMin = 3 $iMid = (($iMax - $iMin) * (120 - $iHue)) / 60 + $iMin Else $IndexMin = 1 $iMid = (($iMax - $iMin) * ($iHue - 120)) / 60 + $iMin EndIf ElseIf $iHue >= 181 And $iHue <= 299 Then $IndexMax = 3 If $iHue <= 240 Then $IndexMin = 1 $iMid = (($iMax - $iMin) * (240 - $iHue)) / 60 + $iMin Else $IndexMin = 2 $iMid = (($iMax - $iMin) * ($iHue - 240)) / 60 + $iMin EndIf ElseIf $iHue >= 300 Or $iHue <= 60 Then $IndexMax = 1 If $iHue <= 60 Then $IndexMin = 3 $iMid = (($iMax - $iMin) * ($iHue)) / 60 + $iMin Else $IndexMin = 2 $iMid = (($iMax - $iMin) * (360 - $iHue)) / 60 + $iMin EndIf EndIf $IndexMid = 6 - ($IndexMin + $IndexMax) $aColorArray[$IndexMin] = $iMin $aColorArray[$IndexMax] = $iMax $aColorArray[$IndexMid] = $iMid Return 0 & "x" & Hex($aColorArray[1], 2) & Hex($aColorArray[2], 2) & Hex($aColorArray[3], 2) EndFunc ;==>_Color_SetHue Func _Color_GetHue($iColor) Local $aColorArray[4], $Hue $aColorArray[1] = _ColorGetRed($iColor) $aColorArray[2] = _ColorGetGreen($iColor) $aColorArray[3] = _ColorGetBlue($iColor) $IndexMax = _ArrayMaxIndex($aColorArray, 1, 1) $IndexMin = _ArrayMinIndex($aColorArray, 1, 1) $IndexMid = 6 - ($IndexMax + $IndexMin) $Lambda = ($aColorArray[$IndexMid] - $aColorArray[$IndexMin]) * 60 / ($aColorArray[$IndexMax] - $aColorArray[$IndexMin]) Switch $IndexMax Case 1 Switch $IndexMin Case 2 $Hue = 360 - $Lambda Case 3 $Hue = $Lambda EndSwitch Case 2 Switch $IndexMin Case 1 $Hue = 120 + $Lambda Case 3 $Hue = 120 - $Lambda EndSwitch Case 3 Switch $IndexMin Case 1 $Hue = 240 - $Lambda Case 2 $Hue = 240 + $Lambda EndSwitch EndSwitch Return Round($Hue, 0) EndFunc ;==>_Color_GetHue Func _Color_FindComplementary($iColor) Local $iHue = Mod(_Color_GetHue($iColor) + 180, 360) Return _Color_SetHue($iColor, $iHue) EndFunc ;==>_Color_FindComplementary However, I dont quite understand the hue changing function in this, or the brightness function. Are there any easier ways to do something like this? Otherwise, can someone please help me make sense of the hue and brightness functions? Thanks. Finally the autoit tags are working so there u go. Sorry bouth that, it was only showing the first few lines and then it swallowed up the edit button and all those buttons and so on.
×
×
  • Create New...