Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
    • p5.js Introduction
    • p5.js Variables
    • p5.js Random Numbers
    • p5.js SVG + Images
    • p5.js WebGL
    • p5.js Classes and Objects
    • p5.js Events and Functions
    • p5.js Loops
    • p5.js Coordinates
    • P5js Nested Loops
    • p5.js Animation Exercise 1
    • p5.js Animation Exercise 2
    • p5.js Conditionals
    • p5.js Arrays and Lists
    • p5.js Simple Collision Detection
    • p5.js Reactors
    • p5.js Tiling and Repetition
    • p5.js Vectors
    • p5.js Animation Solution with Objects
    • p5.js Easing
    • p5.js Perlin Noise
    • p5.js Particle System
    • p5.js Sound
    • p5j.s Typography
    • P5js Archive
  • Programming in Processing (java)

/
p5j.s Typography
Updated Dec 19, 2023

p5j.s Typography

Analytics

Loading data...

Using System fonts in p5.js is quite simple. You can also load your own fonts and use them to type on the canvas

let myFont; function preload() { myFont = loadFont('helvetica.otf'); //load your own font } function setup() { fill(0,0,255); textFont(myFont); textSize(36); text('p5*js', 10, 50); }

 

In order to make interactive, kinetic typography, you need to use p5.Graphics. By calling createGraphics(w, h, [renderer]) you can draw into an off-screen graphics buffer. It allows you to overlay graphics on top of the canvas

The following example is based on Processing-Tutorial: Kinetic Typography 1 • tim rodenbröker creative coding

// GRID const g = 100; // cell width const cellnum = 5; // numbers of cells per row and column // BASIC let cg; //canvas // SOURCE let sx; let sy; let sw; let sh; // DESTINATION let dx; let dy; let dw; let dh; var wave; function setup() { createCanvas(400, 400); cg = createGraphics(400, 400); cg.fill(0,0,0); cg.textFont("Hind"); } function draw() { background(225); // grid(); cg.push(); cg.translate(width / 2, height / 2); cg.textSize(200); cg.textAlign(CENTER, CENTER); cg.text('p5.js', 0, 0); cg.pop(); for (let x = 0; x < cellnum; x++) { for (let y = 0; y < cellnum; y++) { wave = int(cos((frameCount + ( x*y )) * 0.1) * 200); // SOURCE sx = x * g + wave; sy = int(y * g + (wave*0.2)); sw = g; sh = g; // DESTINATION dx = x * g; dy = y * g; dw = g; dh = g; copy(cg, sx, sy, sw, sh, dx, dy, dw, dh); } } grid(); } function grid() { for (let i = 0; i < cellnum; i++) { for (let j = 0; j < cellnum; j++) { //show grid background cg.strokeWeight(random(1,3)); cg.stroke(0); cg.noFill(); cg.rect(i * g, j * g, g, g); } } }

Another method to manipulate the font is to use textToPoints(txt, x, y, fontSize, [options])method, which allows us to create a vertex array on the path which define a specific string.

 



 

Related content

p5.js Introduction
p5.js Introduction
Programming
More like this
Arduino and P5.js
Arduino and P5.js
Electrical Engineering
More like this
p5.js Coordinates
p5.js Coordinates
Programming
More like this
p5.js Variables
p5.js Variables
Programming
More like this
p5.js Tiling and Repetition
p5.js Tiling and Repetition
Programming
More like this
p5.js Events and Functions
p5.js Events and Functions
Programming
More like this
{"serverDuration": 39, "requestCorrelationId": "f0323f18aaa14dca89b12d838ddfca0e"}