Coding Challenge #116 Continued: Lissajous Curve Table in p5.js

preview_player
Показать описание


Рекомендации по теме
Комментарии
Автор

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.

kenhaley
Автор

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

Daniel-wuui
Автор

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`!

SimonTiger
Автор

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

PranavNutalapati
Автор

That timing on the bell hahaha *ding* “oh wait it broke”

zacharymcarthur
Автор

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.

arsebiscuitsandwine
Автор

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!

dylan
Автор

Instead of 'make2DArray', you could use this: new Array(rows).fill(new Array(cols));
Does the same thing, but in one row.

qoutroy
Автор

4:25 there shouldn't be a new in "new createVector()" but it still works 🤔 I'm surprised x)

loic.bertrand
Автор

You are heaven sent! Thank you so much for making this!

wamaithanyamu
Автор

Love your videos Dan! Man you're a magician

himanshere
Автор

Ringing the bell at the exact moment it would break :'D

laurihei
Автор

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.

Schindlabua
Автор

I converted this challenge into python/pygame:


Not much deviation from your example though, except some random colors to make it look more interesting.

MattRose
Автор

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

ranchieducation
Автор

u r the smartes man in the world. im death serius

ailbae
Автор

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?

raffaelenicolapiazzolla
Автор

OMG, two different languages are so different!

OonHan
Автор

Do a Collatz Conjecture tree next time for us please!

MasterWind
Автор

Pls make an 1 hour version of this project. Only fullscreen with some calm music on the background.

klausbdl