Home JS special effects html5 special effects html5 canvas line falling animation special effects

html5 canvas line falling animation special effects

html5 canvas line falling animation special effects

html5 canvas line falling animation special effects

The html5 canvas line falling animation effect is a line falling animation effect that is somewhat similar to rain.

(function(){

var c = document.getElementById("c"),
ctx = c.getContext("2d");

c.width = innerWidth;
c.height = innerHeight;

var lines = [],
maxSpeed ​​= 5,
spacing = 5,
xSpacing = 0,
n = innerWidth / spacing,
colors = ["#3B8686", "#79BD9A", "#A8DBA8", "#0B486B"],
i;

for (i = 0; i < n; i++){
xSpacing += spacing;
lines.push({
x: xSpacing,
y: Math.round(Math.random()*c.height),
width: 2,
height: Math.round(Math.random()*(innerHeight/10)),
speed: Math.random()*maxSpeed ​​+ 1,
color: colors[Math.floor(Math.random() * colors.length)]
});
}


function draw(){
var i;
ctx.clearRect(0,0,c.width,c.height);

for (i = 0; i < n; i++){
ctx.fillStyle = lines[i].color;
ctx.fillRect(lines[i].x, lines[i].y, lines[i].width, lines[i].height);
lines[i].y += lines[i].speed;

if (lines[i].y > c.height)
lines[i].y = 0 - lines[i].height;
}

requestAnimationFrame(draw);

}

draw();

}());

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

Text animation special effects based on HTML5 Canvas Text animation special effects based on HTML5 Canvas

02 Apr 2018

This article shares with you the text animation special effects based on HTML5 Canvas. It is very useful. Friends in need can use it for reference.

JS makes snowflake falling animation special effects JS makes snowflake falling animation special effects

06 Jun 2018

This time I will bring you JS to create special effects of falling snowflake animation. What are the precautions for making special effects of falling snowflake animation with JS? Here is a practical case, let’s take a look.

HTML5 Canvas realizes the special effects of fireworks blooming HTML5 Canvas realizes the special effects of fireworks blooming

03 Jul 2018

This is a gorgeous HTML5 Canvas animation. It will simulate the animation special effects of fireworks blooming in our lives. The effect is very realistic. Let’s briefly analyze the process and code of implementing this HTML5 fireworks special effect. For those who are interested You can refer to it

Realistic fireworks special effects plug-in based on HTML5 canvas Realistic fireworks special effects plug-in based on HTML5 canvas

18 Jan 2017

jquery-fireworks is a jQuery plug-in for realistic fireworks special effects based on HTML5 Canvas. The plugin is simple to use and freely configurable. It can generate realistic fireworks effects in a div container.

Detailed introduction to 7 cool HTML5 Canvas animation effects Detailed introduction to 7 cool HTML5 Canvas animation effects

08 Mar 2017

HTML5 is really an excellent web technology. It not only allows you to manipulate page elements more conveniently, but also allows you to achieve more animation effects through canvas. After the introduction of the HTML5 standard, CSS3 can play a greater role. This article mainly introduces some animation special effects based on HTML5 Canvas and shares them with you. I hope you like them. 1. HTML5 Canvas waterfall animation, super realistic. This is a very realistic HTML5 waterfall animation, based on Canvas, the effect is quite cool. Online demo source code download 2. HTML5 Canvas color..

Loading animation special effects based on HTML5 Canvas and Rebound animation Loading animation special effects based on HTML5 Canvas and Rebound animation

19 Jan 2017

This is a Loading animation special effect based on HTML5 Canvas and Rebound animation. The loading animation uses a canvas to cover the entire page and displays a polygonal loading loader to represent the loading progress.

Detailed introduction to 7 amazing HTML5 particle animation special effects Detailed introduction to 7 amazing HTML5 particle animation special effects

06 Mar 2017

One of the great advantages of HTML5 is that it can more conveniently and efficiently create particle animation special effects on web pages, especially the Canvas feature, which can draw any graphics and animation on web pages. This article will share 7 amazing HTML5 particle animation effects. These particle effects provide source code download for everyone to learn. 1. HTML5 Canvas particle simulation effect This is a 30,000 particle animation simulated using HTML5 Canvas. When you move the mouse on the canvas, some particles around the mouse will move with you and form a certain pattern. Just like you are playing with sand art, the effect...

JavaScript+html5 canvas implements image fragmentation and reorganization animation special effects_javascript skills JavaScript+html5 canvas implements image fragmentation and reorganization animation special effects_javascript skills

16 May 2016

This article mainly introduces JavaScript+html5 canvas to achieve video special effects of fragmentation and reorganization. Interested friends can refer to it.

A graphic and text appreciation of 8 gorgeous HTML5 text animation special effects A graphic and text appreciation of 8 gorgeous HTML5 text animation special effects

06 Mar 2017

Text is the soul of web pages. A long time ago, someone invented many beautiful computer fonts, which gave web pages different styles. With the emergence of HTML5 and CSS3, we can make text more personalized. In some situations where necessary, we can even use HTML5 to animate text. This article shares 8 very gorgeous HTML5 text animation special effects, I hope it can be used as a reference for you. 1. CSS3 3D folding and flipping text animation Today we are going to share a CSS3 text special effects application. It is similar to the HTML5/CSS3 text effects shared before. It is also a CSS3 3D folding and flipping text animation, only...

See all articles See all articles

Hot Tools

HTML5 Canvas heart fluttering animation special effects

HTML5 Canvas heart fluttering animation special effects

HTML5 Canvas heart fluttering animation special effect is a generated animation that can be directly opened with a browser to see a heart.

H5 panda bouncing game source code

H5 panda bouncing game source code

HTML5 Mobile Panda is also a crazy game source code. Game description: Press and hold the screen to adjust the strength of the panda spring and jump to the stone pillar. The game ends if you fall into the river.

HTML5 Valentine's Day box animation special effects

HTML5 Valentine's Day box animation special effects

Based on svg, draw animations of opening love box gifts on Valentine's Day, and special effects of love box animation.

H5 3D rolling ball game source code

H5 3D rolling ball game source code

HTML5 cool 3D ball rolling mobile game code download. Game introduction: A colored ball rolls, and the current track of the colored ball is controlled by dragging it with the mouse or the touch screen of the mobile phone. This is a simple and easy-to-operate mobile game source code.