xxxxxxxxxx
// inspired by DaniFdzzz--> https://openprocessing.org/sketch/1002517
// inspired by R. Luke DuBoise--> https://openprocessing.org/sketch/1285344
var x= 0;
var y= 0;
var stepSize = 5.0;
var theText;// todo el text
var textString;// todo el text adentro de un array
var theFonts= [];//los differents fonts
var minFontSize= 20;// what is the min size of the words
var angleDistortion = 0.0;//this tilts the letter a bit so there is continuation
var counter = 0;
function preload(){
theText = loadStrings('Grimm.txt');
theFonts[0]= loadFont('PermanentMarker-Regular.ttf');
theFonts[1]= loadFont('Lobster-Regular.ttf');
theFonts[2]= loadFont('Righteous-Regular.ttf');
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
textString='';
for(let i=0; i<theText.length; i++){
textString+=theText[i] + '';
}
textString= textString.replace(/[^a-zA-Z0-9’ ]/g, ' ');
textString = textString.toLowerCase();
textString = textString.replace(/ +/g, ' ');
textString = textString.trim();
}
function draw() {
r = random(255);
g = random(255);
b = random(255);
if(mouseIsPressed){
var i = dist(x, y, mouseX, mouseY);
textSize(minFontSize + i/2);
var newLetter = textString.charAt(counter);
stepSize = textWidth(newLetter);
}
if(i > stepSize){
var angle= atan2(mouseY-y, mouseX-x);
fill(0);
stroke(r,g,b);
strokeWeight(5);
translate(x, y);
rotate(angle + random(angleDistortion));
text(newLetter, 0, 0);
counter++;
if (counter >= textString.length) counter = 0;
x = x + cos(angle) * stepSize;
y = y + sin(angle) * stepSize;
}
}
function mousePressed() {
x = mouseX;
y = mouseY;
}
function mouseClicked (){
textFont(random(theFonts));
}
function keyTyped(){
if(key==' ') {background(0);}
}