Skip to content

Commit

Permalink
Added deform settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-calderwood committed Mar 7, 2024
1 parent fd2ab05 commit e3cc52b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 25 deletions.
15 changes: 15 additions & 0 deletions instrument/html/wiggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@
color: #000;
}

.userInput {
width: 50%; /* Make the button fill the available space */
height: 20%;
margin: 0px;
margin-bottom: 20px;
/* make the border and text white */
color: #fff;
background-color: #000;
border: 1px solid #fff;
padding: 10px;
cursor: pointer; /* Change cursor on hover */
text-align: center;
}

::-webkit-scrollbar { width: 8px; height: 3px;}
::-webkit-scrollbar-button { background-color: #666; }
::-webkit-scrollbar-track { background-color: #646464;}
Expand All @@ -101,6 +115,7 @@
<div class="options">
<button class="submit_button" onclick="openPerformTab()">Perform</button>
<button id="deformButton" class="submit_button" onclick="toggleDeform()">Deform</button>
<input value="5" class="userInput" id="deformRate"">
</div>
<div id="textboxes">
<div class="text" id="free">
Expand Down
60 changes: 35 additions & 25 deletions instrument/js/wiggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ let base_url = 'http://localhost:5000';
let performance; // the performance tab
let expectedOrigin = "https://localhost:8101"

const deformInterval = 1000;
let deformInterval;
let deformRate = 5000;

let library = {
"cutup": "ALL WRITING IS IN FACT CUT UPS OF GAMES AND ECONOMIC BEHAVIOR OVERHEARD? WHAT ELSE? ASSUME THAT THE WORST HAS HAPPENED EXPLICIT AND SUBJECT TO STRATEGY IS AT SOME POINT CLASSICAL PROSE. CUTTING AND REARRANGING FACTOR YOUR OPPONENT WILL GAIN INTRODUCES A NEW DIMENSION YOUR STRATEGY. HOW MANY DISCOVERIES SOUND TO KINESTHETIC? WE CAN NOW PRODUCE ACCIDENT TO HIS COLOR OF VOWELS. AND NEW DIMENSION TO FILMS CUT THE SENSES. THE PLACE OF SAND. GAMBLING SCENES ALL TIMES COLORS TASTING SOUNDS SMELL STREETS OF THE WORLD. WHEN YOU CAN HAVE THE BET ALL: \"POETRY IS FOR EVERYONE\" DOCTOR NEUMAN IN A COLLAGE OF WORDS READ HEARD INTRODUCED THE CUT UP SCISSORS RENDERS THE PROCESS GAME AND MILITARY STRATEGY, VARIATION CLEAR AND ACT ACCORDINGLY. IF YOU POSED ENTIRELY OF REARRANGED CUT DETERMINED BY RANDOM A PAGE OF WRITTEN WORDS NO ADVANTAGE FROM KNOWING INTO WRITER PREDICT THE MOVE. THE CUT VARIATION IMAGES SHIFT SENSE ADVANTAGE IN PROCESSING TO SOUND SIGHT TO SOUND. HAVE BEEN MADE BY ACCIDENT IS WHERE RIMBAUD WAS GOING WITH ORDER THE CUT UPS COULD \"SYSTEMATIC DERANGEMENT\" OF THE GAMBLING SCENE IN WITH A TEA HALLUCINATION: SEEING AND PLACES. CUT BACK. CUT FORMS. REARRANGE THE WORD AND IMAGE TO OTHER FIELDS THAN WRITING.",
Expand Down Expand Up @@ -305,6 +306,8 @@ class SampleView {
this.updateWorder(worder);
this.loc = loc;
this.textS = 16;
this.xSpacing = 140;
this.ySpacing = 15;
this.notePlayed = -1;
}

Expand All @@ -324,10 +327,8 @@ class SampleView {
let visTextSize = 12;
textSize(visTextSize);
let wordIndex = 0;
let xSpacing = 100;
let ySpacing = 15;
for(let j = 0; j < this.loc[3] - this.loc[1]; j += ySpacing) {
for (let i = 0; i < this.loc[2] - this.loc[0]; i += xSpacing) {
for(let j = 0; j < this.loc[3] - this.loc[1]; j += this.ySpacing) {
for (let i = 0; i < this.loc[2] - this.loc[0] - this.xSpacing; i += this.xSpacing) {
if (wordIndex == this.notePlayed) {
fill(255, 0, 0);
} else {
Expand Down Expand Up @@ -879,14 +880,6 @@ function addLineBreak() {
worder.addWordToContext(word);
}

// function playSynth() {
// monoSynth.triggerAttack(note, velocity);
// }

// function offSynth() {
// monoSynth.triggerRelease();
// }


function preload() {
// pass
Expand All @@ -897,14 +890,6 @@ function reset() {
slidyWindow.reset();
}

let doDeform = false;
function toggleDeform() {
doDeform = !doDeform;
// change the class of the button
let button = document.getElementById("deformButton");
button.className = doDeform ? "selected submit_button" : "submit_button";
}
toggleDeform(true);

function getDeformPrompt() {
let topic_verb = "friendship"
Expand All @@ -922,8 +907,20 @@ async function deform() {
if (currentContext.length == 0) {
return;
}
// randomly select one from the list
let index = Math.floor(Math.random() * currentContext.length)

let dontDeformLastLine = true;
let deformLimit = -1;

deformLimit = dontDeformLastLine ? deformLimit : currentContext.length;
if (dontDeformLastLine) {
for (let i = 0; i < currentContext.length; i++) {
if (currentContext[i].word == '\n') deformLimit = i;
}
if (deformLimit === -1) return;
} else {
deformLimit = currentContext.length;
}
let index = Math.floor(Math.random() * deformLimit)
let before = currentContext.slice(0, index);
let word = currentContext[index];
let after = currentContext.slice(index + 1, currentContext.length);
Expand All @@ -940,8 +937,21 @@ async function deform() {
worder.words[word.id] = word;
updatePerformanceWord(word);
}
// while doDeform is true, call it every 3 seconds
setInterval(deform, deformInterval);

let doDeform = false;
function toggleDeform() {
doDeform = !doDeform;
// change the class of the button
let button = document.getElementById("deformButton");
button.className = doDeform ? "selected submit_button" : "submit_button";
deformRate = document.getElementById("deformRate").value * 1000;

clearInterval(deformInterval);
deformInterval = setInterval(deform, deformRate);
}
toggleDeform();



function draw() {
// main draw call
Expand Down

0 comments on commit e3cc52b

Please sign in to comment.