Wow, great pair of videos, Dan! I remember programming Lissajous figures using BASIC on my first PC - an Apple ][+ - back in the late '70s. I remember being annoyed by the time it took to draw ONE figure. Here you are drawing over 100 of them simultaneously, each with higher precision and speed, on a machine that's doing many other things at the same time that probably only cost about 1/3 as much. It's truly amazing! Also, it was very useful to see what it takes to convert a Processing program to P5.js. It would be great to see this more often.
@TheCodingTrain6 жыл бұрын
Thank you Ken!
@Daniel-wu9ui5 жыл бұрын
to reset an array just set its length to zero e.g. if(arr.length != 0) arr.length = 0, this will clear the array of all elements
@loic.bertrand3 жыл бұрын
4:25 there shouldn't be a new in "new createVector()" but it still works 🤔 I'm surprised x)
@rebornreaper1943 жыл бұрын
Yeah that's javascript for you. new is merely a suggestion when it comes to functions
@arsebiscuitsandwine6 жыл бұрын
As someone battling with porting code to JavaScript currently this was a trip to watch! Nice job. I'm going to mess about with Lissajous curves in C# too so I can make shiny things with them in Unity3D. Maybe some kind of 3d Modelled machine that drops sand to make the patterns? That sounds rediculous. I'm going to do it.
@kenhaley46 жыл бұрын
I have another idea! Do a 3-D Lissajous. Circles on each of all 3 axes determine the path of a point in 3D space. I think I'll play with that idea.
@benjamindragon5986 жыл бұрын
thisdohhhht thisdohht letletletletlet
@PranavNutalapati4 жыл бұрын
Hey Dan, I know this is an old video of yours, but I just wanted to tell you an alternative way to empty an array. You actually can set the length to zero. This is in fact the fastest way to empty a large array in JavaScript in terms of performance, assuming you can't replace it with a new array (as you have done) for whatever reason. eg: this.path.length = 0
@SimonTiger5 жыл бұрын
3:47 `arr.clear()` is not a thing, but here's a little trick that I use every once in a while! The `arr.splice()` function can remove any amount of elements from `arr`, but by default it just goes all the way to the end. So `arr.splice(n)` will remove everything from n to the end. And guess what now, `arr.splice(0)` will remove everything from the beginning to the end, in other words, _everything!_ There's a similar trick for concatenating two arrays together. Normally, you say something like `arr1 = arr1.concat(arr2)`, but that's not really elegant, because you're resetting `arr1`. In ES6, there's a thing called the _spread operator._ Basically, what it does is this: ...[6, 5, 3, 1, 8, 7, 2, 4] = 6, 5, 3, 1, 8, 7, 2, 4 It turns an array into a _list of arguments for a function._ So, for concatenating 2 arrays together, we can say `arr1.push(...arr2)`! That will put everything from `arr2` on the tail of `arr1`!
@TheCodingTrain5 жыл бұрын
Thank youo Simon!
@misterkite5 жыл бұрын
If you just want to remove all the elements from an array, splice is very inefficient. Just set array.length = 0.
@dmax16 жыл бұрын
Legend says he is still there
@zacharymcarthur90136 жыл бұрын
That timing on the bell hahaha *ding* “oh wait it broke”
@qoutroy3776 жыл бұрын
Instead of 'make2DArray', you could use this: new Array(rows).fill(new Array(cols)); Does the same thing, but in one row.
@TheCodingTrain6 жыл бұрын
Great tip!
@morphman866 жыл бұрын
If you really wanna be optimal about it, use a single array and reference index using mathemagic, as Dan taught a few videos ago. array = new Array(width + height), index = ycoord * width + xcoord, array[index] = your value
@louiserouse79144 жыл бұрын
This was adorable ❤︎
@wamaithanyamu6 жыл бұрын
You are heaven sent! Thank you so much for making this!
@dylan68016 жыл бұрын
Instead of adding vertexes (vertices?) for the paths, you could also use createGraphics to basically make another canvas where you don't refresh the background. Then you just draw an ellipse to the second canvas and it leaves a trail. Really cool video!
@TheCodingTrain6 жыл бұрын
Great tip!
@himanshere75376 жыл бұрын
Love your videos Dan! Man you're a magician
@Holobrine6 жыл бұрын
What about saveFrame()?
@laurihei6 жыл бұрын
Ringing the bell at the exact moment it would break :'D
@Schindlabua6 жыл бұрын
The way to clear an array in javascript by the way is `arr.length = 0;` It looks super wonky but it is standards-complaint and works even in strict mode! Just Javascript things.
@ranchieducation63176 жыл бұрын
Loved this video ! Sir, I had some basic knowledge about java from my school studies. I started seeing your videos and I have learnt many a things by your codes but Sir I know almost nothing except java coding. I had bought my first laptop last month and I don't know how to install java, which version to install, I just want that setup with which you work, I had gone through many videos in youtube about how to install java but I could not do that path set up and all. Can you help me by letting me know how to do and what to do to get exactly that entire set up of java with which you work. I am excited to start coding but... guide me please
@TheCodingTrain6 жыл бұрын
I use Processing (which is built on top of the Java programming language) in many of my videos. It's a good way to get started. For more info, visit processing.org and also this video might help kzbin.info/www/bejne/d57PcpyBqM6sZtE.
@ailbae10046 жыл бұрын
u r the smartes man in the world. im death serius
@amirulidzham36866 жыл бұрын
Hey guys, anyone know how to draw a text box like we do in Microsoft PowerPoint, we do it in p5 js? I've tried but as I found it is impossible. Anyone have any tricks?
@TheCodingTrain6 жыл бұрын
Try the text() function! p5js.org/reference/#/p5/text
@MattRose300006 жыл бұрын
I converted this challenge into python/pygame: github.com/MattR0se/Coding-Train/blob/master/lissajous.py Not much deviation from your example though, except some random colors to make it look more interesting.
@TheCodingTrain6 жыл бұрын
Nice work! You can submit a link to the coding train website if you like! github.com/CodingTrain/website/wiki/Community-Contributions-Guide
@pianfensi6 жыл бұрын
Can anyone tell, why the youtube compression was mentioned in both videos? what's the matter with this challenge?
@figfox24256 жыл бұрын
Because unfortunatly, KZbin compression makes thin lines or isolated pixels disappear...
@MattRose300006 жыл бұрын
If there is two much change in pixels going on, KZbin compression freaks out and produces a bigger amount of artifacts. kzbin.info/www/bejne/qGe1oWCrpJt7o6s
@raffaelenicolapiazzolla39276 жыл бұрын
Why the same code is faster on the browser? It should be slower on browser and faster when it run on a pc, right? How is this possible?
@Schindlabua6 жыл бұрын
Javascript engines these days are heavily optimized mammoths; they are so good that you get close-to-native performance in a lot of cases. Ten years ago you would have probably been right but thanks to google pouring millions of dollars into V8 and chrome that's no longer the case. Python is not known to be blazingly fast anyway; I think it's still mostly an interpreted language while Javascript is mostly compiled.
@OonHan6 жыл бұрын
OMG, two different languages are so different!
@artin1375 жыл бұрын
Bell = freeze
@lokeshlkr5 жыл бұрын
#this.Lissajous
@MasterWind026 жыл бұрын
Do a Collatz Conjecture tree next time for us please!
Dan, I have a request for you:) Actually I really want to know how to do this step by step.Maybe a this type of video can help a lot of people like me. For example,I have a fluid simulation article like this-> www.dgp.toronto.edu/people/stam/reality/Research/pdf/ns.pdf ,how to make a simple simulation by using this article? how path should I follow? My mathematical background is not bad,but I need really extra effort to understand this article.This article just an example.I wonder what we should do when we want to simulate anything.Another example that If I want to simulate a lightning bolt,what kind of research should I do? Do I need to understand all of these formulas to simulate this? Your teaching skill is amazing so I think that it would be great to learn this from you:) I hope you can make a video about that.Thank you:)
@Jousef96 жыл бұрын
I watch these video and im not even a programmer LUL ,( but i am an EE so im a little bit programmer tho)
@BloodKiingZ6 жыл бұрын
I feel like this is a stupid question but is it possible for me to use p5.js on mobile .. like write code using my device ?.. because of kinda broke .. so is it possible and if yes .. how?
@atrumluminarium6 жыл бұрын
Let song confirmed?
@OrangeC76 жыл бұрын
Elon Musk leaks spoilers for "Let 2"
@TheCodingTrain6 жыл бұрын
I'm waiting...
@klausbdl6 жыл бұрын
Pls make an 1 hour version of this project. Only fullscreen with some calm music on the background.
@eeddeellwweeiiss6 жыл бұрын
Do a Rubicks cube next time, please))
@hitsoslovepassionaction57076 жыл бұрын
we want to look at you!!!!!!
@sjdpfisvrj6 жыл бұрын
The last bug reinforces the notion for me to stay away from JS if I can. A bug like that should be caught by the language before you even run it
@NethTech6 жыл бұрын
rumborak that's what you get with interpreted languages.