xxxxxxxxxx
var thetext;
var thefulltext;
var thewords = [];
var x = 0;
var y = 30;
var whichword = 0;
var thefont = [];
function preload() {
thetext = loadStrings('dracula.txt');
thefont[0] = loadFont('Needleteeth Psycho.ttf');
thefont[1] = loadFont('StakeThroughtheHeartBB_reg.ttf');
thefont[2] = loadFont('blooods_.ttf');
thefont[3] = loadFont('October Crow.ttf');
thefont[4] = loadFont('DarkerHollow.ttf');
}
function setup() {
createCanvas (windowWidth, windowHeight);
background (255);
fill(0);
stroke(0);
textFont(random(thefont));
frameRate(15);
textSize(30);
thefulltext = ' ';
for(let i = 0;i<thetext.length;i++)
{
thefulltext+=thetext[i]+' ';
}
thewords = thefulltext.split(' ');
console.log(thewords);
}
function draw() {
textFont(random(thefont));
let wlen = textWidth(thewords[whichword]+' ');
if (x+wlen>width)
{
x=0;
y=y+30;
}
if(y>height)
{
x=0;
y=30;
background(255);
}
text(thewords[whichword], x, y);
x+=wlen;
whichword = (whichword+1)%thewords.length;
}