Member-only story

Create Interactive Visuals with JavaScript and HTML5 Canvas

How to Make Two Animated, Interactive Hero Sections

Bret Cameron
10 min readSep 27, 2019
Photo by Daniel Korpai on Unsplash, with my own edits.

Making an eye-catching, memorable website isn’t easy. As the quality and performance of the web has gone up, so have users’ expectations. One of the best ways to make a lasting impression is through animated, interactive visual elements.

Since the canvas tag got updated in HTML, there are now lots of powerful ways to bring interactive visuals to your next web app. In this tutorial, we’ll look into how, by building two different interactive hero sections, pictured below.

In the first section, we’ll look into the boilerplate code that is common to both examples. Then, we’ll go into the details of each effect. In roughly 100 lines of JavaScript, you can produce eye-catching, interactive visuals like these!

Introduction: The Code in Both Examples

It’s tempting to go straight into the visuals, but there’s a lot of shared code we’ll use in for all three interactive hero images. For that reason, I’ve chosen to begin with the shared elements. If you’d prefer to go straight…

--

--

Bret Cameron
Bret Cameron

Written by Bret Cameron

Writer and developer based in London. On Medium, I mainly write about JavaScript, web development and Rust 💻

Responses (2)