Stop blinking

mmamma
edited November 2016 in Questions about Code

Hi I'm new to processing and I was trying different codes but it seems that everytime I use the mouseMoved and mouseDragged my screen starts flashing or blinking instead of just showing me what I want according to the code. It would be really helpful please, thank you.

boolean drawA = false;

boolean drawB = false;

boolean drawC = false;

void setup() {

size(600, 600);

noStroke();

background(255);

}

void mouseMoved(){

background(126);

float x = mouseX;

float y = mouseY;

float ix = width - mouseX; // Inverse X

float iy = height - mouseY; // Inverse Y

fill(255);

triangle(x, height/2, y, y,ix,iy);

fill(0);

ellipse(ix, height/2, iy, iy);

}

void keyPressed() {

if ((key == 'A') || (key == 'a')) {

drawA = true;

} else if ((key == 'B') || (key == 'b')){

drawB = true;

}else if ((key == 'C') || (key == 'c')){

drawC = true;

}

}

void keyReleased() {

drawA = false;

drawB = false;

drawC = false;

}

void mouseDragged(){

background(255);

fill(0);

ellipse(mouseX,mouseY,70,70);

}

void draw() {

background(255);

fill(0);

if (drawA == true) {

ellipse(100,300,25,25);

} else if(drawB == true) {

quad(290,0,290,600,310,600,310,0);

} else if (drawC == true){

triangle(500,200,400,400,600,400);

}

}

Answers

  • edit post, highlight code, press ctrl-o to fix formatting.

    it's the background calls. remove them all apart from the one in draw().

    if you need to change them based on mouseDragged / mouseMoved, set a flag and check it in draw()

  • Thank you so much, it's just that I'm really new to this. Could you help me by showing me how the code it's supposed to be please? I'm sorry

  • @mma as koogs requested, please edit your post above, highlight the code, and press ctrl-o to fix formatting.

  • Once that is done, it is much easier to read and understand your code.

Sign In or Register to comment.