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" href="css/index.min.css"
crossorigin="anonymous"/> crossorigin="anonymous"/>
</head> </head>
<body onload='particles(avoidMouse = false, hover = false)'> <body onload='particles(false, false, 2, 0.5)'>
<canvas id="particles"></canvas> <canvas id="particles"></canvas>
<!-- javascript --> <!-- javascript -->
<script <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 /* create particles animation
based on the amazing tutorial by 'Franks Labratory' based on the amazing tutorial by 'Franks Labratory'
https://youtu.be/d620nV6bp0A https://youtu.be/d620nV6bp0A
@ -79,8 +79,8 @@ function particles(avoidMouse = true, hover = true, particles = 2) {
} }
// move particle // move particle
this.x += this.directionX; this.x += this.directionX * speed;
this.y += this.directionY; this.y += this.directionY * speed;
// draw particle // draw particle
this.draw(); this.draw();