I'm start learning pygame i buy a book, in this book i have this script:
import pygame
pygame.init()
screen = pygame.display.set_mode((640,480))
all_colors = pygame.Surface((4096,4096),depth=24)
for r in xrange(256):
x = (r & 15) * 256
y = (r >> 4) * 256
print x, " " , y
for g in xrange(256):
for b in xrange(256):
all_colors.set_at((x+g,y+b),(r,g,b))
screen.blit(all_colors,(0,0))
pygame.image.save(all_colors,"allcolors.bmp")
In this script we produce an image that contains all colors that our computer can produce,the only instructions i don't understand are:
x = (r & 15) * 256
y = (r >> 4) * 256
Someone coud explane me why he make this 2 operation. I know that are bitwise operator but i don't understand why he do that thanks :D .