void dragonComp(turtle_t &turt, int x, double side){
	if (x == 1)
		turt.forward(side);
	else{
		dragon(turt, x-1, side);
		turt.turn_right(90);
		dragonComp(turt, x-1, side);
	}
}
void leaffirst(turtle_t &turt, double x)
{
   turt.reset();
   turt.clear();
  turt.set_pos(0.0, -0.8);
  
 turt.turn_left(90);
       leaf(turt, x);
    
}
void star(turtle_t &turt, double x)
{
  int i;
  double factor=x/10;
   turt.reset();
   turt.clear();
  turt.set_pos(0.0, -0.95);
  
   turt.turn_left(90);
   starline(turt,x);
}
//Drawing a Koch Snowflake
void koch(turtle_t &turt, double x)
{
   turt.reset();
   turt.clear();
   turt.set_pos(-0.3, 0.5);
   turt.turn_right(30);

   for (int i = 0; i<3; i++)
     {
       triline(turt, x);
       turt.turn_right(120);
     }
}
void triline(turtle_t &turt, double length)
{
   if (length <= 0.01)
   {
      turt.forward(length);
   }
   else
   {
     double newlength = length/3.0;
     triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);
     turt.turn_right(120);
     triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);
   }
}
void testPattern(turtle_t &turt, double x)
{
	turt.reset();
	turt.clear();
	
	color_t red, green, blue;
	red.r = 1.0; red.g = 0.0; red.b = 0.0;
	green.r = 0.0; green.g = 1.0; green.b = 0.0;
	blue.r = 0.0; blue.g = 0.0; blue.b = 1.0;
	
	turt.set_col(red);
	turt.printAttr();
	turt.forward(0.2);
	turt.turn_right(90);
	turt.backward_move(0.05);
	turt.set_col(green);
	turt.back(0.2);
	turt.set_bgcol(blue.r, blue.g, blue.b);
	
	//~ turt.clear();
}
void render_drawing(turtle_t &turt)
{
	//~ koch(turt, 1.0);
	// testPattern(turt);
	turt.reset();
	turt.clear();
	turt.set_bgcol(0.22, 0.69, 0.87);
	turt.backward_move(0.3);
	turt.turn_right(90);
	turt.forward_move(0.2);
	turt.set_col(0.498039, 1.0, 0.0);
	int num = 20;
	dragon(turt, num, 0.03/num);
  
}
Exemple #8
0
//GLFW display callback
void renderGL(GLFWwindow* window)
{
  //If a filename was given on the command line
  if (file_flag)
    {
      //Execute the parsed commands
      turtle_com_t *com;
      for( liter = list.begin(); liter!=list.end(); liter++)
	{
	  com = *liter;
	  turt.exec(com, window);
	}
    }
  //Or draw the default
  else
    render_drawing(turt);
}
void starline(turtle_t &turt, double length)
{
  double factor;
factor=length/1.5;
 if(length<=0.002)
   return;
 else{
turt.forward(factor);
turt.turn_right(30);
turt.forward(factor);
starline(turt,factor);
turt.backward_move(factor);
turt.turn_left(60);
turt.forward(factor);
starline(turt,factor);
turt.backward_move(factor);
turt.turn_right(30);
turt.backward_move(factor);

}
     
     
}
void leaf(turtle_t &turt, double length)
{
  double factor,i;
  
factor=length/10;
 if(factor<=0.005)
   return;
 else{
  
   for(i=2.0;i<=4.2;i=i+0.2){
turt.forward(factor);
turt.turn_right(45);
leaf(turt,4.2*factor/i);
turt.forward(4.8*factor/i);
turt.backward_move(4.8*factor/i);
turt.turn_left(45);
turt.forward(factor/6);
turt.turn_left(45);
leaf(turt,4.2*factor/i);
turt.forward(4.8*factor/i);
turt.backward_move(4.8*factor/i);

turt.turn_right(45.15);

   }
turt.forward(factor/8);
turt.backward_move(length+3*factor);


}
     
     
}
Exemple #11
0
void triline(turtle_t &turt, double length, bool arg)
{
    double newlength = length/4.0;
   if (length <= 0.03)
   {
      turt.forward(length);
   }
   else if (arg)
   {
    
     /*triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);
     turt.turn_right(120);
     triline(turt, newlength);
     turt.turn_left(60);
     triline(turt, newlength);*/
	 triline(turt, newlength,true);
	 turt.turn_left(60);
	 triline(turt, newlength,false);
	 turt.turn_left(60);
	 triline(turt, newlength,true);
	 turt.turn_right(60);
	 triline(turt, newlength,false);
	 turt.turn_right(60);
	 triline(turt, newlength,true);
	 turt.turn_right(60);
	 triline(turt, newlength,false);
	 turt.turn_right(60);
	 triline(turt, newlength,true);
	 turt.turn_left(60);
	 triline(turt, newlength,false);
	 turt.turn_left(60);
	 triline(turt, newlength,true);
	 
	
   }
   else{
	 triline(turt, newlength, false);
	 turt.turn_right(60);
	 triline(turt, newlength, true);
	 turt.turn_right(60);
	 triline(turt, newlength, false);
	 turt.turn_left(60);
	 triline(turt, newlength, true);
	 turt.turn_left(60);
	 triline(turt, newlength, false);
	 turt.turn_left(60);
	 triline(turt, newlength, true);
	 turt.turn_left(60);
	 triline(turt, newlength, false);
	 turt.turn_right(60);
	 triline(turt, newlength, true);
	 turt.turn_right(60);
	 triline(turt, newlength, false);
}
	
}