# Not work mousePressed left click!

**URL:** <https://discourse.processing.org/t/not-work-mousepressed-left-click/23413>\
**Category:** Processing.py\
**Created:** [August 21, 2020, 2:56pm UTC](https://discourse.processing.org/t/not-work-mousepressed-left-click/23413 "2020-08-21T14:56:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayarch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mayarch/32/10647_2.png) [@Mayarch](https://discourse.processing.org/u/Mayarch)\
**Post date:** [August 21, 2020, 2:56pm UTC](https://discourse.processing.org/t/not-work-mousepressed-left-click/23413/1 "2020-08-21T14:56:48Z")

</div>

tileCountX=2

tileCountY=10

colorsLeft=[]

colorsRight=[]

interpolateShortest=True

def setup():

```
size(800,800)

colorMode(HSB)

noStroke()

shakeColors()

```

def draw():

```
tileCountX=int(map(mouseX,0,width,2,100))

tileCountY=int(map(mouseY,0,height,2,10))

tileWidth=width/tileCountX

tileHeight=height/tileCountY

for gridY in range(tileCountY):

    col1=colorsLeft[gridY]

    col2=colorsRight[gridY]

    for gridX in range(tileCountX):

        amount=map(gridX,0,tileCountX-1,0,1)

        if interpolateShortest:

            colorMode(RGB)

            interCol=lerpColor(col1,col2,amount)

            colorMode(HSB)

        else:

            interCol=lerpColor(col1,col2,amount)

        fill(interCol)

        posX=tileWidth*gridX

        posY=tileHeight*gridY

        rect(posX,posY,tileWidth,tileHeight)

```

def shakeColors():

```
for i in range(tileCountY):

    colorsLeft.append(color(random(0, 60), random(0, 100), 100)) 

    colorsRight.append(color(random(160, 190), 100, random(0, 100)))

```

def keyPressed():

```
global interpolateShortest

if key=="1": 

    interpolateShortest=True

elif key=="2": 

    interpolateShortest=False

```

def mousePressed():

```
shakeColors() #didnt work i couldn t reuse shakeColor function when i pressed mouse left click.
```

---

<div class="post-metadata">

**Author:** ![Mayarch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mayarch/32/10647_2.png) [@Mayarch](https://discourse.processing.org/u/Mayarch)\
**Post date:** [August 21, 2020, 8:31pm UTC](https://discourse.processing.org/t/not-work-mousepressed-left-click/23413/2 "2020-08-21T20:31:05Z")

</div>

i changed the name shakeColors as makeColors and then i redefined colorsLeft,colorsRight lists indexes again with shakeColors function.then solved
