
Let's code an HTML5 Canvas Loader:
HTML
- <canvas id="demo" height="400" width="400" style="background:#000;" />
Js
- var canvas = document.getElementById('demo');
- var context = canvas.getContext('2d');
- var start = new Date();
- var lines = 16,
- cW = context.canvas.width,
- cH = context.canvas.height;
- var draw = function() {
- var rotation = parseInt(((new Date() - start) / 1000) * lines) / lines;
- context.save();
- context.clearRect(0, 0, cW, cH);
- context.translate(cW / 2, cH / 2);
- context.rotate(Math.PI * 2 * rotation);
- for (var i = 0; i < lines; i++) {
- context.beginPath();
- context.rotate(Math.PI * 2 / lines);
- context.moveTo(cW / 10, 0);
- context.lineTo(cW / 4, 0);
- context.lineWidth = cW / 30;
- context.strokeStyle = "rgba(255,255,255," + i / lines + ")";
- context.stroke();
- }
- context.restore();
- };
- window.setInterval(draw, 1000 / 30);

Janeth Kent
Licenciada en Bellas Artes y programadora por pasión. Cuando tengo un rato retoco fotos, edito vídeos y diseño cosas. El resto del tiempo escribo en MA-NO WEB DESIGN END DEVELOPMENT.
Related Posts
Understanding LCP, CLS, FID. All about Core Web Vitals in Google Search Console
A few months ago we talked about certain Google metrics that were displayed in Search Console. The reason for writing another post on this topic is that Google has changed…
Validating HTML forms using BULMA and vanilla JavaScript
Today we are going to write about contact forms and how to validate them using JavaScript. The contact form seems to be one of the top features of every basic home…
How to use Parallax.js effect on your website
Today, we're going to write about the parallax effect, similar to parallax scrolling, and how to implement it to improve your landing page. In webdev, they say mobile first -…
How to make the website's dark mode persistent with Local Storage, CSS and JS
Recently we wrote about how to do a switchable alternative color mode or theme, a very useful and popular feature to websites. Today’s article is going to be about how…
Dark Web: the creepy side of the Internet is not as dark as believed
People who surf the Dark Web are not necessarily looking for something illegal. Most people want to protect their privacy. And according to a recent study, 93 percent only use…
Cross cultural challenges in web design, an overview
The user experience design of a product essentially lies between the intentions of the product and the characteristics of your user. - David Kadavy - The task of building a culturally appropriate…
A Java approach: While loop
Hello everyone and welcome back! After having made a short, but full-bodied, introduction about cycles, today we are finally going to see the first implementations that use what we have called…
Website Traffic Getting Low? 4 Immediate Action to Take
If you have created a website, I am sure your end objective is to create a strong brand presence, boost engagement, and multiply revenue. An interesting statistic showed that there were…
The easiest way to align items using flexbox
With the release of flexbox in CSS, it has become an essential tool when placing elements next to each other, since, by default, the children of a display: flexare stacked…
Dark Mode on website using CSS and JavaScript
In today’s article we are going to learn how to build pretty much standard these days on the web pages and that is the alternative color mode and switching between…
A Java approach: The Cycles - Introduction
Hello everyone and welcome back! Until now, we have been talking about variables and selection structures, going to consider some of the fundamental aspects of these two concepts. Theoretically, to…
JavaScript: Spread and Rest operators
In today’s article we are going to talk about one of the features of the ES6 version(ECMAScript 2015) of JavaScript which is Spread operator as well as Rest operator. These features…