/* * Here are some things you can edit */ const colorBack = "#e3eded"; const colorFront = "#199cff"; const colorLines = "#000090"; /* * do not edit this rest of this file, instead edit the letter * drawing code in draw_letters.js */ const canvasWidth = 960; const canvasHeight = 500; // these variables are used for animation let soloCurLetter = "B"; let soloLastLetter = "A" let soloPrevObj = alphabet["default"]; let soloIsAnimating = false; let soloNumAnimationFrames = 30; let soloCurAnimationFrame = 0; // Handy string of all letters available const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?"; let chosenLetters = []; let chosenPrevObjs = [null, null, null, null, null, null, null, null]; let chosenIsAnimating = [false, false, false, false, false, false, false, false]; let chosenNumAnimationFrames = 30; let chosenCurAnimationFrame = [0, 0, 0, 0, 0, 0, 0, 0]; let curChosenLetter = 0; let lastKeyPressedTime; let secondsUntilSwapMode = 15; let lastWordSwappedTime; let isSwappingWords = true; let secondsPerWord = 8; let curSwapWord = 0; var defaultSwapWords = [ "ACTUALLY", "1234567?", "EXPECTED", "PROPERTY", "ADDITION", "FOLLOWED", "PROVIDED", "ALTHOUGH", "HAPPENED", "QUESTION", "AMERICAN", "INCREASE", "RECEIVED", "ANYTHING", "INDUSTRY", "RELIGION", "BUILDING", "INTEREST", "REMEMBER", "BUSINESS", "INVOLVED", "REQUIRED", "CHILDREN", "NATIONAL", "SERVICES", "COMPLETE", "ORGANIZE", "SOUTHERN", "CONSIDER", "PERSONAL", "STANDARD", "CONTINUE", "PLANNING", "STRENGTH", "ALPHABET", "POSITION", "STUDENTS", "DECISION", "POSSIBLE", "SUDDENLY", "DIRECTLY", "PRESSURE", "THINKING", "DISTRICT", "PROBABLY", "TOGETHER", "ECONOMIC", "PROBLEMS", "TRAINING", "EVIDENCE", "PROGRAMS" ] const interpolation_is_on = (typeof interpolate_letter === "function") function setup () { // create the drawing canvas, save the canvas element main_canvas = createCanvas(canvasWidth, canvasHeight); main_canvas.parent('canvasContainer'); let now = millis(); lastKeyPressedTime = now; lastWordSwappedTime = now; if (typeof swapWords === 'undefined') { // the variable is defined swapWords = []; } swapWords = swapWords.concat(defaultSwapWords); chosenLetters = []; let first_word = swapWords[0]; for(let i=0; i= chosenNumAnimationFrames) { chosenIsAnimating[i] = false; } // if we are animating, increment the number of animation frames if(chosenIsAnimating[i]) { chosenCurAnimationFrame[i] = chosenCurAnimationFrame[i] + 1; } var obj = computeCurrentChosenChar(i); drawFromDataObject(o + i*w2/8.0, o + h2/2.0 - 120, 1.0, obj) } } function swapExhibitLetter(n, c, frameDelay) { chosenPrevObjs[n] = computeCurrentChosenChar(n); chosenLetters[n] = c; chosenIsAnimating[n] = true; chosenCurAnimationFrame[n] = 0 - frameDelay; } function keyTyped() { if (key == '!') { saveBlocksImages(); } else if (key == '@') { saveBlocksImages(true); } else { lastKeyPressedTime = millis(); if(isSwappingWords) { isSwappingWords = false; } upper_key = key.toUpperCase(); swapExhibitLetter(curChosenLetter, upper_key, 0); curChosenLetter = (curChosenLetter + 1) % 8; } }