10 - generative typography
práca s textom a písmom v p5.js
Prezentácia
Last updated
práca s textom a písmom v p5.js
Last updated
function setup() {
createCanvas(800, 400);
textSize(48);
textAlign(CENTER, CENTER);
text("Ahoj, svet!", width / 2, height / 2);
}function setup() {
createCanvas(800, 400);
textSize(48);
textAlign(CENTER, CENTER);
}
function draw() {
background(30);
fill(lerpColor(color("red"), color("blue"), mouseX / width));
text("Ahoj svet", mouseX, mouseY);
}let myFont;
function preload() {
myFont = loadFont('FiraCode-Regular.ttf');
}
function setup() {
createCanvas(windowWidth, windowHeight);
textFont(myFont);
textSize(64);
textAlign(CENTER, CENTER);
}
function draw() {
background(30);
fill(255);
let txt = "Ahoj svet!";
let baseX = width / 2 - textWidth(txt) / 2; // Začiatočná X súradnica textu
let baseY = height / 2;
for (let i = 0; i < txt.length; i++) {
let charWidth = textWidth(txt[i]);
let x = baseX + i * charWidth; // X pozícia znaku
let y = baseY + sin(frameCount * 0.1 + i * 0.5) * 20; // Animovaná Y pozícia
text(txt[i], x, y);
}
}
let font;
let points;
let time = 0;
function preload() {
font = loadFont('Roboto-Regular.ttf');
}
function setup() {
createCanvas(800, 400);
textFont(font);
textSize(128);
fill(255);
noStroke();
points = font.textToPoints("Ahoj svet", 100, 200, 128, {
sampleFactor: 0.2,
});
}
function draw() {
background(0);
for (let i = 0; i < points.length; i++) {
let p = points[i];
// Použitie noise pre jemný pohyb
let nX = noise(p.x * 0.01, p.y * 0.01, time) * 20;
let nY = noise(p.y * 0.01, p.x * 0.01, time) * 20;
let x = p.x + nX;
let y = p.y + nY;
ellipse(x, y, 5, 5);
}
// Posun v čase pre animáciu
time += 0.01;
}