/* Code by Gildas P. / www.gildasp.fr */ Pixel = new Class({ initialize : function(pCanvas, rang){ this.pCanvas = pCanvas; this.id = rang; this.x = 0.1; this.y = 0.1; this.angle = 0; this.s1x = 0; this.s1y = 0; this.s2x = 0; this.s2y = 0; this.s3x = 0; this.s3y = 0; this.s4x = 0; this.s4y = 0; this.diametre = 0; this.coul = this.pCanvas.color(255, 255, 255); this.vitx = 0; this.vity = 0; this.pvitx = 0; this.pvity = 0; this.vitrot = 0; this.centrex = sceneWidth/2; this.centrey = sceneHeight/2; this.zone = 300; this.forme = "quad"; this.updateExtends1 = ''; this.updateExtends2 = ''; this.updateExtends3 = ''; this.updateExtends4 = ''; this.g1 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.g2 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.rot = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b1 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b2 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b3 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b4 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b5 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b6 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b7 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.b8 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.diam = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.c1 = new Tween(this, "centrex", Tween.regularEaseInOut, this.centrex, this.centrex, 0.01); this.c2 = new Tween(this, "centrey", Tween.regularEaseInOut, this.centrey, this.centrey, 0.01); this.t1 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.t2 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.t3 = new Tween(this, "x", Tween.regularEaseInOut, this.x, this.x, 0.01); this.z = new Tween(this, "zone", Tween.regularEaseInOut, this.zone, this.zone, 0.01); this.goOut(0, 0); this.centerMiddle(0, 0); this.zoneM(0, 0); }, updatePixel : function(){ this.pvitx = this.vitx; this.pvity = this.vity; this.vitx = 0; this.vity = 0; this.g1.tick(); this.g2.tick(); this.rot.tick(); this.b1.tick(); this.b2.tick(); this.b3.tick(); this.b4.tick(); this.b5.tick(); this.b6.tick(); this.b7.tick(); this.b8.tick(); this.diam.tick(); this.c1.tick(); this.c2.tick(); this.t1.tick(); this.t2.tick(); this.t3.tick(); this.z.tick(); if(this.updateExtends3 != ''){ this.evaluate(this.updateExtends3); } if(this.updateExtends1 != ''){ this.evaluate(this.updateExtends1); } if(this.updateExtends2 != ''){ this.evaluate(this.updateExtends2); } if(this.updateExtends4 != ''){ this.evaluate(this.updateExtends4); } this.thinkCore(); }, drawPixel : function(){ obj = this.pCanvas; obj.fill(this.coul); obj.noStroke(); obj.pushMatrix(); obj.translate(this.x, this.y); obj.rotate(this.angle); if(this.forme == "quad"){ obj.quad(this.s1x, this.s1y, this.s2x, this.s2y, this.s3x, this.s3y, this.s4x, this.s4y); } else { obj.ellipse(0, 0, this.diametre, this.diametre); } obj.popMatrix(); }, delay : function(codeString, sec){ codeString = str_replace(codeString, 'this', "listePixels["+this.id+"]"); if(sec<=0){ this.delayed = setTimeout(codeString, 0); } else { this.delayed = setTimeout(codeString, sec*1000); } return this.delayed; }, evaluate : function(codeString){ codeString = str_replace(codeString, 'this', "listePixels["+this.id+"]"); eval(codeString); }, debug : function(txt){ jQuery('#debugger').append(txt)+'<br />'; }, debugClear : function(){ jQuery('#debugger').html(''); }, hitTestCircles : function(pixObj){ ray1 = this.diametre/2; ray2 = pixObj.diametre/2; if((ray1+ray2)>(this.pCanvas.dist(this.x, this.y, pixObj.x, pixObj.y))){ return true; } else { return false; } }, hitTestQuads : function(pixObj){ ray1 = this.diametre/2; ray2 = pixObj.diametre/2; x1 = this.s1x; y1 = this.s1y; L1 = this.s2x-this.s1x; H1 = this.s3y-this.s2y; x2 = pixObj.s1x; y2 = pixObj.s1y; L2 = pixObj.s2x-pixObj.s1x; H2 = pixObj.s3y-pixObj.s2y; distx = x2-x1; disty = y2-y1; if(((distx>0 && L1>=distx) || (distx<0 && L2>=Math.abs(distx))) && ((disty>0 && h1>=disty) || (disty<0 && h2>=Math.abs(disty)))){ return true; } else { return false; } },  beQuadCore : function(delai, duree, x1, y1, x2, y2, x3, y3, x4, y4){ if(this.forme == "circle"){ del = randFloat(0, 1); this.beCircleCore(del, 1, 0); this.delay('this.forme="quad"; this.s1x=0; this.s1y=0; this.s2x=0; this.s2y=0; this.s3x=0; this.s3y=0; this.s4x=0; this.s4y=0; this.beQuadCore('+delai+', '+duree+', '+x1+', '+y1+', '+x2+', '+y2+', '+x3+', '+y3+', '+x4+', '+y4+');', del+1.1); } else { if(duree <= 0){ duree = 0.01; } code = 'this.b1 = new Tween(this, "s1x", Tween.regularEaseInOut, this.s1x, '+x1+', '+duree+'); this.b2 = new Tween(this, "s1y", Tween.regularEaseInOut, this.s1y, '+y1+', '+duree+'); this.b3 = new Tween(this, "s2x", Tween.regularEaseInOut, this.s2x, '+x2+', '+duree+'); this.b4 = new Tween(this, "s2y", Tween.regularEaseInOut, this.s2y, '+y2+', '+duree+'); this.b5 = new Tween(this, "s3x", Tween.regularEaseInOut, this.s3x, '+x3+', '+duree+'); this.b6 = new Tween(this, "s3y", Tween.regularEaseInOut, this.s3y, '+y3+', '+duree+'); this.b7 = new Tween(this, "s4x", Tween.regularEaseInOut, this.s4x, '+x4+', '+duree+'); this.b8 = new Tween(this, "s4y", Tween.regularEaseInOut, this.s4y, '+y4+', '+duree+'); this.b1.start(); this.b2.start(); this.b3.start(); this.b4.start(); this.b5.start(); this.b6.start(); this.b7.start(); this.b8.start();'; if(delai<=0){ this.delay(code, 0); } else { this.delay(code, delai); } } }, beInvisible : function(delai, duree){ activeBtnFromName('be', 'Invisible'); this.diam = new Tween(this, "diametre", Tween.regularEaseInOut, this.diametre, 0, Math.max(0.1, delai)); this.diam.start(); this.beQuadCore(delai, duree, 0, 0, 0, 0, 0, 0, 0, 0); }, beIsoTriangleS : function(delai, duree){ activeBtnFromName('be', 'IsoTriangleS'); this.beQuadCore(delai, duree, -5, -2.5, 5.5, 0, 5.5, 0, -5, 2.5); }, beIsoTriangleM : function(delai, duree){ activeBtnFromName('be', 'IsoTriangleM'); this.beQuadCore(delai, duree, -10, -5, 10, 0, 10, 0, -10, 5); }, beIsoTriangleL : function(delai, duree){ activeBtnFromName('be', 'IsoTriangleL'); this.beQuadCore(delai, duree, -20, -10, 20, 0, 20, 0, -20, 10); }, beIsoTriangleAll : function(delai, duree){ tmp = new Array("IsoTriangleS", "IsoTriangleM", "IsoTriangleL"); eval("this.be"+tmp[randInt(0, 2)]+"(delai, duree);"); activeBtnFromName('be', 'IsoTriangleAll'); }, bePoint : function(delai, duree){ activeBtnFromName('be', 'Point'); this.beQuadCore(delai, duree, -1, -1, 1, -1, 1, 1, -1, 1); }, bePixel : function(delai, duree){ activeBtnFromName('be', 'Pixel'); this.beQuadCore(delai, duree, -5, -2.5, 5.5, -2.5, 5.5, 2.5, -5, 2.5); }, beRectS : function(delai, duree){ activeBtnFromName('be', 'RectS'); rectL = randInt(10, 30)/2; rectH = randInt(10, 30)/2; this.beQuadCore(delai, duree, -1*rectL, -1*rectH, rectL, -1*rectH, rectL, rectH, -1*rectL, rectH); }, beRectM : function(delai, duree){ activeBtnFromName('be', 'RectM'); rectL = randInt(20, 60)/2; rectH = randInt(20, 60)/2; this.beQuadCore(delai, duree, -1*rectL, -1*rectH, rectL, -1*rectH, rectL, rectH, -1*rectL, rectH); }, beRectL : function(delai, duree){ activeBtnFromName('be', 'RectL'); rectL = randInt(60, 120)/2; rectH = randInt(60, 120)/2; this.beQuadCore(delai, duree, -1*rectL, -1*rectH, rectL, -1*rectH, rectL, rectH, -1*rectL, rectH); }, beRectAll : function(delai, duree){ tmp = new Array("RectS", "RectM", "RectL"); eval("this.be"+tmp[randInt(0, 2)]+"(delai, duree);"); activeBtnFromName('be', 'RectAll'); }, beBlobS : function(delai, duree){ activeBtnFromName('be', 'BlobS'); rectL = randInt(20, 60)/2; rectH = randInt(20, 60)/2; this.beQuadCore(delai, duree, -1*randInt(2, rectL), -1*randInt(2, rectH), randInt(2, rectL), -1*randInt(2, rectH), randInt(2, rectL), randInt(2, rectH), -1*randInt(2, rectL), randInt(2, rectH)); }, beBlobM : function(delai, duree){ activeBtnFromName('be', 'BlobM'); rectL = randInt(60, 120)/2; rectH = randInt(60, 120)/2; this.beQuadCore(delai, duree, -1*randInt(2, rectL), -1*randInt(2, rectH), randInt(2, rectL), -1*randInt(2, rectH), randInt(2, rectL), randInt(2, rectH), -1*randInt(2, rectL), randInt(2, rectH)); }, beBlobL : function(delai, duree){ activeBtnFromName('be', 'BlobL'); rectL = randInt(120, 300)/2; rectH = randInt(120, 300)/2; this.beQuadCore(delai, duree, -1*randInt(2, rectL), -1*randInt(2, rectH), randInt(2, rectL), -1*randInt(2, rectH), randInt(2, rectL), randInt(2, rectH), -1*randInt(2, rectL), randInt(2, rectH)); }, beBlobAll : function(delai, duree){ tmp = new Array("BlobS", "BlobM", "BlobL"); eval("this.be"+tmp[randInt(0, 2)]+"(delai, duree);"); activeBtnFromName('be', 'BlobAll'); }, beLineH : function(delai, duree){ activeBtnFromName('be', 'LineH'); rectL = sceneWidth*2; rectH = 0.5; this.beQuadCore(delai, duree, -1*rectL, -1*rectH, rectL, -1*rectH, rectL, rectH, -1*rectL, rectH); }, beLineV : function(delai, duree){ activeBtnFromName('be', 'LineV'); rectL = 0.5; rectH = sceneHeight*2; this.beQuadCore(delai, duree, -1*rectL, -1*rectH, rectL, -1*rectH, rectL, rectH, -1*rectL, rectH); }, beCircleCore : function(delai, duree, newDiametre){ if(this.forme == "quad"){ del = randFloat(0, 1); this.beInvisible(del, 1); this.delay('this.forme="circle"; this.diametre=0; this.beCircleCore('+delai+', '+duree+', '+newDiametre+');', del+1.1); } else { if(duree <= 0){ duree = 0.01; } code = 'this.diam = new Tween(this, "diametre", Tween.regularEaseInOut, this.diametre, '+newDiametre+', '+duree+'); this.diam.start();'; if(delai<=0){ this.delay(code, 0); } else { this.delay(code, delai); } } }, beCircleS : function(delai, duree){ activeBtnFromName('be', 'CircleS'); this.beCircleCore(delai, duree, randInt(3, 25)); }, beCircleM : function(delai, duree){ activeBtnFromName('be', 'CircleM'); this.beCircleCore(delai, duree, randInt(25, 55)); }, beCircleL : function(delai, duree){ activeBtnFromName('be', 'CircleL'); this.beCircleCore(delai, duree, randInt(55, 130)); }, beCircleAll : function(delai, duree){ tmp = new Array("CircleS", "CircleM", "CircleL"); eval("this.be"+tmp[randInt(0, 2)]+"(delai, duree);"); activeBtnFromName('be', 'CircleAll'); }, beFreestyle : function(delai, duree){ eval("this.be"+beList[randInt(0, beList.length-1)]+"(delai, duree);"); activeBtnFromName('be', 'Freestyle'); }, goCore : function(delai, duree, posx, posy){ if(duree <= 0){ duree = 0.01; } code = 'this.g1 = new Tween(this, "x", Tween.regularEaseInOut, this.x, '+posx+', '+duree+'); this.g2 = new Tween(this, "y", Tween.regularEaseInOut, this.y, '+posy+', '+duree+'); this.g1.start(); this.g2.start();'; if(delai<=0){ this.delay(code, 0); } else { this.delay(code, delai); } }, goUp : function(delai, duree){ activeBtnFromName('be', 'Up'); this.goCore(delai, duree, randInt(0, sceneWidth), -1*randInt(100, 350)); }, goDown : function(delai, duree){ activeBtnFromName('go', 'Down'); this.goCore(delai, duree, randInt(0, sceneWidth), (sceneHeight+randInt(100, 350))); }, goLeft : function(delai, duree){ activeBtnFromName('go', 'Left'); this.goCore(delai, duree, -1*randInt(100, 350), randInt(0, sceneHeight)); }, goRight : function(delai, duree){ activeBtnFromName('go', 'Right'); this.goCore(delai, duree, sceneWidth+randInt(100, 350), randInt(0, sceneHeight)); }, goLine : function(delai, duree){ activeBtnFromName('go', 'Line'); obj = this.pCanvas; nbParLigne = Math.floor((sceneWidth-60)/20); nbLignes = Math.ceil(obj.nbPixels/nbParLigne); posx = (this.id%nbParLigne)*10; posy = Math.floor(this.id/nbParLigne)*15; this.goCore(delai, duree, this.centrex+posx, this.centrey+posy); }, goAnywhere : function(delai, duree){ activeBtnFromName('go', 'Anywhere'); this.goCore(delai, duree, randInt(0, sceneWidth), randInt(0, sceneHeight)); }, goOut : function(delai, duree){ activeBtnFromName('go', 'Out'); side = randInt(0, 3); distance = randInt(100, 300); switch (side){ case 0 : posx = randInt(-100, sceneWidth+100); posy = -1*distance; break; case 1 : posx = randInt(-100, sceneWidth+100); posy = sceneHeight+distance; break; case 2 : posx = -1*distance; posy = randInt(-100, sceneHeight+100); break; case 3 : posx = sceneWidth+distance; posy = randInt(-100, sceneHeight+100); break; } this.goCore(delai, duree, posx, posy); }, goNearby : function(delai, duree){ activeBtnFromName('go', 'Nearby'); side = new Array(-1, 1); distx = side[randInt(0,1)]*randInt(20, 80)/4; disty = side[randInt(0,1)]*randInt(20, 80)/4; this.goCore(0, 0.4, this.x+distx, this.y+disty); }, goWindy : function(delai, duree){ activeBtnFromName('go', 'Windy'); this.goCore(randFloat(0, 0.5), 1, this.x-1*randInt(100, 250), this.y+randInt(0, 100)-50); }, goGroupCore : function(delai, duree, rayon){ obj = this.pCanvas; rayon = randInt(0, rayon); alpha = randFloat(0, obj.TWO_PI); a = rayon*obj.cos(alpha); b = rayon*obj.sin(alpha); this.goCore(delai, duree, this.centrex+a, this.centrey+b); }, goGroupS : function(delai, duree){ activeBtnFromName('go', 'GroupS'); this.goGroupCore(delai, duree, 50); }, goGroupM : function(delai, duree){ activeBtnFromName('go', 'GroupM'); this.goGroupCore(delai, duree, 150); }, goGroupL : function(delai, duree){ activeBtnFromName('go', 'GroupL'); this.goGroupCore(delai, duree, 300); }, goFreestyle : function(delai, duree){ eval("this.go"+goList[randInt(0, goList.length-1)]+"(delai, duree);"); activeBtnFromName('go', 'Freestyle'); }, go2NewAngleCore : function(delai, duree, newAngle){ if(duree <= 0){ duree = 0.01; } code = 'this.rot = new Tween(this, "angle", Tween.regularEaseInOut, this.angle, '+newAngle+', '+duree+'); this.rot.start();'; if(delai<=0){ this.delay(code, 0); } else { this.delay(code, delai); } }, go2NewAngle : function(delai, duree){ activeBtnFromName('go2', 'NewAngle'); this.go2NewAngleCore(delai, duree, randFloat(0, this.pCanvas.TWO_PI)); }, go2NoAngle : function(delai, duree){ activeBtnFromName('go2', 'NoAngle'); this.go2NewAngleCore(delai, duree, 0); }, centerCore : function(delai, duree, posx, posy){ if(duree <= 0){ duree = 0.01; } code = 'this.c1 = new Tween(this, "centrex", Tween.regularEaseInOut, this.centrex, '+posx+', '+duree+'); this.c2 = new Tween(this, "centrey", Tween.regularEaseInOut, this.centrey, '+posy+', '+duree+'); this.c1.start(); this.c2.start();'; if(delai<=0){ this.delay(code, 0); } else { this.delay(code, delai); } }, centerNone : function(){ this.updateExtends3 = ''; this.c1 = new Tween(this, "centrex", Tween.regularEaseInOut, this.centrex, this.centrex, 0.05); this.c2 = new Tween(this, "centrey", Tween.regularEaseInOut, this.centrey, this.centrey, 0.05); this.c1.start(); this.c2.start(); clearTimeout(this.randomgoing); }, centerMiddle : function(delai, duree){ this.centerNone(); activeBtnFromName('center', 'Middle'); this.centerCore(delai, duree, sceneWidth/2, sceneHeight/2); }, centerLeft : function(delai, duree){ this.centerNone(); activeBtnFromName('center', 'Left'); this.centerCore(delai, duree, sceneWidth/4, sceneHeight/2); }, centerRight : function(delai, duree){ this.centerNone(); activeBtnFromName('center', 'Right'); this.centerCore(delai, duree, 3*sceneWidth/4, sceneHeight/2); }, centerBottomLeft : function(delai, duree){ this.centerNone(); activeBtnFromName('center', 'BottomLeft'); this.centerCore(delai, duree, sceneWidth/4, 3*sceneHeight/4); }, centerBottomRight : function(delai, duree){ this.centerNone(); activeBtnFromName('center', 'BottomRight'); this.centerCore(delai, duree, 3*sceneWidth/4, 3*sceneHeight/4); }, centerTopRight : function(delai, duree){ this.centerNone(); activeBtnFromName('center', 'TopRight'); this.centerCore(delai, duree, 5*sceneWidth/6, sceneHeight/6); }, centerRandom : function(delai, duree){ this.centerNone(); this.pCanvas.globalCenterx = randInt(0, sceneWidth); this.pCanvas.globalCentery = randInt(0, sceneHeight); activeBtnFromName('center', 'Random'); this.delay("this.centerCore("+delai+", "+duree+", this.pCanvas.globalCenterx, this.pCanvas.globalCentery);", 0.2); }, centerContinuousRandom : function(delai, duree){ this.centerRandom(randFloat(0,1), 2); this.randomgoing = this.delay("this.centerContinuousRandom();", 2); activeBtnFromName('center', 'ContinuousRandom'); }, centerMouseDelayCore : function(){ this.centerCore(0, 0.1, mouseX, mouseY); }, centerMouseDelay : function(delai, duree){ activeBtnFromName('center', 'MouseDelay'); this.updateExtends3 = "this.centerMouseDelayCore();"; }, centerMouseNoDelayCore : function(){ this.centrex = mouseX; this.centrey = mouseY; }, centerMouseNoDelay : function(delai, duree){ activeBtnFromName('center', 'MouseNoDelay'); this.updateExtends3 = "this.centerMouseNoDelayCore();"; }, zoneCore : function(delai, duree, largeur){ if(duree <= 0){ duree = 0.01; } code = 'this.z = new Tween(this, "zone", Tween.regularEaseInOut, this.zone, '+largeur+', '+duree+'); this.z.start();'; if(delai<=0){ this.delay(code, 0); } else { this.delay(code, delai); } }, zoneXS : function(delai, duree){ activeBtnFromName('zone', 'XS'); this.zoneCore(delai, duree, 10); }, zoneS : function(delai, duree){ activeBtnFromName('zone', 'S'); this.zoneCore(delai, duree, 70); }, zoneM : function(delai, duree){ activeBtnFromName('zone', 'M'); this.zoneCore(delai, duree, 150); }, zoneL : function(delai, duree){ activeBtnFromName('zone', 'L'); this.zoneCore(delai, duree, 300); }, thinkCore : function(){ this.x += this.vitx; this.y += this.vity; this.angle += this.vitrot; obj = this.pCanvas; if(this.x > sceneWidth+300){ this.x = this.x-sceneWidth-600; } else if(this.x < -300){ this.x = this.x+sceneWidth+600; } if(this.y > sceneHeight+300){ this.y = this.y-sceneHeight-600; } else if(this.y < -300){ this.y = this.y+sceneHeight+600; } }, thinkNone : function(){ activeBtnFromName('think', 'None'); this.t1 = new Tween(this, "vitx", Tween.regularEaseInOut, this.pvitx, 0, 1.2); this.t2 = new Tween(this, "vity", Tween.regularEaseInOut, this.pvity, 0, 1.2); this.t1.start(); this.t2.start(); clearTimeout(this.dancing); clearTimeout(this.randomgoing); this.updateExtends1 = ''; this.updateExtends2 = ''; }, thinkFloating : function(){ activeBtnFromName('think', 'Floating'); }, thinkErratic : function(){ activeBtnFromName('think', 'Erratic'); }, thinkExpanding : function(){ activeBtnFromName('think', 'Expanding'); }, thinkExploring : function(){ activeBtnFromName('think', 'Exploring'); }, thinkFreneticUpdate : function(accCoef){ limiteDist = this.zone; vitMax = 7; obj = this.pCanvas; this.accx = randFloat(-1*accCoef, accCoef); this.accy = randFloat(-1*accCoef, accCoef); tvitx = obj.abs(this.pvitx+this.accx)/(this.pvitx+this.accx)*obj.min(vitMax, obj.abs(this.pvitx+this.accx)); tvity = obj.abs(this.pvity+this.accy)/(this.pvity+this.accy)*obj.min(vitMax, obj.abs(this.pvity+this.accy)); distRef = obj.dist(this.x, this.y, this.centrex, this.centrey); if(distRef>limiteDist){ distx = this.centrex-this.x; disty = this.centrey-this.y; tvitx += distx/distRef; tvity += disty/distRef; } this.vitx += tvitx; this.vity += tvity; }, thinkFrenetic : function(){ this.thinkNone(); this.updateExtends1 = "this.thinkFreneticUpdate(3);"; activeBtnFromName('think', 'Frenetic'); }, thinkElliptic : function(){ this.thinkNone(); this.updateExtends1 = "this.thinkFreneticUpdate(0.5);"; activeBtnFromName('think', 'Elliptic'); }, thinkDancingLoop : function(){ this.goNearby(0, 0); this.dancing = this.delay("this.thinkDancingLoop();", 0.4); }, thinkDancing : function(){ this.thinkNone(); this.thinkDancingLoop(); activeBtnFromName('think', 'Dancing'); }, thinkDrawing : function(){ activeBtnFromName('think', 'Drawing'); }, thinkStreamUpdate : function(vitessex, vitessey){ this.vitx += vitessex; this.vity += vitessey; }, thinkLeftStream : function(){ activeBtnFromName('think', 'LeftStream'); vitessex = randFloat(-3, -10); vitessey = randFloat(-2, 2); this.updateExtends1 = "this.thinkStreamUpdate("+vitessex+", "+vitessey+");"; }, thinkRightStream : function(){ activeBtnFromName('think', 'RightStream'); vitessex = randFloat(3, 10); vitessey = randFloat(-2, 2); this.updateExtends1 = "this.thinkStreamUpdate("+vitessex+", "+vitessey+");"; }, thinkUpStream : function(){ activeBtnFromName('think', 'UpStream'); vitessex = randFloat(-2, 2); vitessey = randFloat(-2, -7); this.updateExtends1 = "this.thinkStreamUpdate("+vitessex+", "+vitessey+");"; }, thinkDownStream : function(){ activeBtnFromName('think', 'DownStream'); vitessex = randFloat(-2, 2); vitessey = randFloat(1.5, 6); this.updateExtends1 = "this.thinkStreamUpdate("+vitessex+", "+vitessey+");"; }, thinkCircular : function(){ activeBtnFromName('think', 'Circular'); }, thinkReticular : function(){ activeBtnFromName('think', 'Reticular'); }, thinkUnstable : function(){ activeBtnFromName('think', 'Unstable'); }, thinkClaustrophobicUpdate : function(vitmax){ obj = this.pCanvas; tvitx = this.pvitx+randFloat(-1, 1); tvitx = obj.min(obj.abs(tvitx), vitmax)*tvitx/obj.abs(tvitx); tvity = this.pvity+randFloat(-1, 1); tvity = obj.min(obj.abs(tvity), vitmax)*tvity/obj.abs(tvity); if(this.x>=sceneWidth || this.x<=0){ if(this.x<=0){ tvitx = obj.abs(tvitx); } else { tvitx = -1*obj.abs(tvitx); } } if(this.y>=sceneHeight || this.y<=0){ if(this.y<=0){ tvity = obj.abs(tvity); } else { tvity = -1*obj.abs(tvity); } } this.vitx += tvitx; this.vity += tvity; }, thinkClaustrophobic : function(vitmax){ if(vitmax){} else { vitmax = 10; } activeBtnFromName('think', 'Claustrophobic'); this.updateExtends1 = "this.thinkClaustrophobicUpdate("+vitmax+");"; }, thinkGraviticCirclesUpdate : function(forcex, forcey){ this.vitx += forcex; this.vity += forcey; this.rayon = this.diametre/2; if(this.y+this.rayon>sceneHeight){ this.vity -= this.y+this.rayon-sceneHeight; } if(this.x+this.rayon>sceneWidth){ this.vitx -= this.x+this.rayon-sceneWidth; } if(this.x-this.rayon<0){ this.vitx -= this.x-this.rayon; } }, thinkGraviticCircles : function(forcex, forcey){ activeBtnFromName('think', 'GraviticCircles'); if(forcex){} else { forcex = 0; } if(forcey){} else { forcey = 18; } this.updateExtends1 = "this.thinkGraviticCirclesUpdate("+forcex+", "+forcey+");"; }, thinkSpore : function(){ activeBtnFromName('think', 'Spore'); }, thinkPong : function(){ activeBtnFromName('think', 'Pong'); }, thinkAsteroid : function(){ activeBtnFromName('think', 'Asteroid'); }, thinkRandomGo : function(){ activeBtnFromName('think', 'RandomGo'); del = randFloat(0, 1); eval("this.go"+goList[randInt(0, goList.length-1)]+"("+del+", 2);"); this.go2NewAngle(del, 2); this.randomgoing = this.delay("this.thinkRandomGo();", del+2); }, thinkFreestyle : function(){ eval("this.think"+thinkList[randInt(0, thinkList.length-1)]+"();"); activeBtnFromName('think', 'Freestyle'); }, think2None : function(){ activeBtnFromName('think2', 'None'); this.t3 = new Tween(this, "vitrot", Tween.regularEaseInOut, this.vitrot, 0, 1.2); this.t3.start(); clearTimeout(this.pulsing); clearTimeout(this.shapeshifting); this.updateExtends2 = ''; this.updateExtends4 = ''; }, think2Rotative : function(){ activeBtnFromName('think2', 'Rotative'); this.vitrot = randFloat(-0.05, 0.05); }, think2TangencialUpdate : function(){ obj = this.pCanvas; this.angle = Math.atan(this.vity/this.vitx); if(this.vitx<0) this.angle += obj.PI; }, think2Tangencial : function(){ activeBtnFromName('think2', 'Tangencial'); this.updateExtends4 = 'this.think2TangencialUpdate();'; }, think2PulsingLoop : function(){ del = randFloat(0, 0.3); dur = randFloat(0.4, 0.6); this.beCircleCore(del, dur, randInt(3, 70)); this.pulsing = this.delay("this.think2PulsingLoop();", del+dur); }, think2Pulsing : function(){ this.think2None(); this.updateExtends4 = ''; activeBtnFromName('think2', 'Pulsing'); this.think2PulsingLoop(); }, think2ShapeShifterUpdate : function(){ del = randFloat(0, 1); eval("this.be"+beList[randInt(0, beList.length-1)]+"("+del+", 2);"); this.go2NewAngle(del, 2); this.shapeshifting = this.delay("this.think2ShapeShifterUpdate();", del+2); }, think2ShapeShifter : function(){ this.updateExtends4 = ''; activeBtnFromName('think2', 'ShapeShifter'); this.think2ShapeShifterUpdate(); }, think2SolidShapeShifterUpdate : function(){ del = randFloat(0, 1); eval("this.be"+beList[randInt(0, beList.length-4)]+"("+del+", 2);"); this.go2NewAngle(del, 2); this.shapeshifting = this.delay("this.think2SolidShapeShifterUpdate();", del+2); }, think2SolidShapeShifter : function(){ this.updateExtends4 = ''; activeBtnFromName('think2', 'SolidShapeShifter'); this.think2SolidShapeShifterUpdate(); }, think2EpilepticUpdate : function(){ this.diametre = randInt(10, 40); }, think2Epileptic : function(){ clearTimeout(this.pulsing); clearTimeout(this.shapeshifting); del = randFloat(0, 0.3); dur = randFloat(0.4, 0.6); this.beCircleCore(del, dur, randInt(3, 70)); this.delay('this.updateExtends4 = "this.think2EpilepticUpdate();";', del+dur); activeBtnFromName('think2', 'Epileptic'); }, think2RepulsiveUpdate : function(attenuation){ obj = this.pCanvas; distance = obj.dist(mouseX, mouseY, this.x, this.y); if(distance<this.zone){ rayon = this.zone; distx = this.x-mouseX; disty = this.y-mouseY; coef = rayon/distance; this.repulsiveVitx = coef*distx/attenuation; this.repulsiveVity = coef*disty/attenuation; } else { this.repulsiveVitx *= 0.8; this.repulsiveVity *= 0.8; } this.vitx += this.repulsiveVitx; this.vity += this.repulsiveVity; }, think2Repulsive : function(att){ if(att){} else { att = 6; } this.updateExtends4 = ''; activeBtnFromName('think2', 'Repulsive'); this.repulsiveVitx = 0; this.repulsiveVity = 0; this.updateExtends2 = 'this.think2RepulsiveUpdate('+att+');'; }, think2AttractiveUpdate : function(attenuation){ obj = this.pCanvas; distance = obj.dist(mouseX, mouseY, this.x, this.y); if(distance<this.zone){ rayon = this.zone; distx = this.x-mouseX; disty = this.y-mouseY; coef = distance/rayon; this.repulsiveVitx = -1*distx/attenuation; this.repulsiveVity = -1*disty/attenuation; } else { this.repulsiveVitx *= 0.8; this.repulsiveVity *= 0.8; } this.vitx += this.repulsiveVitx; this.vity += this.repulsiveVity; }, think2Attractive : function(){ this.updateExtends4 = ''; activeBtnFromName('think2', 'Attractive'); this.repulsiveVitx = 0; this.repulsiveVity = 0; this.updateExtends2 = 'this.think2AttractiveUpdate(6);'; }, think2SolidCirclesUpdate : function(attenuation){ obj = this.pCanvas; this.solidRayon = this.diametre/2; this.collide = false; for(this.i=0; this.i<nbPixels; this.i++){ if(this.id != this.i && this.hitTestCircles(listePixels[this.i])){ this.collide = true; distx = this.x-listePixels[this.i].x; disty = this.y-listePixels[this.i].y; coef = (this.diametre/2+listePixels[this.i].diametre/2)/this.pCanvas.dist(this.x, this.y, listePixels[this.i].x, listePixels[this.i].y)/2; this.repulsiveVitx = coef*distx/attenuation; this.repulsiveVity = coef*disty/attenuation; this.vitx += this.repulsiveVitx; this.vity += this.repulsiveVity; } } }, think2SolidCircles : function(attenuation){ activeBtnFromName('react', 'SolidCircles'); if(attenuation){} else { attenuation = 20; } this.updateExtends4 = 'this.think2SolidCirclesUpdate('+attenuation+');'; }, demoCore : function(delai, duree){ }, demoNone : function(opt){ activeBtnFromName('demo', 'None'); this.thinkNone(); this.think2None(); this.centerNone(); if(!opt){ this.pCanvas.changePixelsNumber(60); } }, demoGraphicFigure1 : function(){ this.demoNone(); activeBtnFromName('demo', 'GraphicFigure1'); this.centerRight(randFloat(0, 1), 1); this.zoneS(randFloat(0, 1), 1); this.thinkElliptic(); this.go2NoAngle(3+randFloat(0, 1), 2); this.beBlobAll(3+randFloat(0, 1), 2); this.delay("this.beBlobAll(randFloat(0, 1), 2);", 5); }, demoGraphicFigure2 : function(){ this.demoNone(); activeBtnFromName('demo', 'GraphicFigure2'); this.centerRight(randFloat(0, 1), 1); this.zoneS(randFloat(0, 1), 1); this.thinkElliptic(); this.go2NoAngle(3+randFloat(0, 1), 2); this.bePoint(randFloat(0, 1), 2); this.delay('this.beCircleAll(randFloat(0, 1), 2);', 3.1); }, demoGraphicFigure3 : function(){ this.demoNone(); activeBtnFromName('demo', 'GraphicFigure3'); this.centerRight(randFloat(0, 1), 1); this.zoneS(randFloat(0, 1), 1); this.thinkElliptic(); this.think2Tangencial(); this.beIsoTriangleS(randFloat(0, 1), 2); this.delay("this.beIsoTriangleS(randFloat(0, 1), 2);", 2); }, demoGraphicFigure4 : function(){ this.demoNone(); activeBtnFromName('demo', 'GraphicFigure4'); this.centerBottomRight(randFloat(0, 1), 1); this.beLineH(randFloat(0, 1), 2); this.zoneS(randFloat(0, 1), 2); this.go2NewAngle(randFloat(0, 1), 2); this.delay("this.go2NewAngle(randFloat(0, 1), 2); this.goGroupS(randFloat(0, 1), 2);", 2); this.delay("this.go2NewAngle(randFloat(0, 1), 4); this.thinkElliptic();", 3); }, demoGraphicFigure5 : function(){ this.demoNone(); activeBtnFromName('demo', 'GraphicFigure5'); this.zoneM(randFloat(0, 1), 1); this.centerMiddle(randFloat(0, 1), 1); this.thinkElliptic(); this.delay("this.think2SolidShapeShifter();", 1.2); }, demoGraphicFigure6 : function(){ this.demoNone(); activeBtnFromName('demo', 'GraphicFigure6'); this.demoNone(); this.delay('this.centerMiddle(randFloat(0, 1), 1);', 1); if(this.id<20){ this.demoGraphicFigure2(); activeBtnFromName('demo', 'GraphicFigure6'); this.delay('this.think2SolidCircles(30);', 2.5); } else { this.beInvisible(randFloat(0, 1), 1); this.delay('this.beInvisible(randFloat(0, 1), 1); activeBtnFromName("demo", "GraphicFigure6");', 2); this.delay('this.beInvisible(randFloat(0, 1), 1); activeBtnFromName("demo", "GraphicFigure6");', 4); } }, demoGraphicFigure7 : function(){ this.demoNone(); activeBtnFromName('demo', 'GraphicFigure7'); this.centerRight(0, 0.1); this.beCircleAll(randFloat(0, 1), 2); this.delay("this.goGroupS(randFloat(0, 1), 2);", 0.3); this.delay("this.think2SolidCircles(40); this.beCircleAll(randFloat(0, 1), 2);", 2.2); }, demoMosquitos : function(){ this.demoNone(); activeBtnFromName('demo', 'Mosquitos'); this.goOut(randFloat(0, 1), 2); this.bePoint(1+randFloat(0, 1), 2); this.delay("this.zoneL(randFloat(0, 1), 2); this.thinkFrenetic(); this.bePoint(randFloat(0, 1), 1);", 3.2); this.delay("this.zoneXS(randFloat(0, 1), 2); this.centerContinuousRandom();", 6.4); this.delay("this.centerNone(); this.centerMouseNoDelay(randFloat(0, 1), 2);", 13.5); }, demoTetsuoBlob : function(){ this.demoNone(); activeBtnFromName('demo', 'TetsuoBlob'); this.zoneS(0, 0); this.delay("this.centerBottomRight(0, 0);", 0.1); this.delay("this.goGroupS(randFloat(0, 0.5), 1);", 0.2); this.delay("this.think2Rotative(); this.think2Pulsing();", 0.8); this.delay('this.demoNone(); this.think2Rotative(); activeBtnFromName("demo", "TetsuoBlob"); this.think2SolidShapeShifter();', 1.2); this.delay("this.thinkFrenetic(); this.centerMouseDelay(randFloat(0, 1), 2);", 5.4); }, demoBreakMyEyes1 : function(){ this.demoNone(); activeBtnFromName('demo', 'BreakMyEyes1'); this.delay('this.beLineH(randFloat(0, 1), 2); this.centerContinuousRandom(); this.go2NewAngle(randFloat(0,1), 4);', 0.5); this.thinkElliptic(); this.zoneS(randFloat(0, 1), 2); this.beLineH(randFloat(0, 1), 2); this.delay('this.beLineH(randFloat(0, 1), 2); this.think2Rotative();', 3.5); this.delay('this.beLineH(randFloat(0, 1), 2);', 5.5); }, demoBreakMyEyes2 : function(){ this.demoNone(); activeBtnFromName('demo', 'BreakMyEyes2'); this.delay('this.beLineH(randFloat(0, 1), 2); this.centerContinuousRandom(); this.go2NewAngle(randFloat(0,1), 4);', 0.5); this.thinkElliptic(); this.zoneS(randFloat(0, 1), 2); this.think2ShapeShifter(); this.delay('this.think2Rotative();', 3.5); }, demoSpaceJunk : function(){ this.demoNone(); activeBtnFromName('demo', 'SpaceJunk'); this.zoneL(randFloat(0, 1), 1); this.centerMiddle(randFloat(0, 1), 1); this.thinkElliptic(); this.delay("this.beBlobAll(randFloat(0, 1), 2); this.think2Rotative();", 2.1); this.delay("this.beBlobAll(randFloat(0, 1), 1); this.pCanvas.changePixelsNumber(200); this.centerMiddle(0, 0);", 4.5); delaySomePixels("this.thinkLeftStream();", 8, 60, 200); }, demoSpider : function(){ this.demoNone(); activeBtnFromName('demo', 'Spider'); this.centerBottomLeft(0, 0); this.delay("this.goGroupS(randFloat(0, 1), 2);", 0.2); this.beInvisible(randFloat(0, 1), 2); this.delay("this.beInvisible(randFloat(0, 1), 1);", 2); this.delay('this.centerTopRight(0, 0); this.delay("this.goGroupS(0, 0);", 0.1);', 3.2); this.delay("this.think2Rotative(); this.zoneXS(randFloat(0, 1), 2); this.beFreestyle(randFloat(0, 1), 2); this.go2NewAngle(randFloat(0, 1), 2); this.thinkElliptic(); this.centerMouseDelay();", 3.5); }, demoBacteria : function(){ this.demoNone(); activeBtnFromName('demo', 'Bacteria'); this.beCircleAll(randFloat(0, 1), 2); this.goGroupS(randFloat(0, 1), 2); this.zoneS(0, 0); this.delay("this.centerMouseDelay();", 3); this.delay("this.thinkFrenetic(); this.think2Pulsing();", 3.2); }, demoDance : function(){ this.demoNone(); activeBtnFromName('demo', 'Dance'); this.beInvisible(randFloat(0, 1), 2); this.centerMiddle(0, 0); this.delay("this.goGroupM(0, 0);", 2.1); this.delay("this.thinkDancing(); this.think2ShapeShifter();", 3.5); }, demoBubbles : function(){ this.demoNone(); activeBtnFromName('demo', 'Bubbles'); this.goLeft(randFloat(0, 1), 2); this.delay("this.beInvisible(0, 0);", 3.2); this.delay("this.goDown(0, 0); this.beCircleAll(0.2, 0); this.zoneM(0, 0);", 3.4); this.delay("this.thinkUpStream(); this.think2Repulsive(12); this.beCircleAll(randFloat(0, 1), 2)", 5); }, demoMagneticFlux : function(){ this.demoNone(); activeBtnFromName('demo', 'MagneticFlux'); this.zoneS(0, 0); this.goUp(randFloat(0, 1), 2); this.delay("this.bePoint(0, 0); this.pCanvas.changePixelsNumber(300);", 3.1); this.delay("this.goLeft(0, 0);", 5.3); delayAllPixels("this.thinkRightStream(0, 0); this.zoneS(0, 0); this.delay('this.think2Attractive();', 2);", 5.5); }, demoClaustrophobia1 : function(){ this.demoNone(); activeBtnFromName('demo', 'Claustrophobia1'); this.thinkClaustrophobic(); this.centerMouseNoDelay(0, 0); this.zoneL(0, 0); this.delay("this.think2SolidCircles();", 1.5); this.delay("this.beCircleL(randFloat(0, 1), 2);", 1); }, demoClaustrophobia2 : function(){ this.demoNone(); activeBtnFromName('demo', 'Claustrophobia2'); this.thinkClaustrophobic(); this.centerMouseNoDelay(0, 0); this.beBlobS(randFloat(0, 1), 2); this.zoneL(0, 0); this.delay("this.think2Rotative(); this.think2Repulsive(12);", 1.5); }, demoClaustrophobia3 : function(){ this.demoNone(); activeBtnFromName('demo', 'Claustrophobia3'); this.thinkClaustrophobic(); this.centerMouseNoDelay(0, 0); this.beIsoTriangleL(randFloat(0, 1), 2); this.think2Tangencial(); this.zoneM(0, 0); this.delay("this.think2Rotative(); this.think2Repulsive(12); this.think2Tangencial(); this.beIsoTriangleL(randFloat(0, 1), 1);", 1.5); this.delay("this.beIsoTriangleL(randFloat(0, 1), 2);", 3.2); }, demoPlayBalls : function(){ this.demoNone(); activeBtnFromName('demo', 'PlayBalls'); this.thinkClaustrophobic(5); this.centerMouseNoDelay(0, 0); this.beCircleCore(randFloat(0, 1), 2, randInt(10, 40)); this.zoneM(0, 0); this.delay("this.think2Attractive(); this.think2SolidCircles();", 1); }, demoFallingVectors : function(){ this.demoNone(); activeBtnFromName('demo', 'FallingVectors'); this.goDown(randFloat(0, 1), 2); this.delay("this.beInvisible(0, 0);", 3.2); this.delay("this.goDown(0, 0); this.beIsoTriangleM(0.2, 0); this.zoneM(0, 0);", 3.4); this.delay("this.thinkDownStream(); this.think2Repulsive(12); this.think2Tangencial(); this.beIsoTriangleM(0, 1);", 5); this.delay("this.beIsoTriangleM(0, 1);", 6); } });
