그래서 검색 할 색상의 총 개수에 따라 RGB 색상 목록을 얻는 방법을 찾고 있었고이 코드 조각을 발견했습니다. 그리고 이해할 수없는 부분이 있습니다. ">>"연산자와 "&"연산자가 비트 연산자이지만 이미 수행 한 작업을 완전히 이해할 수없는 노트를 이미 읽었습니다.RGB 색상 얻기
색상 값 이 할당 된 부분을 이해하는 데 도움을 줄 수 있습니까?
def getDinstinctRGBColorsList(desiredColors)
availableColors = 16000000
inc = availableColors/desiredColors
colorsList = {}
RGB = 0
count = 0
while count <= desiredColors:
RGB = RGB+inc
colorBlue = RGB & 255
colorGreen = (RGB >> 8) & 255
colorRed = (RGB >> 16) & 255
colorsList[count] = str(colorRed) + "," + str(colorGreen) + "," + str(colorBlue)
count += 1
return colorsList
'&'는 비트와 연산자입니다. '>>'는 비트 오른쪽 시프트 연산자입니다. 그것들은 간단한 검색으로 찾을 수있는 [here here] (https://wiki.python.org/moin/BitwiseOperators)입니다. – mhawke