Random Color on Background

#1

I wanted to have random color blinking on the background. I found two methods:

1.) as first action in a mode draw a rectangle with random color. This may look like this

...
def draw(screen, etc):
   pygame.draw.rect(screen, ((random.randrange(0, 2) * 255),(random.randrange(0, 2) * 255),(random.randrange(0, 2) * 255)), ((0,0),(1280,720)), 0)
...

2.) Or change in /root/ETC_Mother/etc_system.py the definition of color_picker_bg, which is at the end of the file:

def color_picker_bg( self ):
    c = float(self.knob5)
    if c < .99 :
        r = (1 - (math.cos(c * 3 * math.pi) * .5 + .5)) * c
        g = (1 - (math.cos(c * 7 * math.pi) * .5 + .5)) * c
        b = (1 - (math.cos(c * 11 * math.pi) * .5 + .5)) * c
        color = (r * 255,g * 255,b * 255)

    if c > .98 :
        r = random.randrange(0, 2) * 255
        g = random.randrange(0, 2) * 255
        b = random.randrange(0, 2) * 255
        color = (r,g,b) 
    self.bg_color = color
    return color

This way the bg-color knob will switch to random if turned fully clockwise.

1 Like
#2

awesome. thanks!

#3

I am still looking for the possibility to have the background slowly fading through the colours. I would know how to achieve this with printing the background rectangle within the mode. But I would like to have it as a possible selection on the knob5. Any idea?