# Changing strokeWeight when mousePressed

**URL:** <https://discourse.processing.org/t/changing-strokeweight-when-mousepressed/22869>\
**Category:** Coding Questions\
**Created:** [July 27, 2020, 10:24pm UTC](https://discourse.processing.org/t/changing-strokeweight-when-mousepressed/22869 "2020-07-27T22:24:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karate29](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@karate29](https://discourse.processing.org/u/karate29)\
**Post date:** [July 27, 2020, 10:24pm UTC](https://discourse.processing.org/t/changing-strokeweight-when-mousepressed/22869/1 "2020-07-27T22:24:18Z")

</div>

I am brand new to Processing and was trying to create a free hand drawing program. I already made the colors and when you press them it changes the color and you can draw with the selected color. The problem I am coming across is I want the user to be able to change the strokeWeight. I used the same process I did while changing the color but there is no difference.

Here is my code:

int strokeWeight = (1);  
color drawcolor = color(0, 0, 0);  
void setup() {  
size(1000, 500);  
background(255,255,255);  
}

void draw() {  
stroke(0,0,0);  
// thickness  
textSize(20);  
text(“Choose Thickness”, 10, 435);  
fill(0,0,0);  
circle(20,450,5);  
fill(0,0,0);  
circle(40,452,10);  
fill(0,0,0);  
circle(70,456,20);  
fill(0,0,0);  
circle(110,460,30);  
fill(0,0,0);  
circle(160,465,40);  
fill(0,0,0);  
circle(220,469,50);  
//draw  
fill(255,0,0);  
circle(50,50,50);  
fill(255,128,0);  
circle(150,50,50);  
fill(255,255,0);  
circle(250,50,50);  
fill(0,255,0);  
circle(350,50,50);  
fill(0,64,128);  
circle(450,50,50);  
fill(128,0,255);  
circle(550,50,50);  
fill(255,23,139);  
circle(650,50,50);  
fill(0,0,0);  
circle(750,50,50);  
fill(128,64,0);  
circle(850,50,50);  
fill(255,255,255);  
circle(950,50,50);  
fill(drawcolor);  
stroke(drawcolor);  
if (mousePressed == true && mouseY \> 100)  
circle(mouseX, mouseY, strokeWeight);  
}

void mouseClicked() {

// commands for draw  
if (mouseX \>= 50 && mouseX \<= 100 && mouseY \>= 50 && mouseY \<= 100)  
drawcolor = color(255,0,0);  
if (mouseX \>= 150 && mouseX \<= 200 && mouseY \>= 50 && mouseY \<= 200)  
drawcolor = color(255,128,0);  
if (mouseX \>= 250 && mouseX \<= 300 && mouseY \>= 50 && mouseY \<= 300)  
drawcolor = color(255,255,0);  
if (mouseX \>= 350 && mouseX \<= 400 && mouseY \>= 50 && mouseY \<= 400)  
drawcolor = color(0,255,0);  
if (mouseX \>= 450 && mouseX \<= 500 && mouseY \>= 50 && mouseY \<= 500)  
drawcolor = color(0,64,128);  
if (mouseX \>= 550 && mouseX \<= 600 && mouseY \>= 50 && mouseY \<= 600)  
drawcolor = color(128,0,255);  
if (mouseX \>= 650 && mouseX \<= 700 && mouseY \>= 50 && mouseY \<= 700)  
drawcolor = color(255,23,139);  
if (mouseX \>= 750 && mouseX \<= 800 && mouseY \>= 50 && mouseY \<= 800)  
drawcolor = color(0,0,0);  
if (mouseX \>= 850 && mouseX \<= 900 && mouseY \>= 50 && mouseY \<= 900)  
drawcolor = color(128,64,0);  
if (mouseX \>= 950 && mouseX \<= 1000 && mouseY \>= 50 && mouseY \<= 1000)  
drawcolor = color(255,255,255);  
//commands for thickness  
if (mouseX \>=20 && mouseX \<= 25 && mouseY \>= 450 && mouseY \<=25)  
strokeWeight(5);  
if (mouseX \>=40 && mouseX \<= 50 && mouseY \>= 452 && mouseY \<=50)  
strokeWeight(10);  
if (mouseX \>=70 && mouseX \<= 90 && mouseY \>= 456 && mouseY \<=90)  
strokeWeight(20);  
if (mouseX \>=110 && mouseX \<= 140 && mouseY \>= 460 && mouseY \<=140)  
strokeWeight(30);  
if (mouseX \>=160 && mouseX \<= 200 && mouseY \>= 465 && mouseY \<=200)  
strokeWeight(40);  
if (mouseX \>=220 && mouseX \<= 270 && mouseY \>= 469 && mouseY \<=270)  
strokeWeight(50);  
}

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [July 28, 2020, 11:03am UTC](https://discourse.processing.org/t/changing-strokeweight-when-mousepressed/22869/2 "2020-07-28T11:03:12Z")

</div>

This thread is a duplicate
