Get intersection of cursor with a component on sketch.
in
Contributed Library Questions
•
2 years ago
I have various applets onto the base PApplet.Now I want to know the intersection point of cursor with the child applets.
Now to check if the cursor is within a perticular applet, I took the cursor points as :
Now if cursor is within app then I wish to draw a flower at that point.But if I draw flower at the same point as
X = tcur.getScreenX(parentPApplet.width );
Y =tcur.getScreenY(parentPApplet.height);
then it does not draw within child app.Then what should I do to solve this prob??
Now to check if the cursor is within a perticular applet, I took the cursor points as :
- withinApp= checkBounds(tcur.getScreenX(parentPApplet.width ),tcur.getScreenY(parentPApplet.height));
- boolean checkBounds(float X,float Y)
- {
- float leftX = this.getPositionX(); //upper left X of applet
- float leftY = this.getPositionY(); //upper left Y of applet
- if( X>leftX && Y >leftY && ( X < leftX+ this.getWidth() )&& (Y < leftY +this.getHeight()) )
- return(true);
- else
- return false;
- }
Now if cursor is within app then I wish to draw a flower at that point.But if I draw flower at the same point as
X = tcur.getScreenX(parentPApplet.width );
Y =tcur.getScreenY(parentPApplet.height);
then it does not draw within child app.Then what should I do to solve this prob??
1