xxxxxxxxxx
128
let all_rectangles = []; //array for negative thoughts - rectangles
let all_ellipses = []; //array for positive thoughts - ellipses
let incrementingspeed = 2; //how fast the shapes will grow
let BadMemoriesFade = false; //as we face the negative situation, by default the bad memories fill up our mind and don't go until we start turning on the light
function setup() {
createCanvas(500, 500);
background(random(100, 255), random(100, 255), random(100, 255)); // represents our mind, clear and bright by default
frameRate(60)
console.log('This canvas represents your mind')
console.log('Life is not life without challenges and troubles')
console.log('And we often concentrate too much on the negative emotions and feelings')
console.log('They grow just like when you press the mouse!')
console.log('But it is important to let go')
console.log('And really appreciate the good things that are happening to you - unpress the mouse')
console.log('You can add positive thoughts by pressing SPACE BAR')
console.log('Try to mix pressing mouse and SPACE BAR, and then let go to see the effect')
for (let i = 0; i < 100; i += 1) {
let emerging_rectangle = { //adding charachteristics of the bad thoughts
x: random(width),
y: random(height),
w: 0,
h: 0,
wLimit: random(20, 400), //random sizes of the shapes
hLimit: random(20, 400),
colorR: random(0, 50), // dark tones for bad thoughts
colorG: random(0, 50),
colorB: random(0, 50),
time: i * 30, // controls the delay
up_vs_down: floor(random(1, 3)) // controls whether the rectangles will grow from top to bottom or vice-versa
};
all_rectangles.push(emerging_rectangle);
}
for (let n = 0; n < 100; n += 1) {
let emerging_ellipse = { //adding characteristics of the good thoughts
x: random(width),
y: random(height),
w: 0,
h: 0,
wLimit: random(20, 400), //random sizes of the shapes
hLimit: random(20, 400),
colorR: random(100, 255), //random bright tones for good thoughts
colorG: random(100, 255),
colorB: random(100, 255),
time: n * 30
};
all_ellipses.push(emerging_ellipse);
}
}
function draw() {
if (mouseIsPressed) {
let width_vs_height = floor(random(1, 3)); // chooses whether width or height of the rectangle will increment
for (let j = 0; j < 100; j += 1) {
let emerging_rectangle = all_rectangles[j]; // takes rectangles for an array one by one
if (frameCount > emerging_rectangle.time) { // delays the emergence of the next rectangle
if (emerging_rectangle.up_vs_down === 1) { // grows down
if (width_vs_height === 1) { // grows in width
if (emerging_rectangle.w < emerging_rectangle.wLimit) {
emerging_rectangle.w += incrementingspeed;
}
} else if (width_vs_height === 2) { // grows in height
if (emerging_rectangle.h < emerging_rectangle.hLimit) {
emerging_rectangle.h += incrementingspeed;
}
}
}
else if (emerging_rectangle.up_vs_down === 2) { //grows up
if (width_vs_height === 1) {
if (emerging_rectangle.w < emerging_rectangle.wLimit) { // grows in width
emerging_rectangle.w -= incrementingspeed;
}
}
else if (width_vs_height === 2) { // grows in height
if (emerging_rectangle.h < emerging_rectangle.hLimit) {
emerging_rectangle.h -= incrementingspeed;
}
}
}
}
fill(emerging_rectangle.colorR, emerging_rectangle.colorG, emerging_rectangle.colorB, random(0, 6)); //random transparency to create the 'waterfall' effect
noStroke();
rect(emerging_rectangle.x, emerging_rectangle.y, emerging_rectangle.w, emerging_rectangle.h);
}
}
if (keyIsPressed && key === ' ') { // all the same but for the ellipses
let width_vs_height = floor(random(1, 3));
for (let j = 0; j < 100; j += 1) {
let emerging_ellipse = all_ellipses[j];
if (frameCount > emerging_ellipse.time) {
if (width_vs_height === 1) {
if (emerging_ellipse.w < emerging_ellipse.wLimit) {
emerging_ellipse.w += incrementingspeed;
}
} else if (width_vs_height === 2) {
if (emerging_ellipse.h < emerging_ellipse.hLimit) {
emerging_ellipse.h += incrementingspeed;
}
}
}
fill(emerging_ellipse.colorR, emerging_ellipse.colorG, emerging_ellipse.colorB, random(0, 6));
noStroke();
ellipse(emerging_ellipse.x, emerging_ellipse.y, emerging_ellipse.w, emerging_ellipse.h);
}
}
if (BadMemoriesFade == true)
filter(DILATE) // by definition increases the light areas, just like we should everyday
}
function mouseReleased() {
BadMemoriesFade = true // once you 'let go' the bad memories, the good ones start to fill your mind
}