Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bitwise NOT, is this getting "opposite" colors???
#5
In this case, your color values are simply 255 - value at the end of the day.

Code: (Select All)
Dim NotI As _Unsigned _Byte
_Define C As _UNSIGNED LONG

For i = 0 To 255
    c = _RGB32(i, i, i)
    NotI = Not i
    c1 = _RGB32(NotI, NotI, NotI)
    c2 = _RGB32(255 - i, 255 - i, 255 - i)
    Print i, NotI, c, c1, c2
    Sleep
Next


Whatever r, g, b is for you, you're using NOT to change the 0 to 255 value of it...

NOT 0 becomes -1.
NOT 1 becomes -2.
NOT 2 becomes -3.
...and so on...

Which you then store in an _UNSIGNED BYTE:
-1 as an unsigned byte is 255.
-2 as an unsigned byte is 254.
-3 as an unsigned byte is 253.
...and so on...

Nothing at all wrong with what you're doing, but I think it'd be a little easier to read and understand if you just kept it simple with:

Code: (Select All)
screen _newimage(600,400,32)

dim as _unsigned _byte r, g, b

again:
r = int(rnd*256)
g = int(rnd*256)
b = int(rnd*256)

line (0, 0) - (200, 200), _rgb32(r,g,b), BF
line (300, 0) - (500, 200), _rgb32(255 - r,255 - g, 255 -b), BF

_delay 0.5
goto again
Reply


Messages In This Thread
RE: Bitwise NOT, is this getting "opposite" colors??? - by SMcNeill - 11-19-2022, 05:24 AM



Users browsing this thread: 1 Guest(s)