
Draw multi-line text on HTML canvas and center it with gradients. Turn the text into a vanilla JavaScript particle system that updates as you type in input field, with physics.
Set up an HTML canvas project and draw multi-line centered text with fillText and strokeText, manage font and alignment, measure text, and create interactive animated particles from user input.
Master css sizing and layout using box-sizing: border-box, calc, and margins to prevent scroll bars, then initialize a 2d canvas, sync width, and manage z-index for interactive animations.
Learn to render text on the HTML canvas with fill text and stroke text, control font and colors, and position with textAlign, textBaseline, and coordinates.
Learn to wrap and center multiline text on an HTML canvas by implementing a custom wrapText function, measuring word widths, splitting on spaces, and drawing lines within a max width.
Learn how to center multi-line text vertically on an HTML canvas by calculating text height and adjusting the y position, while updating the display dynamically from a text input.
Apply a linear gradient to canvas text from top-left to bottom-right with color stops at 0.3, 0.5, and 0.7 in red, fuchsia, and purple; radial gradient offers an alternative.
Refactor a canvas text effect into object oriented JavaScript by modeling a particle class and an effect controller to render typed text as animated particles.
Draws text on canvas from an input field and converts the pixels into animated particles with a configurable gap. Tracks mouse movement and uses getImageData to map colors into particles.
Convert canvas text into particles by mapping pixel data to x, y, and color, then animate from random origins to targets with a particle class and physics.
Explore interactive canvas physics where particles react to mouse position, moving away and circling the cursor via distance, angle, friction, and performance tuning.
Explore rendering text on an HTML canvas and applying custom web fonts via Google Fonts. Optimize performance by using context attributes, including will read frequently set to true.
Make canvas text effects responsive by handling the window resize, updating canvas size and text position, recalculating max text width, and wrapping text into particles, with export as png.
Explore the constellations effect by rendering text as particles on HTML canvas, connecting nearby particles with lines based on distance, using nested loops and performance considerations.
Calculate opacity from the ratio of current to maximum distance between particles, applying per-line opacity on canvas. Save and restore canvas state to isolate effects while adjusting font for readability.
Become a master of web animation.
From drawing a single letter to multiline animated particle text. In this HTML canvas crash course we will go from basics to advanced in a single class. We will cover everything you need to know about using fonts and drawing text on HTML canvas. Let's explore what's possible in modern front-end web development and turn text into complex animated particle systems.
Practice vanilla JavaScript with no frameworks and no libraries
Learn how to write creative coding prototypes and experiments in a simple procedural (line by line) codebase. Convert those experiments into a more modular object oriented JavaScript syntax.
Experiment with code
Learn how to create the base version of the effect with me step by step. Apply constellations algorithm for a completely different visual effect. Learn how to use canvas gradients, custom web fonts and how to change particle shapes and physics to get different visuals and movement.
This technique will also work with company LOGOS, even if the logo is a combination of text, symbols and images.
Source code included
With the final lesson you can download the complete source code, as well as some of my experimental variations of the codebase.
From basics to advanced
Basic knowledge of HTML, CSS and JavaScript is required. The first part of the course will be very beginner friendly, we will learn how to set up an HTML canvas, how to draw text using fillText and strokeText built-in methods and we will cover all available tools and techniques to style it.
The second part will cover more advanced algorithms. We will learn how to draw multiline centered text on HTML canvas, how to turn it into particles, how to make those particle systems interactive and much more.
Have fun! :)