Click And Drag - Increase/Decrease Value
in
Programming Questions
•
1 year ago
Hello,
I have a circle that pops up when you click the mouse down, and if you were to drag the mouse outward (away from the circle), the circle gets bigger. But I also want it when you drag the mouse closer, the circle then begins to get smaller.
So like a highlighter, but with a circle. This is what I have so far:
- void draw(){
- ellipse(10, 10, draggingX ,draggingY);
- }
- Boolean isDragging = false;
- int draggingReferenceX;
- int draggingReferenceY;
- int draggingX = 10;
- int draggingY = 10;
- void mousePressed(){
- draggingX = 10;
- draggingY = 10;
- isDragging = true;
- draggingReferenceX = mouseX;
- draggingReferenceY = mouseY;
- }
- void mouseDragged(){
- if(isDragging == true){
- //println("dragging");
- if(mouseX > draggingReferenceX && mouseY > draggingReferenceY){
- draggingX ++;
- draggingY ++;
- }
- else{
- draggingX --;
- draggingY --;
- }
- }
- }
Now, this 'kind of' work... The circle will only start shrinking when the mouse has gone negative beyond the centre of the circle. I just want it so that, when you drag your mouse outward, it gets bigger. And smaller when you start moving the drag mouse towards the centre again.
Would appreciate any help. Thanks
1