How do I keep the "mousepressed" within the parameters of an image
in
Programming Questions
•
4 months ago
I'm quite new to processing. I'm trying to create an interactive dial and the focus of my functionality lies within the pointer. Currently the pointer operates with the mouse placed at any given location on the canvas moving the mouse left to right. The behavior of the pointer is to rotate within the dial itself, that much I have established.
Question: How to I contain the "mousepressed" function within the image of the pointer (img2 - pink pointer) ?
Image img, img2;
float dial = 0.0;
void setup(){
size(1024,768);
img = loadImage("img/sampleforpro2.png");
img2 = loadImage("img/pointer.png");
imageMode(CENTER);
}
void draw(){
background(0);
translate(width/2, height/2);
image(img, 0, 0);
if(mousePressed){
dial += radians( mouseX - pmouseX );
}
rotate(dial);
image(img2, 0, -88);
}
Thanks in advance.
1