Ontosy Posted September 23, 2012 Posted September 23, 2012 do have a way to rotate main color (blue, red, yellow, ...) via BitRotate or BitShift? f.e. $a=BitRotate(PixelGetColor(300, 300), -2, "D", $form) GUISetBkColor($a, $form)
trancexx Posted September 23, 2012 Posted September 23, 2012 Color is RGB. That's 24 bits or 3 byes. That means you have one byte too much for BitRotate(). ...Still it's mystery what you want to do. ♡♡♡ . eMyvnE
czardas Posted September 23, 2012 Posted September 23, 2012 Yeah very strange. Convert to a string of two characters (true binary) and rotate that instead. operator64 ArrayWorkshop
Ontosy Posted September 23, 2012 Author Posted September 23, 2012 i would to change color when i click a form. Do it is possible to rotate color with BitRotate(PixelGetColor(300, 300), -2, "D", $form) ? #0000d8, #00d7d8, #00d800, #d7d800, #d80000, #d800d8 BitRotate not have 24 bits option
czardas Posted September 23, 2012 Posted September 23, 2012 (edited) BitRotate not have 24 bits optionNoWhen you rotate 32 bits you will lose information. Perhaps what you need fior this is Actually the code is a little untidy, but it works perfectly well and was designed for this very job. You may be the first person to ever use it (or maybe not). In any case, the answer to your question is within the text description on the page linked to above (that's if I understood your question correctly). Edited September 25, 2012 by czardas operator64 ArrayWorkshop
Malkey Posted September 23, 2012 Posted September 23, 2012 This example rotates the color channels of a 24 bit color. Local $iPixelColor = PixelGetColor(300, 300) ConsoleWrite("0x" & Hex($iPixelColor, 6) & " = " & $iPixelColor & @LF) ; Pixel color at start Local $iColorRotate1 = ColorChannelRotate($iPixelColor) ConsoleWrite("0x" & Hex($iColorRotate1, 6) & " = " & $iColorRotate1 & @LF); Pixel color channels rotated once. Local $iColorRotate2 = ColorChannelRotate($iColorRotate1) ConsoleWrite("0x" & Hex($iColorRotate2, 6) & " = " & $iColorRotate2 & @LF); Pixel color channels rotated twice. Local $iColorRotate3 = ColorChannelRotate($iColorRotate2) ConsoleWrite("0x" & Hex($iColorRotate3, 6) & " = " & $iColorRotate3 & @LF); Pixel color channels rotated third time, back to original color. Func ColorChannelRotate($iColor) Return Number("0x" & StringRegExpReplace(Hex($iColor, 6), "(.{2})(.{2})(.{2})", "312")) EndFunc ;==>ColorChannelRotate
czardas Posted September 23, 2012 Posted September 23, 2012 (edited) After you posted that Malkey, I just had to test my function against your results. I'm happy to say the results are exactly the same. Local $iPixelColor = PixelGetColor(300, 300) For $i = 0 To -24 Step -8 ConsoleWrite(_bitModalSpin($iPixelColor, $i, 24) & @LF) Next Func _bitModalSpin($iVal, $iShift, $iLoopSize) If (Not IsInt($iVal)) Or ($iVal < 0 - 2^31) Or ($iVal > 2^31 -1) Then Return SetError(1, 0, 0) If (Not IsInt($iLoopSize)) Or $iLoopSize > 32 Or $iLoopSize < 0 Then Return SetError(2, 0, 0) If Not IsInt($iShift) Then Return SetError(3, 0, 0) If $iLoopSize < 2 Then Return $iVal $iShift = Mod($iShift, $iLoopSize) If $iShift = 0 Then Return $iVal If $iLoopSize = 32 Then Return BitRotate($iVal, $iShift, "D") ; Spin all 32 bits If $iShift > 0 Then $iShift = $iShift - $iLoopSize Local $dLeft, $dLoop, $dRight, $dMid $dLeft = BitShift( BitShift($iVal, $iLoopSize), -$iLoopSize) $dLoop = BitXOR($dLeft, $iVal) $dRight = BitShift($dLoop, -$iShift) $dMid = BitShift( BitXOR( BitShift($dRight, $iShift), $dLoop), -$iShift -$iLoopSize) Return BitOR($dLeft, $dMid, $dRight) EndFunc Edited September 23, 2012 by czardas operator64 ArrayWorkshop
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