Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

549 lines (505 sloc) 14.046 kB
<!DOCTYPE html>
<!-- effects mutated from recursion2 by Casey Reas and Ben Fry -->
<!-- sfx from http://www.soundjay.com/ -->
<!-- assembled together by Filipe Cruz (ps / TPOLM) -->
<html>
<head>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<script LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
if (document.referrer == 'http://pouet.net/prod.php?which=57444') window.location.href = 'index.html';
//dear gloperators, i added link to the root, not demo.html, for a good reason
</script>
<script src="js/processing.js"></script>
<style>
body {
background-color: #D0D0D0;
}
#container {
margin:0 auto;
text-align:center;
}
#ourCanvas {
border: 60px solid purple;
-moz-box-shadow: 5px 5px 4px #000;
-webkit-box-shadow: 5px 5px 4px #000;
box-shadow: 5px 5px 4px #000;
/* For IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#000000')";
}
</style>
</head>
<body>
<div id="container">
<script type="application/processing">
float drawCounter = 0;
float drawInterval = 300;
float iterationCounter = 0;
float iterationInterval = 5000;
//ArrayList texs;
PImage logo;
ArrayList sounds;
int partCounter = 2;
int sudCounter = 0;
//float startMillis;
var filetype = '.wav';
if (navigator.appName == 'Microsoft Internet Explorer') filetype = '.mp3';
var ourCanvas = document.getElementById('ourCanvas');
changeBorder();
void setup() {
size(500, 500);
background(255);
noStroke();
smooth();
/*texs = new ArrayList();
for (i=1; i<=4; i++) {
PImage tex;
tex = loadImage("tex/"+i+".png");
texs.add(tex);
}*/
logo = loadImage("tex/ma.png");
sounds = new ArrayList();
doCircle();
sudCounter = 0;
float m = millis();
iterationCounter = m;
drawCounter = m;
playSound();
}
void draw() {
float m = millis();
if (m > iterationCounter + iterationInterval) {
iterationCounter = m;
clearSoundBuffer();
doCircle();
} else if (m > drawCounter + drawInterval) {
drawCounter = m;
playSound();
}
}
function changeBorder() {
var d = new Date();
switch (d.getUTCDate()%10) {
case 0:
ourCanvas.style.borderColor = 'blue';
break;
case 1:
ourCanvas.style.borderColor = 'red';
break;
case 2:
ourCanvas.style.borderColor = 'purple';
break;
case 3:
ourCanvas.style.borderColor = 'steelblue';
break;
case 4:
ourCanvas.style.borderColor = 'green';
break;
case 5:
ourCanvas.style.borderColor = 'brown';
break;
case 6:
ourCanvas.style.borderColor = 'darkolivegreen';
break;
case 7:
ourCanvas.style.borderColor = 'darkorange';
break;
case 8:
ourCanvas.style.borderColor = 'teal';
break;
case 9:
ourCanvas.style.borderColor = 'indianred';
break;
}
}
function doCircle() {
fill(255);
noStroke();
rect(0, 0, 500, 500);
//image(texs.get(0),0,0);
sudCounter++;
if (sudCounter >= 4)
{
sudCounter = 0;
partCounter++;
}
//unused
// drawCircle5(250, 250, 200, 9);
// drawCircle7(250, 250, 220, 8);
// drawCircle8(250, 250, 220, 9);
// drawCircle10(250, 250, 220, 9);
switch(partCounter) {
/*case 1:
noStroke();
drawCircle1(250, 250, 220, 6);
break;*/
case 2:
drawCircle3(250, 250, 220, 6);
break;
case 3:
noStroke();
drawCircle2(250, 250, 220, 8);
break;
case 4:
drawCircle4(250, 250, 220, 8);
break;
case 5:
drawCircle6(250, 250, 220, 8);
break;
case 6:
drawCircle9(250, 250, 220, 8);
break;
case 7:
drawCircle12(250, 250, 120, 8);
break;
case 8:
drawCircle11(250, 250, 220, 8);
break;
default:
image(logo,0,0);
break;
}
}
void drawCircle13(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%2 == 0) tt = ((126 * level/6.0) - negative);
else tt = ( negative - (126 * level/6.0));
fill(30,30,tt, 32);
if ((level+1)%3 == 0) {
noStroke();
ellipse(x, y, radius*2, radius*2);
}
stroke( 126 * level / 7.0, 40);
if (level%3 > 1) bufferSound(28+level*tt%3,16+tt%2);
if(level > 1) {
level = level - 1;
int num;
if num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 12.0 * level;
float ny = y + sin(a) * 12.0 * level;
if (level > 4) drawCircle13(nx, ny, radius, level);
else if (level > int(random(3, 7))) drawCircle13(nx, ny, radius/2, level);
else drawCircle2(nx, ny, radius/2, level);
}
}
}
void drawCircle12(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%2 == 0) tt = ((126 * level/6.0) - negative);
else tt = ( negative - (126 * level/6.0));
stroke(tt, negative, tt, 120);
fill(negative+30, 12);
if (level%4 == 0) ellipse(x, y, radius*2, radius*2);
if (level%3) bufferSound(30+level*tt%3,17);
if(level > 1) {
level = level - 1;
int num = int(random(2, 6));
int outradius;
if (level%2) outradius = radius*0.2;
else outradius = radius*1.8;
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 10.0 * level;
float ny = y + sin(a) * 8.0 * level;
line(x,y,nx,ny);
if (level > int(random(3, 7))) drawCircle12(nx, ny, outradius, level);
else drawCircle13(nx, ny, radius/2, level); }
}
}
void drawCircle11(float x, float y, int radius, int level)
{
tt = (126 * level/6.0);
fill(tt, 22);
if ((level+2)%3 > 1) {
noStroke();
ellipse(x, y, radius*2, radius*2);
}
stroke( 126 * level / 7.0, 40);
strokeWeight(int(random(1, 4)));
if (level%3 > 1) bufferSound(24+tt%2,3+tt%4);
if(level > 1) {
level = level - 1;
int num;
if num = int(random(2, 5));
int outradius;
if (level%2) outradius = radius*0.2;
else outradius = radius*1.8;
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 16.0 * level;
float ny = y + sin(a) * 16.0 * level;
line(x,y,nx,ny);
if (level > int(random(3, 7))) drawCircle11(nx, ny, outradius, level);
else drawCircle7(nx, ny, radius/2, level);
}
}
}
void drawCircle10(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%3 == 0) tt = ((126 * level/8.0) - negative);
else tt = ( negative - (126 * level/6.0));
fill(tt, 32);
if ((level+1)%3 == 0) {
noStroke();
ellipse(x, y, radius*2, radius*2);
}
stroke( 126 * level / 7.0, 40);
if (level%3 > 1) bufferSound(24+tt%2,0);
if(level > 1) {
level = level - 1;
int num;
if num = int(random(2, 4));
int outradius;
if (level%2) outradius = radius*0.2;
else outradius = radius*1.8;
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 8.0 * level;
float ny = y + sin(a) * 8.0 * level;
if (level > 5) drawCircle10(nx, ny, outradius, level);
else drawCircle4(nx, ny, radius/2, level);
}
}
}
void drawCircle9(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%3 == 0) tt = ((126 * level/8.0) - negative);
else tt = ( negative - (126 * level/6.0));
fill(tt, 32);
if ((level+1)%3 == 0) {
noStroke();
ellipse(x, y, radius*2, radius*2);
}
stroke( 126 * level / 7.0, 40);
if (level%3 > 1) bufferSound(24+tt%2,0);
if(level > 1) {
level = level - 1;
int num;
if num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 8.0 * level;
float ny = y + sin(a) * 8.0 * level;
if (level > 4) drawCircle9(nx, ny, radius/2, level);
else drawCircle1(nx, ny, radius/2, level);
}
}
}
void drawCircle8(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%2 == 0) tt = ((126 * level/6.0) - negative);
else tt = ( negative - (126 * level/6.0));
fill(30,30,tt, 32);
if ((level+1)%3 == 0) {
noStroke();
ellipse(x, y, radius*2, radius*2);
}
stroke( 126 * level / 7.0, 40);
if (level%3 > 1) bufferSound(24+level*tt%3,12+tt%2);
if(level > 1) {
level = level - 1;
int num;
if num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 12.0 * level;
float ny = y + sin(a) * 12.0 * level;
if (level > 4) drawCircle8(nx, ny, radius/2, level);
else drawCircle3(nx, ny, radius/2, level);
}
}
}
void drawCircle7(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%2 == 0) tt = ((126 * level/6.0) - negative);
else tt = ( negative - (126 * level/6.0));
fill(30,30,tt, 32);
if ((level+2)%3 == 0) {
noStroke();
ellipse(x, y, radius*2, radius*2);
}
stroke( 126 * level / 7.0, 40);
if (level%3 > 0) bufferSound(24+level*tt%3,12+tt%2);
if(level > 1) {
level = level - 1;
int num;
if (level % 2 == 0) num = int(random(2, 4));
else num = int(random(2, 10));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 12.0 * level;
float ny = y + sin(a) * 12.0 * level;
if (level > 4) drawCircle7(nx, ny, radius/2, level);
else drawCircle4(nx, ny, radius/2, level);
}
}
}
void drawCircle6(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%2 == 0) tt = ((126 * level/6.0) - negative);
else tt = ( negative - (126 * level/6.0));
fill(30,30,tt, 32);
if ((level+2)%3 == 0) {
noStroke();
ellipse(x, y, radius*2, radius*2);
}
stroke( 126 * level / 7.0, 40);
if (level%3 > 0) bufferSound(20+level*tt%3,2+tt%2);
if(level > 1) {
level = level - 1;
int num;
if (level % 2 == 0) num = int(random(2, 4));
else num = int(random(2, 10));
strokeWeight(level-num);
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 12.0 * level;
float ny = y + sin(a) * 12.0 * level;
line(x,y,nx,ny);
drawCircle6(nx, ny, radius/2, level);
}
}
}
void drawCircle5(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%2 == 0) tt = ((126 * level/6.0) - negative);
else tt = ( negative - (126 * level/6.0));
stroke(tt, negative, tt, 120);
fill(negative+30, 12);
if (level%4 == 0) ellipse(x, y, radius*2, radius*2);
if (level%3) bufferSound(30+level*tt%3,0);
if(level > 1) {
level = level - 1;
int num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 10.0 * level;
float ny = y + sin(a) * 8.0 * level;
line(x,y,nx,ny);
drawCircle5(nx, ny, radius/2, level);
}
}
}
void drawCircle4(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt;
if (drawCounter%2 == 0) tt = ((126 * level/6.0) - negative);
else tt = ( negative - (126 * level/6.0));
stroke(tt, negative, tt, 120);
fill(255, tt, negative+10, 125);
//fill(125,125);
if (level%2 == 0) {
ellipse(x, y, radius*2, radius*2);
}
if (level>=3) bufferSound(15+level+negative%4, 2);
if(level > 1) {
level = level - 1;
int num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 8.0 * level;
float ny = y + sin(a) * 9.0 * level;
line(x,y,nx,ny);
drawCircle4(nx, ny, radius/2, level);
}
}
}
void drawCircle3(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt = (negative - (126 * level/6.0));
stroke(negative,120);
if (level>=5) bufferSound(19, 6);
if(level > 1) {
level = level - 1;
int num = int(random(2, 7));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 18.0 * level;
float ny = y + sin(a) * 18.0 * level;
line(x,y,nx,ny);
drawCircle3(nx, ny, radius/2, level);
}
}
}
void drawCircle2(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt = (negative - (126 * level/6.0));
fill(tt, 0, negative-tt, negative*.5);
ellipse(x, y, radius*2, radius*2);
if (level%2 == 0) bufferSound(radius*.5+y, level);
if(level > 1) {
level = level - 1;
int num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 15.0 * level;
float ny = y + sin(a) * 15.0 * level;
drawCircle2(nx, ny, radius/2, level);
}
}
}
void drawCircle1(float x, float y, int radius, int level)
{
int negative = 155*(level%2);
float tt = (negative - (126 * level/6.0));
fill(tt, tt, tt, negative*.5);
ellipse(x, y, radius*2, radius*2);
bufferSound(radius, level);
if(level > 1) {
level = level - 1;
int num = int(random(2, 6));
for(int i=0; i<num; i++) {
float a = random(0, TWO_PI);
float nx = x + cos(a) * 12.0 * level;
float ny = y + sin(a) * 12.0 * level;
drawCircle1(nx, ny, radius/2, level);
}
}
}
void bufferSound(radius, level) {
if ((level % 2) == 0) {
sounds.add("sfx/button-"+(int)(radius%50)+""+filetype);
} else {
sounds.add("sfx/beep-"+(int)(radius%30)+""+filetype);
}
}
void playSound() {
if (sounds.size() > 0) {
var filename = sounds.get(0);
var snd = new Audio(filename);
snd.play();
sounds.remove(0);
}
}
void clearSoundBuffer() {
for (int i = sounds.size()-1; i >= 0; i--) {
sounds.remove(i);
}
sounds = new ArrayList();
}
</script>
<canvas id="ourCanvas" width="500" height="500">a browser with canvas support would be nice</canvas>
<!--<div style="height:0px;width:0px;overflow:hidden;"></div>-->
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.