xxxxxxxxxx
290
var Text;
var newText;
var originalText;
let font;
let fontSize;
let pointArray;
let angle = 0;
let textColor;
var pg;
let color1;
let color2;
let deleteKey;
let index = 0;
let factor= 9;
let p=0;
function preload() {
font = loadFont('font.otf')
}
function setup() {
createCanvas(windowWidth, windowHeight);
textFont(font);
textSize(80);
Text = createInput(''); //generates an input box for the text
//Text.position(windowWidth/2, windowHeight/2)
Text.position(0,windowHeight-30)
Text.size(windowWidth, 20)
pg = createGraphics(windowWidth, windowHeight);
push();
textSize(12);
textAlign(CENTER);
fill(160);
textFont("font.otf");
text("type anyhting in the box below to begin", windowWidth/2, windowHeight/1.08);
pop();
push();
textSize(20);
textAlign(CENTER);
fill(160);
textFont("font.otf");
text("there is no ______ that is not an echo", windowWidth/2, windowHeight/2-300);
pop();
push();
color1 = color( 0, 200);
color2 = color(200);
lineGradient(windowWidth/2-215, windowHeight/2-39, 520, 9, color1, color2);
color1 = color(255);
color2 = color(200);
lineGradient(windowWidth/2-215, windowHeight/2+30.75, 520, 9, color1, color2);
color1 = color(180);
color2 = color(200);
lineGradient(windowWidth/2-215.5, windowHeight/2-5.5, 520, 9, color1, color2);
pop();
push();
textSize(110);
textAlign(CENTER);
strokeWeight(1.5)
noStroke()
fill(200);
textFont("font.otf");
text("E H", windowWidth/2-163, windowHeight/2+39.7);
pop();
push();
textSize(105);
textAlign(CENTER);
strokeWeight(1.5)
noStroke()
fill(200);
textFont("font.otf");
text(" C", windowWidth/2-190, windowHeight/2+38.7);
pop();
push();
textSize(10);
textFont("font.otf");
noStroke();
fill(0);
text("your voice", windowWidth/2+310, windowHeight/2-31);
pop();
push();
fill(160);
textSize(10);
textFont("font.otf");
text("your echo", windowWidth/2+310, windowHeight/2+2);
pop();
push();
fill(220);
textSize(10);
textFont("font.otf");
text("your silence", windowWidth/2+310, windowHeight/2+40);
pop();
}
function draw() {
pg.fill(255)
pg.noStroke();
pg.rect(0,0, width, height);
// blinkingText();
if (mouseIsPressed) {
image(pg, 0, 0);
}
ellipseColor();
pointArray = font.textToPoints(Text.value(), 0, 110, fontSize, { sampleFactor: factor
});
translate(windowWidth/2+p, windowHeight/2-p)
rotate(angle);
lines();
angle+=.0055;
p+=(random(-.5, .5));
}
function keyPressed(){
if(keyCode === BACKSPACE){
strokeWeight(1);
stroke(255, 85);
}
else if (keyIsPressed && !deleteKey) {
strokeJoin(MITER)
strokeWeight(.6);
stroke(0, 200);
}
else {
strokeWeight(.5)
stroke(0, 150);
noFill();
// strokeWeight(.01)
// stroke(100, 120)
// fill(180, 2)
}
}
function ellipseColor() {
let s = 80;
if (keyCode === BACKSPACE) {
deleteKey == true}
if(keyCode === BACKSPACE){
push();
noStroke()
fill(255);
rectMode(CENTER)
ellipse(windowWidth/2, windowHeight/2, s, s);
pop();
}
else if(keyIsPressed && !deleteKey){
push();
noStroke();
fill(0, 140);
rectMode(CENTER)
ellipse(windowWidth/2, windowHeight/2, s,s);
pop();
push();
}
else {
push();
noStroke()
fill(200);
rectMode(CENTER)
ellipse(windowWidth/2, windowHeight/2, s, s);
pop();
}
}
function lineGradient(x, y, w, h, color2, color1) {
noFill();
for (let i = x; i <= x + w; i++) {
let inter = map(i, x, x + w, 0, 1);
let c = lerpColor(color1, color2, inter);
stroke(c);
line(i, y, i, y + h);
}
}
function blinkingText() {
let words = ['love', 'thought', 'world', 'lie', 'you', 'idea', 'quote', 'test', 'code', 'art']
push();
noStroke();
fill(255, op)
rect(windowWidth/2-80,windowHeight/2-320,85,30);
pop();
push();
textSize(20);
textFont('font.otf');
textAlign(CENTER);
fill(0, op);
text(words[index],windowWidth/2-35,windowHeight/2-300);
pop();
if(mouseIsPressed){
push();
noStroke();
fill(255, op)
rect(windowWidth/2-80,windowHeight/2-320,85,30);
pop();
}
if(frameCount%30 == true) {
index++
}
if(index > words.length-1){
index = 0;
}
}
function lines() {
if (keyCode === BACKSPACE) {
deleteKey == true}
//beginShape();
beginShape(POINTS);
factor-=0.0035;
for (let i = 0; i < pointArray.length; i+=1) {
keyPressed();
vertex(pointArray[i].x, pointArray[i].y);
}
if (keyIsPressed && !deleteKey){
factor=1
}
else if(factor<0.02){
factor=.08;
}
endShape();
}