From b7cc25ebd7053cea53b71f001af89ba312d25a05 Mon Sep 17 00:00:00 2001
From: Hannah Robertson
Date: Wed, 6 Nov 2024 17:29:10 -0500
Subject: [PATCH] Feat: Add save to yellow scream (#46)
* update details
* add save option
---
projects/yellow-scream/index.html | 8 ++++++--
projects/yellow-scream/sketch.js | 23 ++++++++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/projects/yellow-scream/index.html b/projects/yellow-scream/index.html
index 6f348e5..f4b3bf8 100644
--- a/projects/yellow-scream/index.html
+++ b/projects/yellow-scream/index.html
@@ -25,9 +25,11 @@
Yellow Scream (2024)
+ Save your masterpiece
+ Clear your canvas
Details
- Created while at the Recurse Center , Yellow Scream (2024) is an homage to
+
Yellow Scream (2024) is an homage to
Kim Beom's Yellow Scream
(2012) :
+
Usage: When prompted, grant microphone access, then yell.
- If you are uninterested in yelling (?!?!?!?!), play the above video through your computer speakers.
+ If you are uninterested in yelling (?!?!?!?!), play the above video through your computer speakers. To make the microphone more or less sensitive, adust screamThreshold in the dropdown Parameters window.
+
diff --git a/projects/yellow-scream/sketch.js b/projects/yellow-scream/sketch.js
index ce0c090..7e39fa2 100644
--- a/projects/yellow-scream/sketch.js
+++ b/projects/yellow-scream/sketch.js
@@ -61,7 +61,7 @@ function draw() {
// console.log(vol);
if (vol > params.screamThreshold && !isPainting) {
// Start a stroke
- x = random(width);
+ x = random(windowWidth);
y = random(height);
yellowColor = color(255, 204 + random(-10, 100), 0);
isPainting = true;
@@ -82,3 +82,24 @@ function draw() {
square(x, y, currentbrushWidth, 0);
}
}
+
+function saveMasterpiece() {
+ let cnv = document.getElementById("p5-canvas");
+ let date = new Date().toISOString().split("T")[0];
+ let filename = 'YellowScream-' + date + ".png";
+ saveCanvas(cnv, filename, 'png' );
+}
+
+function getCanvasHeight() {
+ return 1 + windowHeight - document.getElementById("project-body").offsetTop;
+}
+
+function resetCanvas() {
+ let cnv = document.getElementById("p5-canvas");
+
+ let details = document.getElementsByClassName("projects-details")[0];
+ details.open = false;
+
+ resizeCanvas(windowWidth, getCanvasHeight(), cnv);
+ background("#E8E7D7");
+}