1

I have a simple processing sketch (you can post the code and observe the behavior here)

int value = 0;

void setup() {
  size(480, 120);

}

void draw() {
  fill(value);
  background(#ffffff);
}

void mouseDragged() 
{
ellipse(mouseX,mouseY,20,20);
}

The only thing this does is have a circle follow the cursor on being dragged. In order to not have the circle leave a trace, I assign the bacground in the Draw procedure so that the background resets. I also played with the frame rate taking it from the default 60 up to 2000 without success. How do I get this right?

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
yayu
  • 7,758
  • 17
  • 54
  • 86

1 Answers1

2

You can use multiple integers or instead one PVector to store the position data:

PVector position;
// int x, y;

void setup(){
  size(200,200);
  background(125);

  position = new PVector();
  // x=0;
  // y=0;
}

void draw(){
  background(125);

  noStroke(); fill(50);
  ellipse(position.x,position.y,20,20);  
}

void mouseDragged(){
  position.x = mouseX;
  position.y = mouseY;
  // x = mouseX;
  // y = mouseY;
}
Darius
  • 10,762
  • 2
  • 29
  • 50