
//////////////////////
// Zoom TAG loupe  //
//Code By Ayoros  //
///////////////////

function part6() {
    this.vbl = 0 ;
    this.initdone = 0 ;
    this.canvaspart ;

    var bulx=0;
    var buly=0;

    var mybuffer1;

    this.init = function(dest) {
        this.canvaspart = new canvas(640,400) ;

        mybuffer1 = new canvas(276,92); // 3 round masks of 92x92
        this.initdone = 1 ;
     }

    this.render = function(dest) {
        if (this.initdone == 0) { this.init() ; }
          myimage.draw(this.canvaspart);
          bulx+=0.02;
          buly+=0.03;

          var sinbulx1 = (Math.sin(bulx)*160) ;
          var sinbuly1 = (Math.sin(buly)*90) ;
          var sinbulx2 = (Math.sin(bulx)*220) ;
          var sinbuly2 = (Math.sin(buly)*120) ;

          // draw squares into temp buffers and double them
          mybuffer1.contex.globalCompositeOperation='source-over';

          myimage.drawPart(mybuffer1,  0, 0, 245 + sinbulx1, 140 + sinbuly1, 46, 46, 1, 0, 2, 2);
          myimage.drawPart(mybuffer1, 92, 0, 275 - sinbulx1, 160 - sinbuly1, 46, 46, 1, 0, 2, 2);
          myimage.drawPart(mybuffer1,184, 0, 240 + sinbulx2, 180 - sinbuly2, 46, 46, 1, 0, 2, 2);

          // mask squares them
          mybuffer1.contex.globalCompositeOperation='destination-in';
          mask.draw(mybuffer1);

          // draw back to dest
          mybuffer1.drawPart(this.canvaspart,281 + sinbulx1, 174 + sinbuly1,  0, 0, 92, 92);
          mybuffer1.drawPart(this.canvaspart,310 - sinbulx1, 194 - sinbuly1, 92, 0, 92, 92);
          mybuffer1.drawPart(this.canvaspart,275 + sinbulx2, 214 - sinbuly2,184, 0, 92, 92);

          ball_loupe.draw(this.canvaspart,272 + sinbulx1, 174 + sinbuly1);
          ball_loupe.draw(this.canvaspart,301 - sinbulx1, 194 - sinbuly1);
          ball_loupe.draw(this.canvaspart,266 + sinbulx2, 214 - sinbuly2);

          this.canvaspart.draw(dest,60,88);
          
        if (this.vbl<100) mycanvasblack.draw(dest,60,88,1-this.vbl/100);
        if (this.vbl>intro_parts[part_running].part_duration-100) mycanvasblack.draw(dest,60,88,1-(intro_parts[part_running].part_duration-this.vbl)/100);
        this.vbl++ ;
    }

    return this;
}

//////////////
//END PART6//
////////////
