xxxxxxxxxx
// Blurs Constants (ignore the names, they are confusing)
blue_blur1 = 0; blue_blur2 = 0; blue_blur3 = 0; stop_count = 40;
blue_blur4 = 0; up_burst = false; up_burst_d = false;
pur_blur1 = 0; pur_count = 0; or_blur1 = 0; or_blur2 = 0;
or1 = 100; or2 = 300; or3 = 300; or4 = 100;
let red_blur = []; let fl_blur1 = []; fl_angle = 270;
// Swirl
myRad = 0; let swirls = []; sw_size = 100; sw_spin = 0;
sw_size2 = 0; myRad2 = 0; sw_count = 0; sw_d = false;
// Swiggle
count = 0; swiggleHeight = 200; LswiggleHeight = 100; Lcount = 0;
// Loading Music
let Sample0
let Sample1
let Sample2
let Sample3
var vol0 = 0.001;
var vol1 = 0.001;
var vol2 = 0.001;
var vol3 = 0.001;
function setup() {
createCanvas(400, 400);
background(0);
xy = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
xy2 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
xy3 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
lxy = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
lxy2 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
lxy3 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
//FROM HERE DOWN :PPPPPPPPPPPPPPPPPP
soundFormats('mp3');
Sample0 = createAudio('Drums.mp3');
Sample1 = createAudio('Bass.mp3');
Sample2 = createAudio('Horns.mp3');
Sample3 = createAudio('Piano.mp3');
Sample0.loop();
Sample1.loop();
Sample2.loop();
Sample3.loop();
}
function draw() {
background(0);
// BURSTS OF COLOR
leftBurst();
rightBurst();
upBurst();
downBurst();
// SWIRLS
swirlUpDown();
swirlUpRight();
// SWIGGLES
swiggleDownRight();
swiggleUpLeft();
// MUSIC
if (keyIsDown(38) && vol0 < 0.999) // up
vol0 += 0.001;
else if (0.001 < vol0)
vol0 -= 0.001;
if (keyIsDown(40) && vol1 < 0.999) // down
vol1 += 0.001;
else if (0.001 < vol1)
vol1 -= 0.001;
if (keyIsDown(37) && vol2 < 0.999) // left
vol2 += 0.001;
else if (0.001 < vol2)
vol2 -= 0.001;
if (keyIsDown(39) && vol3 < 0.999) //right
vol3 += 0.001;
else if (0.001 < vol3)
vol3 -= 0.001;
Sample0.volume(vol0);
Sample1.volume(vol1);
Sample2.volume(vol2);
Sample3.volume(vol3);
}
function upBurst(){
if (keyIsDown(38) || vol0 > 0.05) { // UP Blue
up_burst = true;
}
else
up_burst = false;
// makes four bursts grow and shrink
if (up_burst == true || blue_blur1 > 0){
if (blue_blur1 == 40)
up_burst_d = true;
if (blue_blur1 == 0)
up_burst_d = false;
if (up_burst_d == false){
blue_blur1++;
blue_blur4++; }
else{
blue_blur1--;
blue_blur4--; }
if (up_burst_d == true){
blue_blur2++;
blue_blur3++; }
else if (blue_blur2 > 0){
blue_blur2--;
blue_blur3--; }
circleBlur(100, 190, 250, 50, 50, 1, blue_blur1);
circleBlur(100, 190, 250, 350, 50, 1, blue_blur2);
circleBlur(100, 190, 250, 50, 350, 1, blue_blur3);
circleBlur(100, 190, 250, 350, 350, 1, blue_blur4);
}
// completes the cycle
else if (blue_blur2 > 0){
if (stop_count > 0){
blue_blur2--;
blue_blur3--;
circleBlur(100, 190, 250, 350, 50, 1, blue_blur2);
circleBlur(100, 190, 250, 50, 350, 1, blue_blur3);
stop_count--;
}
if (stop_count == 0){
stop_count = 40;
}
}
}
function downBurst(){
if (keyIsDown(40) || pur_count > 0){
if (pur_count < 50){
pur_blur1 += 2;
pur_count++;
}
else if (pur_blur1>0){
pur_blur1 -= 2;
pur_count++;
}
else{
pur_count = 0;
}
if (pur_count > 40 && pur_count < 70){
or_blur1++;
}
else if (or_blur1 > 0){
or_blur1--;
}
if (pur_count == 0){
or1 = int(random(400)); or2 = int(random(400));
or1 = int(random(400)); or2 = int(random(400));
}
circleBlur(70, 0, 100, 200, 200, 1, pur_blur1);
circleBlur(100, 40, 100, or1, or4, 1, or_blur1);
circleBlur(100, 40, 100, or2, or1, 1, or_blur1);
circleBlur(100, 40, 100, or3, or2, 1, or_blur1);
circleBlur(100, 40, 100, or4, or3, 1, or_blur1);
}
else if (vol1 > 0.01){
if (pur_count < 50){
pur_blur1 += 2;
pur_count++;
}
else if (pur_blur1>0){
pur_blur1 -= 2;
pur_count++;
}
else{
pur_count = 0;
}
if (pur_count > 40 && pur_count < 70){
or_blur1++;
}
else if (or_blur1 > 0){
or_blur1--;
}
if (pur_count == 0){
or1 = int(random(400)); or2 = int(random(400));
or1 = int(random(400)); or2 = int(random(400));
}
circleBlur(70, 0, 100, 200, 200, 1, pur_blur1);
circleBlur(100, 40, 100, or1, or4, 1, or_blur1);
circleBlur(100, 40, 100, or2, or1, 1, or_blur1);
circleBlur(100, 40, 100, or3, or2, 1, or_blur1);
circleBlur(100, 40, 100, or4, or3, 1, or_blur1);
}
}
function rightBurst(){
if (keyIsDown(39)){
if (int(random(10)) == 1){
red_blur.push(int(random(400)));}
for (var i = 0; i < red_blur.length - 1; i++){
circleBlur(210, 200, 80, red_blur[i],
red_blur[i+1], 1, 20);
}
}
else{
for (var j = 0; j < red_blur.length - 1; j++){
circleBlur(210, 200, 80, red_blur[j],
red_blur[j+1], 1, 20);
}
if (int(random(10)) == 1 || vol3 < 0.05){
red_blur.pop();}
}
}
function leftBurst(){
if (keyIsDown(37)){
if (fl_angle < 361){
fl_blur1.push(fl_angle);
fl_angle++;
}
for (var i = 0; i < fl_blur1.length; i++){
push();
translate(-40, -40);
petal(fl_blur1[i]);
pop();
push();
translate(440, 440);
rotate(PI);
petal(fl_blur1[i]);
pop();
}
}
else {
fl_blur1.pop();
for (var j = 0; j < fl_blur1.length; j++){
push();
translate(-40, -40);
petal(fl_blur1[j]);
pop();
push();
translate(440, 440);
rotate(PI);
petal(fl_blur1[j]);
pop();
}
if (fl_angle > 270){
fl_angle--;
}
}
}
function petal(angle){
noFill();
var size = 80;
c = [100, 10, 20, 10];
stroke(c);
strokeWeight(size);
rotate(radians(angle))
ellipse(0, size*3, size/4, size*4);
}
function swirlUpDown(){
if (keyIsDown(38) && keyIsDown(40)){
s = int(random(100));
if (s == 1 && swirls.length < 20){
swirls.push(int(random(400)));
swirls.push(int(random(400)));
}
for (var i = 0; i < swirls.length - 1; i++){
swirl(swirls[i], swirls[i + 1], 1, 100, 50, 0, 100, myRad);
}
myRad += PI/24;
}
else if (swirls.length>0) {
for (var j = 0; j < swirls.length - 1; j++){
swirl(swirls[j], swirls[j + 1], 1, sw_size, 50, 0, 100, myRad);
}
myRad += PI/24;
if (sw_size > 0)
sw_size--;
if (sw_size == 0){
swirls.pop();
}
if (swirls.length == 0){
sw_size = 100;
}
}
}
function swirlUpRight(){
if (keyIsDown(38) && keyIsDown(39)){
push();
translate(200, 200);
rotate(sw_spin);
swirl(-75, -75, 1, sw_size2, 10, 70, 50, myRad2);
swirl(75, -75, 1, sw_size2, 10, 70, 50, myRad2);
swirl(-75, 75, 1, sw_size2, 10, 70, 50, myRad2);
swirl(75, 75, 1, sw_size2, 10, 70, 50, myRad2);
pop();
myRad2 += PI/24;
sw_spin+= PI/192;
if (sw_count == 0)
sw_d = false;
else if (sw_count == 150)
sw_d = true;
if (sw_d == false){
sw_count++;
sw_size2++;}
else if (sw_size2 > 0){
sw_count--;
sw_size2--;}
if (sw_size2 == 0)
sw_count = 0;
}
else if (sw_size2 > 0){
sw_size2--;
sw_count = 0;
push();
translate(200, 200);
rotate(sw_spin);
swirl(-75, -75, 1, sw_size2, 10, 70, 50, myRad2);
swirl(75, -75, 1, sw_size2, 10, 70, 50, myRad2);
swirl(-75, 75, 1, sw_size2, 10, 70, 50, myRad2);
swirl(75, 75, 1, sw_size2, 10, 70, 50, myRad2);
pop();
}
}
function swiggleDownRight(){
push();
stroke(150, 100, 50, 200);
if (keyIsDown(40) && keyIsDown(39)){
movingSwiggle(xy, 3, -150, swiggleHeight);
movingSwiggle(xy2, 3, -300, swiggleHeight);
movingSwiggle(xy3, 3, -450, swiggleHeight);
count++;
if (xy3[0]>850){
xy = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
xy2 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
xy3 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
count = 0;
swiggleHeight = int(random(400));
}
}
else if (xy3[0] < 850 && count > 0) {
movingSwiggle(xy, 3, -150, swiggleHeight);
movingSwiggle(xy2, 3, -300, swiggleHeight);
movingSwiggle(xy3, 3, -450, swiggleHeight);
count++;
}
pop();
}
function swiggleUpLeft(){
push();
stroke(120, 80, 150, 200);
if (keyIsDown(38) && keyIsDown(37)){
movingSwiggleL(lxy, 3, -150, LswiggleHeight);
movingSwiggleL(lxy2, 3, -300, LswiggleHeight);
movingSwiggleL(lxy3, 3, -450, LswiggleHeight);
Lcount++;
if (lxy3[0]>850){
lxy = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
lxy2 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
lxy3 = [0, 50, 25, 0, 50, 0,
100, 50, 125, 50, 150, 0];
Lcount = 0;
LswiggleHeight = int(random(400));
}
}
else if (lxy3[0] < 850 && Lcount > 0) {
movingSwiggleL(lxy, 3, -150, LswiggleHeight);
movingSwiggleL(lxy2, 3, -300, LswiggleHeight);
movingSwiggleL(lxy3, 3, -450, LswiggleHeight);
Lcount++;
}
pop();
}
function swiggle(xy, size, transX, transY){
push();
translate(transX, transY);
strokeWeight(size);
noFill();
beginShape();
curveVertex(xy[0], xy[1]);
curveVertex(xy[0], xy[1]);
curveVertex(xy[2], xy[3]);
curveVertex(xy[4], xy[5]);
curveVertex(xy[6], xy[7]);
curveVertex(xy[8], xy[9]);
curveVertex(xy[10], xy[11]);
curveVertex(xy[10], xy[11]);
endShape();
pop();
}
function movingSwiggle(xy, size, transX, transY){
swiggle(xy, size, transX, transY);
swiggle(xy, size, transX + 15, transY + 15);
swiggle(xy, size, transX + 30, transY + 30);
if (count < 50){
xy[1]--; xy[7]--; xy[9]--;
xy[3]++; xy[5]++; xy[11]++;
}
else if (count < 100){
xy[1]++; xy[7]++; xy[9]++;
xy[3]--; xy[5]--; xy[11]--;
}
if (count == 100) {
xy[1]--; xy[7]--; xy[9]--;
xy[3]++; xy[5]++; xy[11]++;
count = 0;
}
for (var i = 0; i <=10; i+=2){
xy[i]+=2;
}
}
function movingSwiggleL(xy, size, transX, transY){
swiggle(xy, size, transX, transY);
swiggle(xy, size, transX + 15, transY + 15);
swiggle(xy, size, transX + 30, transY + 30);
if (Lcount < 50){
xy[1]--; xy[7]--; xy[9]--;
xy[3]++; xy[5]++; xy[11]++;
}
else if (Lcount < 100){
xy[1]++; xy[7]++; xy[9]++;
xy[3]--; xy[5]--; xy[11]--;
}
if (Lcount == 100) {
xy[1]--; xy[7]--; xy[9]--;
xy[3]++; xy[5]++; xy[11]++;
Lcount = 0;
}
for (var i = 0; i <=10; i+=2){
xy[i]+=2;
}
}
function swirl(x, y, radius, spiralSize, R, G, B, myRad){
noFill();
var angleStep = TWO_PI / 200;
var angle = 0;
sX1 = 0; sY1 = 0;
stroke(R, G, B);
strokeWeight(3);
push();
translate(x, y);
rotate(myRad);
beginShape();
vertex(sX1, sY1);
for (var i = 0; i < spiralSize * 2; i++){
sX2 = sX1 + radius * cos(angle);
sY2 = sY1 + radius * sin(angle);
sX3 = sX1 + radius * cos(angle + angleStep/2);
sY3 = sY1 + radius * sin(angle + angleStep/2);
sX4 = sX1 + radius * cos(angle + angleStep);
sY4 = sY1 + radius * sin(angle + angleStep);
bezierVertex(sX2, sY2, sX3, sY3, sX4, sY4);
angle += angleStep;
radius += 0.1;
}
endShape();
pop();
}
function circleBlur(R, G, B, x, y, diameter, blur){
d = diameter;
fill(R, G, B, 20);
noStroke();
for (var i = 0; i<=blur/2; i++){
circle(x, y, d);
d+=5;
}
}