ludocus Posted May 27, 2009 Posted May 27, 2009 (edited) I want to convert a 0xFFFFFF color into some number wich I can make higher or lower and then convert back and then let the color be lighter or darker is there a way to do this?? Please help, thnx in advance Edited May 28, 2009 by ludocus
James Posted May 27, 2009 Posted May 27, 2009 I want to convert a 0xFFFFFF color into some number wich I can make higher or lower and then convert back and then let the color be lighter or darkeris there a way to do this??Please help, thnx in advanceConvert it to RGB and work that way? There are examples around the forum. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
ludocus Posted May 27, 2009 Author Posted May 27, 2009 I searched the forum but what keyword do I search??
martin Posted May 27, 2009 Posted May 27, 2009 (edited) I want to convert a 0xFFFFFF color into some number wich I can make higher or lower and then convert back and then let the color be lighter or darker is there a way to do this?? Please help, thnx in advance Split the colour into rde, green and blue components, reduce oir increase the value of each with a limit of 0 min, 255 max, then add them back together again. There are posts around I think about this, but it would be something like ALterBrightness($colour,$amount) Func AlterBrightness($c,$a) local $red = BitAnd($c,0xff0000)/0x10000 Local $grn = BitANd($c,0x00ff00)/0x100 Local $blu = BitAnd($c,0x0000FF) $red = $red + $a if $red > 255 Then $red = 255 if $red < 0 Then $red = 0 ;same for others return $red * 0x10000 + $grn * 0x100 + $blu EndFunc But not tested - it's just to show the idea. Edited May 27, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
ludocus Posted May 27, 2009 Author Posted May 27, 2009 (edited) but.... it doesn't work for me Edited May 27, 2009 by ludocus
martin Posted May 27, 2009 Posted May 27, 2009 but....it doesn't work for me Well in that case I actually try using it myself and then I'll get back. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
martin Posted May 27, 2009 Posted May 27, 2009 (edited) Well in that case I actually try using it myself and then I'll get back.I tried it and it works ok. Try this expandcollapse popupGUICreate("Brightness change") GUISetBkColor(0x345678) GUISetState() For $n = 0 To 100 Sleep(20) $new = _ALterBrightness(0x345678, -$n) GUISetBkColor($new) Next For $n = -100 To 200 Sleep(20) $new = _ALterBrightness(0x345678, $n) GUISetBkColor($new) Next While GUIGetMsg() <> -3 WEnd ;======AlterBrightness================== ;Returns the colour made by changing the brightness of $c ;according to the value of $adjust which is the amount to adjust the red green and blue components, ;and the value of $group. ;If $group = 7 (default) adjust red, green and blue by $adjust. ; = 1 red only ; = 2 green only ; = 4 blue only Func _AlterBrightness($StartCol, $adjust, $Select=7) Local $red = $adjust*(BitAnd(1,$Select) <> 0) + BitAND($StartCol, 0xff0000) / 0x10000 Local $grn = $adjust*(BitAnd(2,$Select) <> 0) + BitAND($StartCol, 0x00ff00) / 0x100 Local $blu = $adjust*(BitAnd(4,$Select) <> 0) + BitAND($StartCol, 0x0000FF) Return LimitCol($red) * 0x10000 + LimitCol($grn) * 0x100 + LimitCol($blu) EndFunc ;==>AlterBrightness : _LimitCol ;returns the value of $cc limited to a value from 0 to 255 Func limitCol($cc) If $cc > 255 Then Return 255 If $cc < 0 Then Return 0 Return $cc EndFunc ;==>limitCol Edit:improved it to allow indivual colour components to be adjusted Edited May 27, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
ludocus Posted May 28, 2009 Author Posted May 28, 2009 (edited) wow man, thnx alot Edited May 28, 2009 by ludocus
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