Question about my line code

function setup() {
  createCanvas(400, 400);
}

function draw() { 

  background(220,220,0);
  
  fill(255,100,0);
  rect(166,57,68,15);//hat
  noFill();
  rect(176,72,48,45);//head
  circle(186,82,10);//eyes
  circle(186,82,5);
  circle(186,82,1);
  circle(214,82,10);
  rect(186,100,28,8);//mouth
  rect(140,117,120,130);//body
  
  strokeWeight(6);
  line(140,128,100,210)
  
}

I am trying to get arms to my robo with the line thickness of 6. I know the order of the code matters here but I have put the strokeWeight in second last line so it will only effect Weight of the line but it is making my whole drawing strokes bigger. Help me I only want to increase the thickness of the line. Also, see image for clarification.

1 Like

Hi,

In draw() function, the rendering is looping, so when a computer runs your code, it will remember strokeWeight(6) and bring it to previous lines. The way to solve it is adding strokeWeight(1) in line 9, so the computer now will know that all your code from line 10 to line 19 should be applied to strokeWeight(1).

Please feel free to ask if you have any other quetion!

1 Like

Thanks it resolved my problem .Also, I never knew I will get feedback that fast I just started p5.js. Iā€™m have fun. Thank you.

2 Likes