transforms per frame outside of Processing (manual), any better way?
in
Programming Questions
•
2 years ago
I always wondered how Processing handles transformations so that a translate, for example, doesn't get repeated each time the function is called (each frame). Every time I try to set up my own translation I have to use
translate(mouseX-pmouseX, mouseY-pmouseY) to get the same effect of Processing's
translate(mouseX, mouseY). The only other way I've been able to do it is the following:
- void move(float x, float y) {
- if(x != tx || y != ty) {
- AffineTransform ng = AffineTransform.
- getTranslateInstance((double)-tx,(double)-ty);
- transform(ng);
- AffineTransform mv = AffineTransform.
- getTranslateInstance((double)x, (double)y);
- transform(mv);
- tx = x;
- ty = y;
- }
- }
1