[TriPython] making a color wheel

Joseph Mack NA3T jmack at austintek.com
Mon Mar 21 13:39:32 EDT 2016


For a classrom demonstration, I would like to repeat Maxwell's spinning color 
wheel demonstration of combining r,g,b to appear white. I could go out and get 
a motor and colored paper, but then I thought I should be able to paint a color 
wheel on a screen and do the same thing. At the frame rate of modern displays 
this should work. My first attempt (below), filling a box with r,g and then b, 
doesn't produce white. Instead I get lots of flashing r,g and b rectangles.

I assume the code is not update()'ing the screen synchronously with every 
frame. Whether it's faster or slower I have no idea. I don't know if screens 
are being buffered and then not written when the next colored rectangle is 
presented.

Any suggestions?

Thanks Joe

----

#!/usr/bin/python

# from drawCircleArcExample.py     P. Conrad for CS5nm, 10/31/2008
#  How to draw an arc in Pygame that is part of a circle
# http://www.cs.ucsb.edu/~pconrad/cs5nm/08F/ex/ex09/drawCircleArcExample.py

import pygame
from pygame.locals import *
from sys import exit

pygame.init()
screen = pygame.display.set_mode((160,120))

white = (255,255,255);
red = (255,0,0);
green = (0,255,0);
blue = (0,0,255);

while True:

     for event in pygame.event.get():
         if event.type == QUIT:
             pygame.quit(); sys.exit();

     screen.fill(red);
     pygame.display.update()
     screen.fill(green);
     pygame.display.update()
     screen.fill(blue);
     pygame.display.update()

#-----

-- 
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) austintek (dot) com - azimuthal equidistant
map generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!


More information about the TriZPUG mailing list