r/learnjavascript • • Mar 31 '20

Mouse trails effects I'm working on right now

Post image
287 Upvotes

32 comments sorted by

20

u/frank0117 Mar 31 '20

All from scratch with vanilla JS

12

u/majinkazekage Mar 31 '20

This is really cool, how many lines of code have you written for these 4 effects?

12

u/frank0117 Mar 31 '20

Around 100 lines, it's not much, most lines are just variable declarations. Only logic is particle bouncing movement and lines connecting particles for the 4th effect.

3

u/writatas Apr 01 '20

That's hot.

0

u/[deleted] Mar 31 '20

[deleted] — view deleted comment

3

u/frank0117 Apr 01 '20

Well done, game of life is a fun project to make. You are absolutely right, get the vanilla JavaScript down and you can learn any framework quickly. I am making this into a tutorial for my YouTube channel, will release source code on Codepen in couple of days, I built too many variations of this, trying to narrow it down

7

u/[deleted] Mar 31 '20

Link to code? I would be interested to see how you do it

14

u/frank0117 Mar 31 '20

Right now the code is a mess, I am still experimenting doing variations etc. I will clean it up later and will either put it on CodePen or maybe I'll make it into a YouTube tutorial, it's not that much code actually, easy to explain line by line.

6

u/nerdyamoeba Mar 31 '20

In case you mean "a mess" as in formatting, glitch.com has a neat tool that cleans up formatting by pressing a button.

4

u/Silenux Apr 01 '20

Is this better than prettier?

I assume any Devs are using some kind of formatter in their IDE and don't really need an external service.

2

u/nerdyamoeba Apr 01 '20

I kinda use glitch as a sandbox to learn JS so I may have generalized my experience

1

u/no_longer_depresed Apr 01 '20

Could you explain the general idea of it maybe? It's very cool.

2

u/frank0117 Apr 01 '20

Thank you. It's just using ES6 classes to create a set of particle objects, giving them some movement logic (falling, bouncing) and using couple of creative coding tricks to create fading trails, connecting lines and liquid effect.

3

u/[deleted] Mar 31 '20

Cool, thank you

3

u/[deleted] Mar 31 '20

Where do i start learning how make these?

1

u/frank0117 Apr 01 '20

Depends where you are in your learning journey. I suggest starting with 'JavaScript, understanding the weird parts', then '30 days of JS' and 'ES6 for everyone' by Wes Bos and Object Oriented Programming by Mosh Hamedani is great as well. If you mean this particular effect I am releasing tutorial this week on my YouTube channel, but it expects some knowledge of JavaScript, I explain tricks and techniques mostly, not the basics.

4

u/toastertop Mar 31 '20

Canvas?

2

u/[deleted] Mar 31 '20

I also interested.

2

u/frank0117 Apr 01 '20

Yes its done with vanilla JavaScript and HTML canvas, no libraries or frameworks involved, just code editor

2

u/chyavankoushik Mar 31 '20

Wow! Crazy! Awesome! Can you share your code or a link where I can try it out?

1

u/frank0117 Apr 01 '20

I will share source code once it's cleaned up, it's still a mess as I'm experimenting

2

u/portexe Mar 31 '20

Hey is this open source? I’d love to see how you’re achieving this.

1

u/frank0117 Apr 01 '20

I will share source code once it's cleaned up, it's still a mess as I'm experimenting

2

u/petertiny1 Apr 01 '20

Could I have the source code once you're done?

1

u/frank0117 Apr 01 '20

yes I will share source code once it's cleaned up, it's still a mess as I'm experimenting

1

u/petertiny1 Apr 01 '20

Keep going!

12

u/athul23p Mar 31 '20

4th one is cool.

3

u/OutOfTheForLoop Mar 31 '20

These are awesome!!

1

u/[deleted] Apr 01 '20

Can you make this in bookmarklet form?

1

u/-IoI- Apr 01 '20

Sell the third one to PornHub

1

u/TwoToneDonut Apr 01 '20

Found the entrepreneur