Response title
This is preview!




Click on Join Now to Sign Up
PVector pos;//<start positionvoid setup(){float p=1.5;//extra variable to simple change sizesize(int(800*p),int( 800*p));noLoop();background(#ffffff);pos=new PVector(800*p/2,400*p/2);//<start position}//-----------------------------//String L_string = "+F+F+F+F";//String change="F-F+F+FF-F-F+F";String change="FF-F-F-F-F-F+F";int n=3;//iteration number//-----------------------------int F=int(10); //how long single line isfloat THETA=PI/2;//-------------------------------//-------------------------------void draw(){println(L_string+" <-String in beginning ");for(int i=0;i<n;i=i+1)//n-number of iterations,it generate string{L_string=Make_String(L_string,change);println(L_string+" <-String in end");}background(#ffffff);draw_String(L_string,THETA,F);}//-------------------------------//-------------------------------String Make_String(String L_string,String change){//I am creating arrayString[] L_STRING = new String[L_string.length()];//----------------------------------------//fill in arrayfor (int i = 0; i < L_string.length(); i = i+1){L_STRING[i]=""+L_string.charAt(i);if(L_string.charAt(i)=='F'){L_STRING[i]=change;}}//----------------------------------------int W=L_string.length();//I add new variable because i will change string//it create string from arrayL_string="";for (int i = 0; i < W; i = i+1){L_string=L_string+L_STRING[i];}return(L_string);}//-------------------------------//-------------------------------void draw_String(String L_string,float TETA,int F){float R=0;for (int i = 0; i < L_string.length(); i = i+1){//if rotation is multiple of 360 i can remove itif(R>=2*PI){R=R-2*PI;}if(R<-2*PI){R=R+2*PI;}if(L_string.charAt(i)=='F'){//extra variablesint x=int(F*cos(R+PI/2));int y= int(F*sin(R+PI/2));line(pos.x,pos.y,pos.x- x,pos.y-y);pos.x-= x;pos.y-= y;}if(L_string.charAt(i)=='+'){//turn rightR+=THETA;}if(L_string.charAt(i)=='-'){//turn leftR-=THETA;}}print(R);}