void drawGear(float radius, Vec2d center,int teeth,float toothSize){
Vec2d cp; //circle points as vector
int points = 400;
int nTeeth = (points/teeth)/2; // gets number of teeth
glBegin(GL_LINE_LOOP);
for (int i = 0; i<points; i++){//number of points (x) x/number gives number of arcs how many points are in one arc of 360
int x =i; // watch the is
float angle = ((2*PI)/points)*i; //2*pi is 360 divided into degree segments based on points multiplied by what point your on
//printf( "%d \n", (x/10)%4 );
int y = (x/nTeeth)%2; //x/1 gives number of pixels you get a whole number from in regards to the number of pixels x/x =1 every point gets a integer remander
y = y*toothSize; // increase amplitude from one
cp.x= cos(angle) * (radius + y); //gets the length of x in unit circle and muiltiplies by radius the size out
cp.y= sin(angle) * (radius + y); //gets the length of y and muiltiplies by radius
cp = cp+center; //sets the offset center point
glColor3f( (mouseX/windowW),(mouseY/windowH),0.0f);
glVertex2f(cp.x,cp.y);
}
glEnd( );
}
void drawShapes(int points){
printf( " state is %d \n" ,Bstate);
if ( prevBstate != 0 && Bstate == 0){// pressed tags one hit
pressed++;
prevBstate = Bstate;
}else if (Bstate == 1){
prevBstate = 1;
}// end one hit
if (pressed == 1){
p1.x = mouseDX;
p1.y = mouseDY;
}
if (pressed == 2){
p2.x = mouseDX;
p2.y = mouseDY;
pressed = 0;
}
printf( " pressed is %d \n" ,pressed);
for (float p = 0; p < 1.0 ; p=(p+(1.0/points))){
p3 = (p1*(1.0 - p))+(p2*p); //1/points gets percentaage number of points p1 is offset + length
drawGear((p*100), p3,(p*10),(p*10));
}
}