How to rotate the rect
in
Programming Questions
•
1 year ago
Good day
Do not have any idea. How to rotate a rect in the cycle.
- float a;
- float fx,fy;
- void setup() {
- size(640, 550);
- smooth();
- fill(255);
- rectMode(CENTER);
- }
- void draw() {
- background(102);
- translate(320, 275);
- a = atan2(mouseY-height/2, mouseX-width/2);
- rotate(a);
- rectDraw(250,50,0.45,0);
- }
- void rectDraw(int r, int s, float c, float d)
- {
- for(float i=0; i<2*PI; i=i+c)
- {
- fx = r*cos(i);
- fy = r*sin(i);
- //This is not work everything becomes chaotic
- //translate(fx, fy);
- //rotate(i)
- rect(fx,fy,s,s);
- }
- }
1