Line appearing after using strokeweight()

So whenever I run this code:

int NUMBEROFCOLOURS = 4;
int SMALL = 15;
int MEDIUM = 30;
int BIG = 45;
int SHAPESIZE = MEDIUM;
color CURRENTCOLOUR = color(0, 0, 0);
color DEFAULTCOLOUR = color(0, 0, 0);
color COLOUR1 = color(255, 0, 0);
color COLOUR2 = color(0, 0, 255);
color COLOUR3 = color(255, 255, 0);
String CURRENTSHAPE = "square";
void setup() {
  fullScreen();
  background(255);
  strokeWeight(5);
  line(width/10, 0, width/10, height);
  fill(0);
  textSize(30);
  text("C", width/10/2, height/16);
  text("l", width/10/2, height/16*2);
  text("e", width/10/2, height/16*3);
  text("a", width/10/2, height/16*4);
  text("r", width/10/2, height/16*5);
  text("s", width/10/2, height/16*7);
  text("c", width/10/2, height/16*8);
  text("r", width/10/2, height/16*9);
  text("e", width/10/2, height/16*10);
  text("e", width/10/2, height/16*11);
  text("n", width/10/2, height/16*12);
  rect(width/10*9, 0, width/10, height/NUMBEROFCOLOURS);
  fill(COLOUR1);
  rect(width/10*9, height/NUMBEROFCOLOURS, width/10, height/NUMBEROFCOLOURS);
  fill(COLOUR2);
  rect(width/10*9, height/NUMBEROFCOLOURS*2, width/10, height/NUMBEROFCOLOURS);
  fill(COLOUR3);
  rect(width/10*9, height/NUMBEROFCOLOURS*3, width/10, height/NUMBEROFCOLOURS);
  fill(255);
  rect(width/10, height/10*9, width/10*2, height/10); // square selector
  rect(width/2, height/10*9, width/10*2, height/10); // circle selector
  rect(width/10*3, height/10*9, width/10*2, height/10);
  rect(width/10*7, height/10*9, width/10*2, height/10);
  fill(0);
  rect(width/10*2-25, height/20*19-25, 50, 50);
  ellipse(width/10*6, height/20*19, 50, 50);
  line(mouseX-25, mouseY-25, mouseX+25, mouseY+25);
  fill(255);
  rect(width/10, 0, width/10*2.66, height/10);
  rect(width/10*3.66, 0, width/10*2.66, height/10);
  rect(width/10*6.32, 0, width/10*2.66, height/10);
  strokeWeight(BIG);
  line(width/10+(width/10*2.66)/2, 30, width/10+(width/10*2.66)/2, 60);
  strokeWeight(MEDIUM);
  line(width/10*3.66+(width/10*2.66)/2, 30, width/10*3.66+(width/10*2.66)/2, 60);
  strokeWeight(SMALL);
  line(width/10*6.32+(width/10*2.66)/2, 30, width/10*6.32+(width/10*2.66)/2, 60);
  strokeWeight(5);
}

void draw() {
  if (mousePressed && mouseX<width/10) {
    reset();
  } else if (mousePressed && mouseX>width/10*9) {
    if (mouseY<height/NUMBEROFCOLOURS) {
      CURRENTCOLOUR = DEFAULTCOLOUR;
    } else if (mouseY<height/NUMBEROFCOLOURS*2) {
      CURRENTCOLOUR = COLOUR1;
    } else if (mouseY<height/NUMBEROFCOLOURS*3) {
      CURRENTCOLOUR = COLOUR2;
    } else if (mouseY<height/NUMBEROFCOLOURS*4) {
      CURRENTCOLOUR = COLOUR3;
    }
  } else if (mousePressed && mouseX>width/10 && mouseX<width-width/10-50 && mouseY<height/10*9-50 && mouseY>height/10) {
    fill(CURRENTCOLOUR);
    if (CURRENTSHAPE == "square") {
      rect(mouseX, mouseY, SHAPESIZE, SHAPESIZE);
    } else if (CURRENTSHAPE == "circle") {
      ellipse(mouseX, mouseY, SHAPESIZE, SHAPESIZE);
    }
  }
  if (squarePressed(width/10, height/10*9, width/10*2, height/10)) {
    CURRENTSHAPE = "square";
  }
  if (circlePressed(width/2, height/10*9, width/10*2, height/10)) {
    CURRENTSHAPE = "circle";
  }
  SHAPESIZE = lineThickness(width/10, 0, width/10*8, height/10, BIG, MEDIUM, SMALL, SHAPESIZE);
}

void reset() {
  CURRENTCOLOUR = color(0, 0, 0);
  background(255);
  strokeWeight(5);
  line(width/10, 0, width/10, height);
  fill(0);
  textSize(30);
  text("C", width/10/2, height/16);
  text("l", width/10/2, height/16*2);
  text("e", width/10/2, height/16*3);
  text("a", width/10/2, height/16*4);
  text("r", width/10/2, height/16*5);
  text("s", width/10/2, height/16*7);
  text("c", width/10/2, height/16*8);
  text("r", width/10/2, height/16*9);
  text("e", width/10/2, height/16*10);
  text("e", width/10/2, height/16*11);
  text("n", width/10/2, height/16*12);
  rect(width/10*9, 0, width/10, height/NUMBEROFCOLOURS);
  fill(COLOUR1);
  rect(width/10*9, height/NUMBEROFCOLOURS, width/10, height/NUMBEROFCOLOURS);
  fill(COLOUR2);
  rect(width/10*9, height/NUMBEROFCOLOURS*2, width/10, height/NUMBEROFCOLOURS);
  fill(COLOUR3);
  rect(width/10*9, height/NUMBEROFCOLOURS*3, width/10, height/NUMBEROFCOLOURS);
  fill(255);
  rect(width/10, height/10*9, width/10*2, height/10); // square selector
  rect(width/2, height/10*9, width/10*2, height/10); // circle selector
  rect(width/10*3, height/10*9, width/10*2, height/10);
  rect(width/10*7, height/10*9, width/10*2, height/10);
  fill(0);
  rect(width/10*2-25, height/20*19-25, 50, 50);
  ellipse(width/10*6, height/20*19, 50, 50);
  line(mouseX-25, mouseY-25, mouseX+25, mouseY+25);
  fill(255);
  rect(width/10, 0, width/10*2.66, height/10);
  rect(width/10*3.66, 0, width/10*2.66, height/10);
  rect(width/10*6.32, 0, width/10*2.66, height/10);
  strokeWeight(BIG);
  line(width/10+(width/10*2.66)/2, 30, width/10+(width/10*2.66)/2, 60);
  strokeWeight(MEDIUM);
  line(width/10*3.66+(width/10*2.66)/2, 30, width/10*3.66+(width/10*2.66)/2, 60);
  strokeWeight(SMALL);
  line(width/10*6.32+(width/10*2.66)/2, 30, width/10*6.32+(width/10*2.66)/2, 60);
  strokeWeight(5);
}

boolean circlePressed(int x, int y, int circleWidth, int circleHeight) {
  if (mousePressed && mouseX > x && mouseY > y && mouseX < x + circleWidth && mouseY < y + circleHeight) {
    return true;
  } else {
    return false;
  }
}

boolean squarePressed(int x, int y, int squareWidth, int squareHeight) {
  if (mousePressed && mouseX > x && mouseY > y && mouseX < x + squareWidth && mouseY < y + squareHeight) {
    return true;
  } else {
    return false;
  }
}

private int lineThickness(int x, int y, int Width, int Height, int BIG, int MEDIUM, int SMALL, int SHAPESIZE) {
  if (mousePressed) {
    if (mouseY<y+Height) {
      if (mouseX>x && mouseX<x+Width) {
        if (mouseX<x+Width/3) {
          return BIG;
        }
        if (mouseX<x+Width/3*2 && mouseX>x+Width/3) {
          return MEDIUM;
        }
        if (mouseX<x+Width && mouseX>x+Width/3*2) {
          return SMALL;
        } else {
    return SHAPESIZE;
  }
      } else {
    return SHAPESIZE;
  }
    } else {
    return SHAPESIZE;
  }
  } else {
    return SHAPESIZE;
  }
}

A line appears where I clicked the clear screen button. Does anyone know why this is?

Specs:

Sony Xperia M2
Using APDE to write and build code.

Thanks.

Hey,

Line 122 : line(mouseX-25, mouseY-25, mouseX+25, mouseY+25);

You want to get rid of that.

Cheers.

2 Likes

Thank you! I forgot to comment that line out after I finished with prototyping a triangle.

1 Like