Type in a new word (and press backspace to delete the current one). You can also drag the mouse around to add some more particles.
xxxxxxxxxx
var string = "";
const size = 12;
const fontFile = "Muli-Black.ttf";
const showText = true;
const textAlpha = 1;
const backgroundColor = 8;
const strokeAlpha = 50;
const strokeColor = 254;
const fontSampleFactor = 0.3;
const noiseZoom = 0.006;
const noiseOctaves = 4;
const noiseFalloff = 0.5;
const zOffsetChange = 0;
const individualZOffset = 0;
const lineSpeed = 50;
const newPointsCount = 10;
var seed;
var font;
var points = [];
var startingPoints;
function preload() {
font = loadFont(fontFile);
}
function setup() {
createCanvas(1920, 1080);
textFont(font);
fill(backgroundColor, textAlpha);
stroke(strokeColor, strokeAlpha);
noiseDetail(noiseOctaves, noiseFalloff);
seed = floor(random(1000000));
start();
}
function start(){
background(backgroundColor)
textSize(size);
randomSeed(seed);
noiseSeed(seed);
frameCount = 0;
startingPoints = font.textToPoints(string, width / 2 - textWidth(string) / 2, height / 2, size, {"sampleFactor": fontSampleFactor});
points = [];
for (let p = 0; p < startingPoints.length; p++) {
points[p] = startingPoints[p];
points[p].zOffset = random();
}
}
function draw() {
if(showText){
noStroke();
text(string, width / 2 - textWidth(string) / 2, height / 2);
stroke(strokeColor, strokeAlpha);
}
for (let pt = 0; pt < points.length; pt++) {
let p = points[pt];
let noiseX = p.x * noiseZoom;
let noiseY = p.y * noiseZoom;
let noiseZ = frameCount * zOffsetChange + p.zOffset*individualZOffset;
let newPX = p.x + map(noise(noiseX, noiseY, noiseZ), 0, 1, -lineSpeed, lineSpeed);
let newPY = p.y + map(noise(noiseX, noiseY, noiseZ + 214), 0, 1, -lineSpeed, lineSpeed);
line(p.x, p.y, newPX, newPY);
p.x = newPX;
p.y = newPY;
}
}
// Use a keypress so thousands of files aren't created
void mousePressed() {
record = true;
}
function keyPressed() {
if (keyIsDown(CONTROL) && key.toLowerCase() === 's') {
save();
}else if (keyCode === BACKSPACE || keyCode === DELETE){
string = string.substring(0, string.length-1);
start();
}else if(keyCode === RETURN){
seed = floor(random(1000000));
start();
}else if (keyCode === 32 || keyCode >= 186 || (keyCode >= 48 && keyCode <= 90)){
string += key;
start();
}
}
function mouseMoved() {
for (let i = 0; i < newPointsCount; i++) {
let angle = random(TAU);
let magnitude = randomGaussian() * ((newPointsCount-1)**0.5*3);
let newPoint = {
"x": mouseX + magnitude * cos(angle),
"y": mouseY + magnitude * sin(angle),
"zOffset": random()
};
points[points.length] = newPoint;
startingPoints[startingPoints.length] = newPoint;
}
}