I'm implementing a simple drawing program using Java/Processing.
            
There are simple geometric elements like triangles, rectangles etc. which I want to rotate according to mouse movement. Each element registers itself within the constructor using pApplet.registerElement(this).
            
Everything fine so far, but I struggle to rotate each element.
At the moment the element gets drawn temporarily (as long as the mouse is dragged):
            
            
            
After releasing the mouse button the unrotated element is still in its old place.
            
The display method looks something like that:
            
            
There was a similar problem with the built-in scale() function, although the according code snippet worked fine within Processing IDE. I circumvented this problem by recalculating the side length of the rect, which then got redrawn automatically.
            
I guess I have to implement the rotation manually too, but how does this work?
            
Any help would be greatly appreciated!
 
           
 
            
           There are simple geometric elements like triangles, rectangles etc. which I want to rotate according to mouse movement. Each element registers itself within the constructor using pApplet.registerElement(this).
Everything fine so far, but I struggle to rotate each element.
At the moment the element gets drawn temporarily (as long as the mouse is dragged):
After releasing the mouse button the unrotated element is still in its old place.
The display method looks something like that:
- displayRotation(float theta)
 - {
 pApplet_.pushMatrix();
pApplet_.translate(pApplet_.width/2,pApplet_.height/2);
pApplet_.rotate(theta);
displayDefault();
pApplet_.translate(-pApplet_.width/2, -pApplet_.height/2);
pApplet_.popMatrix();- }
 
There was a similar problem with the built-in scale() function, although the according code snippet worked fine within Processing IDE. I circumvented this problem by recalculating the side length of the rect, which then got redrawn automatically.
I guess I have to implement the rotation manually too, but how does this work?
Any help would be greatly appreciated!
 
              
              1  
            
 
            