
//////////////////////
//Tunnel Vertices  //
//Code By Ayoros  //
///////////////////

function part4() {
    this.vbl = 0 ;
    this.initdone = 0 ;
    this.canvaspart;
var test_tunnel=1;
var date;    
var width = 600;
var height = 400;

var scale = height/3;

var rings = 96;
var ringsize = 48;

var zmax = 2.5;
var zstep = 2*zmax / rings;
var tstep = 2*Math.PI/ringsize;

var zshift = zstep;

var t;
var x_tunnel=[];
var y_tunnel=[];
var xt_tunnel=[];
var yt_tunnel=[];
var xtz_tunnel=[];
var ytz_tunnel=[];
var xz_tunnel=[];
var yz_tunnel=[];
var wx_tunnel;
var wy_tunnel;
var wxz_tunnel;
var wyz_tunnel;
var multiplier;
var multiplier2;
function rgb(b,d,c){return"rgb("+~~b+","+~~d+","+~~c+")"}function hsl(b,d,c){return"hsl("+~~b+","+150*d+"%,"+150*c+"%)"}var color_tunnel=0,offsetx=300,offsety=200;
function line_tunnel(b){var d=+new Date,c=d-date;rings=1==test_tunnel?72:24;zstep=2*zmax/rings;zshift=1==test_tunnel?zshift-zstep/3*c/32:zshift-zstep/3*c/96;0>zshift&&(zshift+=zstep);c=rings;b=b.contex;for(var f=b.fillStyle;c--;)if(!(1>c)){var a=c*zstep+zshift,e=a-zstep;color_tunnel=hsl((date/40+20*a)%360,0.5,0.2);wx_tunnel=offsetx+70*Math.sin(a+date/570);wy_tunnel=offsety+70*Math.cos(a+date/510);wxz_tunnel=offsetx+70*Math.sin(e+date/570);wyz_tunnel=offsety+70*Math.cos(e+date/510);multiplier=scale/
a;multiplier2=scale/e;for(a=0;a<ringsize;a++){t=a*tstep+Math.PI+Math.sin(date/2500);var e=Math.cos(t)*multiplier,g=Math.sin(t)*multiplier,h=Math.cos(t+tstep)*multiplier,k=Math.sin(t+tstep)*multiplier,l=Math.cos(t)*multiplier2,m=Math.sin(t)*multiplier2,n=Math.cos(t+tstep)*multiplier2,p=Math.sin(t+tstep)*multiplier2;x_tunnel[a]=wx_tunnel+e;y_tunnel[a]=wy_tunnel+g;xt_tunnel[a]=wx_tunnel+h;yt_tunnel[a]=wy_tunnel+k;xtz_tunnel[a]=wxz_tunnel+l;ytz_tunnel[a]=wyz_tunnel+m;xz_tunnel[a]=wxz_tunnel+n;yz_tunnel[a]=
wyz_tunnel+p}if(1==test_tunnel){b.lineWidth=1;b.beginPath();b.strokeStyle="#c63eb4";for(a=0;a<ringsize;a++)b.moveTo(x_tunnel[a],y_tunnel[a]),b.lineTo(xt_tunnel[a],yt_tunnel[a]);b.closePath();b.stroke();b.beginPath();b.strokeStyle="#b6312e";for(a=0;a<ringsize;a++)b.moveTo(x_tunnel[a],y_tunnel[a]),b.lineTo(xtz_tunnel[a],ytz_tunnel[a]);b.closePath();b.stroke();b.beginPath();b.strokeStyle="#b65e2e";for(a=0;a<ringsize;a++)b.moveTo(x_tunnel[a],y_tunnel[a]),b.lineTo(xz_tunnel[a],yz_tunnel[a]);b.closePath();
b.stroke()}else{b.lineWidth=0.5;b.beginPath();b.strokeStyle="#c6413e";b.fillStyle=color_tunnel;for(a=0;a<ringsize;a++)b.moveTo(x_tunnel[a],y_tunnel[a]),b.lineTo(xt_tunnel[a],yt_tunnel[a]),b.lineTo(xz_tunnel[a],yz_tunnel[a]),b.lineTo(xtz_tunnel[a],ytz_tunnel[a]);b.closePath();b.stroke();b.fill()}}b.fillStyle=f;date=d}
this.render=function(b){0==this.initdone&&(this.canvaspart=new canvas(600,400),this.initdone=1);0==this.vbl&&(test_tunnel=1,date=new Date,this.canvaspart.contex.globalCompositeOperation="lighter");400==this.vbl&&(test_tunnel=0,date=new Date,this.canvaspart.contex.globalCompositeOperation="source-over");this.canvaspart.clear();line_tunnel(this.canvaspart);this.canvaspart.draw(b,60,88);100>this.vbl&&mycanvasblack.draw(b,60,88,1-this.vbl/100);this.vbl>intro_parts[part_running].part_duration-100&&mycanvasblack.draw(b,
60,88,1-(intro_parts[part_running].part_duration-this.vbl)/100);this.vbl++;this.vbl>=this.vbl>intro_parts[part_running].part_duration&&(this.vbl=0)};
}

//////////////
//END PART4//
////////////
