I would like to distribute rectangles with a custom anchor point around a circle, they should change the angle based on the location on the circle.
I have bit of code that draws one rectangle, but i am unclear where to put the loop, or if i am going the wrong way about this.
glPushMatrix();
glTranslatef(1280 / 2, 720 / 2, 0); // Put in the middle of the canvas
glPushMatrix();
ofSetColor(255,255,255);
ofFill();
ofCircle(0,0,250);
glPushMatrix();
glRotatef(45, 0, 0, 1); //Rotation around anchor point
ofSetColor(0,255,0);
ofFill();
glTranslatef(-50, -25, 0); //Translate to center of Rectangle
ofRect(0, 0, 100, 50);
glPopMatrix();
glPopMatrix();
glPopMatrix();
OK made some progress, i am now able to set the number of objects around the circle, added also ofxUI so i can see it visually. Now the last step i have to take is where to add the rotation about the rectangle anchor point.
Current Code:
glPushMatrix();
glTranslatef(ofGetWidth() / 2, ofGetHeight() / 2, 0); // Put in the middle of the canvas
ofSetColor(255,255,255);
ofFill();
ofCircle(0, 0, cloningRad);
for (int i = 0; i < numClones; i++) {
glPushMatrix();
glRotatef((360.0f/numClones)*i, 0, 0, 1); //Rotation
ofSetColor(250, 0, 0);
ofFill();
ofCircle(cloningRad, 0, 20);
glTranslatef(-50, -50, 0); //Translate to center of Rectangle
ofSetColor(0, 255, 0);
ofNoFill();
ofRect(cloningRad, 0, 100, 100);
glPopMatrix();
}
glPopMatrix();