I want to click and drag a corner of a rectangle, and have the rectangle spin around its center.
This is pretty easy to do with a square:
rot = PI * 3 / 4 + atan2( (centerY - mouseY), (centerX - mouseX) );
But if I want to rotate a rectangle, I am not sure how to handle the offset to make the rotation smooth as the mouse is moved.
In this jsfiddle example, http://jsfiddle.net/R4QpV/, clicking on the red corner lets you rotate around the center of the square. But what if you click on the green corner, there is a jump. How to make dragging the green corner smooth and follow the mouse as it does when clicking the square's corner?
I am guessing I need to first draw the shape with noStroke and then go back and stroke in the sides I want drawn:beginShape( );vertex( 10, 10 );vertex( 90, 10 );vertex( 90, 90 );vertex( 10, 90 );vertex( 10, 10 );endShape( );
But maybe there is some cool way to do it with the shape & vertex calls?noStroke( );beginShape( );vertex( 10, 10 );vertex( 90, 10 );vertex( 90, 90 );vertex( 10, 90 );vertex( 10, 10 );endShape( );stroke( 0 );line( 10, 10, 90, 10 );line( 10, 90, 90, 90 );
void setup( ){noLoop( );}
void draw( ){println( "redraw" );redraw( );}
public class okee
{
public static void yarp( )
{ System.err.println("yarp");
}
}
That part was easy.
But to get it to work with processing, I have a two part question:
[1] Where do I put my okee.class relative to my sketch folder?
[2] How do I "import" my class in my sketch so that I can call okee.yarp( ); ?