|
|
|
var canvasWidth = 960; |
|
var canvasHeight = 860; |
|
var letterArray = []; |
|
|
|
var easing = 0.05; |
|
|
|
// The number of points that are "On" in the current letter (active pixels) |
|
var numPoints = 0; |
|
// How detailed the sketch for the letters are |
|
var detail = 0; |
|
// Size of the font |
|
var pxlSize = 10; |
|
|
|
// For holding the letters as they are generated for click display for single letter mode and alphabet and write modes |
|
var letterHolderSingle = []; |
|
var letterHolderAlphabet = []; |
|
var letterHolderWord = []; |
|
|
|
|
|
// State toggles |
|
var currState = 0; // 0 = none, 1 = Single Letter mode (interactive), 2 = Alphabetic Grid Mode, 3 = word interaction |
|
|
|
// Data sets for instructions and alphabet display |
|
var singleInstruct; |
|
var alphabetInstruct; |
|
var wordInstruct; |
|
var instSize; |
|
|
|
// Variables for currState 3, writing your own words |
|
var startXWord; |
|
var startYWord; |
|
var nextLetter; |
|
var prevLetter; |
|
var nextLine; |
|
var pointerX; |
|
var pointerY; |
|
|
|
var targetMax = 10; |
|
var targetMin = 3; |
|
var direction = true; |
|
var lsize = 1; |
|
// TIme variable for instruction character growth |
|
var timeA; |
|
var timeB; |
|
// Time variables for color growth |
|
var timeC1; |
|
var timeC2; |
|
|
|
// Color Variables |
|
var c1,c2,c3,c4,cCount,cDirection; |
|
|
|
|
|
|
|
|
|
// Style 1 = to create a Stylised 8-Bit letters alphabet |
|
// Consists of a 4 X 5 Grid. IMages are in the Images folder for reference. |
|
// Each point is either on or off and populated into an array for display |
|
// Just using A B C for this example. If I like it I will develop it more |
|
|
|
function setup () { |
|
// create the drawing canvas, save the canvas element |
|
main_canvas = createCanvas(canvasWidth, canvasHeight); |
|
|
|
//Starts the word in the center for currState 3, word writer if no mouse clicked |
|
startXWord = 150; |
|
startYWord = canvasHeight/2; |
|
nextLetter = 0; |
|
pointerX = startXWord; |
|
pointerY = startYWord; |
|
|
|
// Time variables |
|
timeA = millis(); |
|
|
|
timeC1 = millis(); |
|
|
|
// Color variables for pulse |
|
c1 = 190; |
|
c2 = 93; |
|
c3 = 239; |
|
c4 = 200; |
|
cCount = 0; |
|
cDirection = true; |
|
|
|
// rotation in degrees (more slider friendly) |
|
angleMode(DEGREES); |
|
|
|
instSize = 5; |
|
|
|
// populating instructions and alphabet |
|
singleInstruct = 'PRESS ANY CHARACTER'.split(''); |
|
alphabetInstruct = 'THE FULL CHARACTER SET'.split(''); |
|
wordInstruct = 'CLICK ANYWHERE THEN WRITE'.split(''); |
|
alphabetDisplay = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'.split(''); |
|
|
|
|
|
// creates and populates a 4 X 5 array with null values to be populated later |
|
for(var i = 0; i < 5; i++){ |
|
letterArray[i] = []; |
|
for(var j = 0; j < 4; j++){ |
|
letterArray[i][j] = null; |
|
} |
|
} |
|
|
|
rectMode(CENTER); |
|
|
|
|
|
sel = createSelect(); |
|
sel.option('Alphabet Grid'); |
|
sel.option('Alphabet Silhouette'); |
|
sel.option('Single Letter Mode'); |
|
sel.option('Write Mode'); |
|
sel.changed(dropDownChooser); |
|
|
|
// position each element on the page |
|
main_canvas.parent('canvasContainer'); |
|
|
|
sel.parent(selectorContainer); |
|
|
|
} |
|
|
|
// Populates the letter array based on the input received |
|
function populateLetterArray(item){ |
|
|
|
|
|
switch(item) { |
|
case("A"): |
|
letterArray[0][0] = 0; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("B"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("C"): |
|
letterArray[0][0] = 0; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("D"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("E"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("F"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("G"): |
|
letterArray[0][0] = 0; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("H"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("I"): |
|
letterArray[0][0] = 0; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("J"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("K"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("L"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("M"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 1; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("N"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 1; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("O"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("P"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("Q"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("R"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("S"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("T"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("U"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("V"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("W"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 1; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("X"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 1; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 1; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("Y"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("Z"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 1; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("0"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 1; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("1"): |
|
letterArray[0][0] = 0; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 1; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("2"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("3"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("4"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 1; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 1; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 0; |
|
break; |
|
case("5"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("6"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("7"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("8"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 1; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
case("9"): |
|
letterArray[0][0] = 1; |
|
letterArray[0][1] = 1; |
|
letterArray[0][2] = 1; |
|
letterArray[0][3] = 1; |
|
letterArray[1][0] = 1; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 1; |
|
letterArray[2][0] = 1; |
|
letterArray[2][1] = 1; |
|
letterArray[2][2] = 1; |
|
letterArray[2][3] = 1; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 1; |
|
letterArray[4][0] = 0; |
|
letterArray[4][1] = 0; |
|
letterArray[4][2] = 0; |
|
letterArray[4][3] = 1; |
|
break; |
|
case(" "): |
|
letterArray[0][0] = 0; |
|
letterArray[0][1] = 0; |
|
letterArray[0][2] = 0; |
|
letterArray[0][3] = 0; |
|
letterArray[1][0] = 0; |
|
letterArray[1][1] = 0; |
|
letterArray[1][2] = 0; |
|
letterArray[1][3] = 0; |
|
letterArray[2][0] = 0; |
|
letterArray[2][1] = 0; |
|
letterArray[2][2] = 0; |
|
letterArray[2][3] = 0; |
|
letterArray[3][0] = 0; |
|
letterArray[3][1] = 0; |
|
letterArray[3][2] = 0; |
|
letterArray[3][3] = 0; |
|
letterArray[4][0] = 1; |
|
letterArray[4][1] = 1; |
|
letterArray[4][2] = 1; |
|
letterArray[4][3] = 1; |
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
// Function to write the instructions to the screen based on the screen chosen |
|
function writeInstructions(){ |
|
|
|
|
|
if(currState == 1){ |
|
for(var i = 0; i <= singleInstruct.length-1; i++){ |
|
timeB = millis(); |
|
|
|
if(timeB - timeA > 50){ |
|
timeA = millis(); |
|
if(direction){ |
|
lsize+=lsize*easing; |
|
if(lsize>targetMax){ |
|
direction = false; |
|
} |
|
} else { |
|
lsize-=lsize*easing; |
|
if(lsize<targetMin){ |
|
direction = true; |
|
} |
|
} |
|
} |
|
|
|
populateLetterArray(singleInstruct[i]); |
|
this.letterTemp = new aLetter(10+(i*(lsize*5)), 700, lsize); |
|
this.letterTemp.populateArray(); |
|
this.letterTemp.display(); |
|
} |
|
|
|
} |
|
|
|
if(currState == 2 || currState == 4){ |
|
for(var i = 0; i <= alphabetInstruct.length-1; i++){ |
|
timeB = millis(); |
|
|
|
if(timeB - timeA > 50){ |
|
timeA = millis(); |
|
if(direction){ |
|
lsize+=lsize*easing; |
|
if(lsize>targetMax){ |
|
direction = false; |
|
} |
|
} else { |
|
lsize-=lsize*easing; |
|
if(lsize<targetMin){ |
|
direction = true; |
|
} |
|
} |
|
} |
|
|
|
populateLetterArray(alphabetInstruct[i]); |
|
this.letterTemp = new aLetter(10+(i*(lsize*5)), 700, lsize); |
|
this.letterTemp.populateArray(); |
|
this.letterTemp.display(); |
|
} |
|
} |
|
|
|
if(currState == 3){ |
|
for(var i = 0; i <= wordInstruct.length-1; i++){ |
|
timeB = millis(); |
|
|
|
if(timeB - timeA > 50){ |
|
timeA = millis(); |
|
if(direction){ |
|
lsize+=lsize*easing; |
|
if(lsize>targetMax){ |
|
direction = false; |
|
} |
|
} else { |
|
lsize-=lsize*easing; |
|
if(lsize<targetMin){ |
|
direction = true; |
|
} |
|
} |
|
} |
|
|
|
populateLetterArray(wordInstruct[i]); |
|
this.letterTemp = new aLetter(10+(i*(lsize*5)), 700, lsize); |
|
this.letterTemp.populateArray(); |
|
this.letterTemp.display(); |
|
} |
|
} |
|
} |
|
|
|
// For when user presses a button |
|
function letterChangedEvent(value) { |
|
|
|
this.value = value; |
|
|
|
populateLetterArray(this.value); |
|
|
|
} |
|
|
|
// Used only with the dropdown |
|
function dropDownChooser(){ |
|
doAction(sel.value()); |
|
} |
|
|
|
// Actions for the drop down chooser |
|
function doAction(val){ |
|
this.value = val; |
|
|
|
if(this.value == 'Alphabet Grid'){ |
|
resetStates(); |
|
currState = 2; |
|
} |
|
if(this.value == 'Alphabet Silhouette'){ |
|
resetStates(); |
|
currState = 4; |
|
} |
|
if(this.value == 'Single Letter Mode'){ |
|
resetStates(); |
|
currState = 1; |
|
} |
|
if(this.value == 'Write Mode'){ |
|
resetStates(); |
|
currState = 3; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
// function to create and object of type aLetter |
|
function aLetter(lx,ly,size){ |
|
this.x = lx; |
|
this.y = ly; |
|
this.size = size; |
|
this.lArray = []; |
|
this.randSet = false; |
|
|
|
this.populateArray = function(){ |
|
|
|
for(var i = 0; i < 5; i++){ |
|
this.lArray[i] = []; |
|
for(var j = 0; j < 4; j++){ |
|
this.lArray[i][j] = letterArray[i][j]; |
|
} |
|
} |
|
|
|
|
|
}; |
|
|
|
this.display = function(){ |
|
|
|
push(); |
|
for(var i = 0; i < 5; i++){ |
|
for(var j = 0; j < 5; j++){ |
|
if(this.lArray[j][i] == 1){ |
|
rect(this.x+(i*1*this.size),this.y+(j*1*this.size),this.size,this.size); |
|
} |
|
} |
|
} |
|
pop(); |
|
}; |
|
|
|
} |
|
|
|
var colorBack = [29, 42, 46]; |
|
|
|
|
|
function draw () { |
|
|
|
noStroke(); |
|
frameRate(60); |
|
|
|
//background(colorBack); |
|
stroke(95, 52, 8); |
|
|
|
//print(currState); |
|
|
|
// Lerping the color of the items |
|
timeC2 = millis(); |
|
if(timeC2 - timeC1 > 5){ |
|
timerC1 = millis(); |
|
if(cDirection == false){ |
|
c1--; |
|
c2++; |
|
c3--; |
|
c4++; |
|
cCount--; |
|
if(cCount<0){ |
|
cDirection = true; |
|
} |
|
} |
|
if(cDirection){ |
|
c1++; |
|
c2--; |
|
c3++; |
|
c4--; |
|
cCount++; |
|
if(cCount>75){ |
|
cDirection = false; |
|
} |
|
} |
|
} |
|
|
|
|
|
// Much more pleasant color schemes |
|
var cFill = [c1,c2,c3,c4]; |
|
var cFill2 = [c3,c4,c2,c1]; |
|
background(cFill2); |
|
fill(cFill); |
|
|
|
activateMode(); |
|
|
|
} |
|
|
|
function activateMode(){ |
|
|
|
if(currState == 1){ |
|
|
|
letterHolderSingle.forEach(function(aLetter){ |
|
aLetter.display(); |
|
}); |
|
} |
|
|
|
if(currState == 2){ |
|
|
|
var count = 1; |
|
var j = 1; |
|
|
|
for(var i = 0; i <= alphabetDisplay.length-1; i++){ |
|
//print(alphabetDisplay[i]); |
|
|
|
if(count > 6){ |
|
j++; |
|
count = 1; |
|
} |
|
|
|
// Displays the alphabet and numbers in a box of 6 X 6 |
|
populateLetterArray(alphabetDisplay[i]); |
|
this.letterTemp = new aLetter(pxlSize+(count*(pxlSize*5)), (j*(pxlSize*6)), pxlSize); |
|
this.letterTemp.populateArray(); |
|
this.letterTemp.display(); |
|
|
|
count++; |
|
} |
|
} |
|
|
|
if(currState == 3){ |
|
|
|
rect(pointerX-(2.5*pxlSize),pointerY+(pxlSize*5),pxlSize*4,pxlSize); |
|
|
|
letterHolderWord.forEach(function(aLetter){ |
|
aLetter.display(); |
|
}); |
|
|
|
} |
|
|
|
if(currState == 4){ |
|
var count = 1; |
|
var j = 1; |
|
|
|
for(var i = 0; i <= alphabetDisplay.length-1; i++){ |
|
//print(alphabetDisplay[i]); |
|
|
|
if(count > 6){ |
|
j++; |
|
count = 1; |
|
} |
|
|
|
// Displays the alphabet and numbers in a box of 6 X 6 |
|
populateLetterArray(alphabetDisplay[i]); |
|
this.letterTemp = new aLetter(pxlSize+(count*(pxlSize*4)), (j*(pxlSize*5)), pxlSize); |
|
this.letterTemp.populateArray(); |
|
this.letterTemp.display(); |
|
|
|
count++; |
|
} |
|
} |
|
|
|
writeInstructions(); |
|
|
|
} |
|
|
|
function resetStates(){ |
|
// Resets the Arrays so that when a new drop down box is chosen you start over |
|
letterHolderSingle = []; |
|
letterHolderWord = []; |
|
nextLetter = 0; |
|
nextLine = 0; |
|
} |
|
|
|
function keyTyped() { |
|
if (key == '!') { |
|
saveBlocksImages(); |
|
} |
|
else if (key == '@') { |
|
saveBlocksImages(true); |
|
} else { |
|
|
|
if(currState == 1){ |
|
upperKey = key.toUpperCase(); |
|
letterChangedEvent(upperKey); |
|
var letterTemp = new aLetter(mouseX,mouseY,pxlSize); |
|
letterTemp.populateArray(); |
|
append(letterHolderSingle, letterTemp); |
|
} |
|
|
|
if(currState == 3){ |
|
upperKey = key.toUpperCase(); |
|
letterChangedEvent(upperKey); |
|
var letterTemp = new aLetter(startXWord+(nextLetter*(pxlSize*5)),startYWord+(nextLine*(pxlSize*5)),pxlSize); |
|
letterTemp.populateArray(); |
|
append(letterHolderWord, letterTemp); |
|
nextLetter++; |
|
pointerX = startXWord + (nextLetter*(pxlSize*5)) - pxlSize; |
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function keyPressed(){ |
|
if(keyCode == UP_ARROW && pxlSize<=100){ |
|
pxlSize = pxlSize + 5; |
|
} |
|
if(keyCode == DOWN_ARROW && pxlSize>=10){ |
|
pxlSize = pxlSize - 5; |
|
} |
|
if(keyCode == LEFT_ARROW){ |
|
strokeWeight(0); |
|
} |
|
if(keyCode == RIGHT_ARROW){ |
|
strokeWeight(1); |
|
} |
|
|
|
// Some of the logic here is working, but it is beyond the time I have right now |
|
// It works fairly well, but I am sure there is a much more elagent way of doing this! |
|
// Basically I am trying make it so the user can enter multiple lines of text and be able |
|
// to delete. Its in the placing of the letter that I am having issues. Specifically because of that weird 'E' that enter is throwing |
|
// Ive tried removing the last entry, but it does not seem to work |
|
if(keyCode == BACKSPACE && currState == 3){ |
|
letterHolderWord = shorten(letterHolderWord); |
|
nextLetter--; |
|
pointerX = pointerX - (pxlSize*5); |
|
if(nextLetter<0){ |
|
nextLetter = prevLetter; |
|
nextLine--; |
|
pointerY -= pxlSize*5; |
|
pointerX = startXWord+(pxlSize*4); |
|
} |
|
} |
|
// Pressing return places the x,y on the next line down depending on pxlSize |
|
if(keyCode == RETURN && currState == 3){ |
|
nextLine++; |
|
prevLetter = nextLetter-1; |
|
nextLetter = 0; |
|
pointerY += pxlSize*5; |
|
} |
|
} |
|
|
|
function mousePressed(){ |
|
if(currState == 3){ |
|
startXWord = mouseX; |
|
startYWord = mouseY; |
|
pointerX = mouseX; |
|
pointerY = mouseY; |
|
resetStates(); |
|
} |
|
} |
|
|