# Colors! (a lot of colors but not all of them)

**URL:** <https://discourse.processing.org/t/colors-a-lot-of-colors-but-not-all-of-them/7022>\
**Category:** Processing.py\
**Created:** [December 30, 2018, 4:16pm UTC](https://discourse.processing.org/t/colors-a-lot-of-colors-but-not-all-of-them/7022 "2018-12-30T16:16:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)\
**Post date:** [December 30, 2018, 4:16pm UTC](https://discourse.processing.org/t/colors-a-lot-of-colors-but-not-all-of-them/7022/1 "2018-12-30T16:16:32Z")

</div>

```auto
import random

class Walker:
    def __init__ (self):
        self.x = width >> 1
        self.y = height >> 1
        self.foot = 10 #space between every step
        self.strw = 3#stroke weight
    def move(self):
        a = random.randint(0,4)
        if a == 0:
            #self.x = constrain(self.x - self.foot,2,width - 2)
            self.x = self.x - self.foot
        elif a == 1:
            #self.x = constrain(self.x +self.foot,2,width - 2)
            self.x = self.x + self.foot
        elif a == 2:
            #self.y = constrain(self.y - self.foot,2,height - 2)
            self.y = self.y - self.foot
        elif a == 3:
            #self.y = constrain(self.y + self.foot,2,height - 2)
            self.y = self.y + self.foot
        if(self.x > width- self.strw):
            self.x = self.strw
        if(self.x < self.strw):
            self.x = width - self.strw
        if(self.y > height- self.strw):
            self.y = self.strw
        if(self.y < self.strw):
            self.y = height - self.strw
    def show(self,colorr):
        self.strw = 4
        stroke(colorr)
        strokeWeight(self.strw)
        point (self.x,self.y)
    
width = 500
height = 500
walker = Walker()

def setup():
    global i
    i = 0
    size(width,height)
    background(0)
    frameRate(120)
    
def draw():
    if i < 1<<24:
        r = ((i>>16) & 0xff) #* 0x11
        g = ((i>>8) & 0xff) #* 0x11
        b = (i & 0xff) #* 0x11
        colour = color(r,g,b)
        walker.show(colour)
        walker.move()
        global i
        i = i + 20

```

To have a shorter range of colors:

```auto
 if i < 1<<12:
        r = ((i>>8) & 0xff) * 0x11
        g = ((i>>4) & 0xff) * 0x11
        b = (i & 0xff) * 0x11

```

or add to i a bigger number  
RGB colors scale (but only blue) :

> <https://stackoverflow.com/questions/23568391/all-rgb-colors-combinations-in-javascript>

  
The “Walker” example where i took ‘inspiration’:  
[https://natureofcode.com/book/introduction/](https://natureofcode.com/book/introduction/)

What can I add?  
Theres a way to run this code as screensaver? 😃  
 ![saver](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/3b7fc295303d83ebfc7ca79157cfb636b395c1e4.jpeg)

---

<div class="post-metadata">

**Author:** ![dector](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dector/32/2944_2.png) [@dector](https://discourse.processing.org/u/dector)\
**Post date:** [December 30, 2018, 9:35pm UTC](https://discourse.processing.org/t/colors-a-lot-of-colors-but-not-all-of-them/7022/2 "2018-12-30T21:35:44Z")

</div>

Checkout [color()](https://py.processing.org/reference/color.html) and [lerpCollor()](https://py.processing.org/reference/lerpColor.html) fucntions.

Or read about [HSV](https://en.wikipedia.org/wiki/HSL_and_HSV#Basic_principle) color model if you want to dive deeper.
