Shape Revolver Function

A "Shape Revolver" function written in Processing. This function revolves a shape around a center point with a specified number and circle radius.

/**
* Shape Revolver
* @author Gabriel Dunne
* @description Revolves a repeating shape around a vertex
* @param int _x the X position
* @param int _y the Y position
* @param int sides the number of sides
* @param float radius the radius
*/
void shapeRevolver(int _x, int _y, int sides, float radius) {
for ( int i = 0; i < 360; i += (360 / sides) ) {
float x = _x + sin(radians(i)) * radius;
float y = _y + cos(radians(i)) * radius;
pushMatrix();
translate(x, y);
rotate(atan2(y - _y, x - _x));
// draw your shape here
rect(0,0,20,20);
//
popMatrix();
}
}
Related Examples:http://processing.org/learning/basics/triangleflower.html