create speed parameter

This commit is contained in:
Asif Bacchus 2020-04-08 05:23:28 -06:00
parent 24af3c33ac
commit fe51090807
2 changed files with 4 additions and 4 deletions

View File

@ -8,7 +8,7 @@
href="css/index.min.css"
crossorigin="anonymous"/>
</head>
<body onload='particles(avoidMouse = false, hover = false)'>
<body onload='particles(false, false, 2, 0.5)'>
<canvas id="particles"></canvas>
<!-- javascript -->
<script

View File

@ -1,4 +1,4 @@
function particles(avoidMouse = true, hover = true, particles = 2) {
function particles(avoidMouse = true, hover = true, particles = 2, speed = 0.5){
/* create particles animation
based on the amazing tutorial by 'Franks Labratory'
https://youtu.be/d620nV6bp0A
@ -79,8 +79,8 @@ function particles(avoidMouse = true, hover = true, particles = 2) {
}
// move particle
this.x += this.directionX;
this.y += this.directionY;
this.x += this.directionX * speed;
this.y += this.directionY * speed;
// draw particle
this.draw();