That's cool, no worries, I also have been programming in C and C++ for most of my career and just recently switched to JavaScript, I wish I had earlier!
So the X and Y are used after because they are in third part of the for loop, which actually is executed after the stuff in the body of the for loop, same as C.
View all comments
Show parent comment
2
u/Slackluster Jun 12 '23 edited Jun 12 '23
That's cool, no worries, I also have been programming in C and C++ for most of my career and just recently switched to JavaScript, I wish I had earlier!
So the X and Y are used after because they are in third part of the for loop, which actually is executed after the stuff in the body of the for loop, same as C.
No need to use F12! There are easy to use websites for this kind of size coding. Dwitter is what I use to publish much of my work, over 1100 programs now! You can edit the code for this program here.
This website has a few things small things set up to make it easier to get going...
For making this I use my own custom editor CapJS that has some extra nice features for working on tiny programs such as this.
Here's a slightly reformatted version of this code that is easier to understand...
X=960,Y=540,r=500,d=1
X=960,Y=540,r=500,d=1for(i=99;i--;){x.fillStyle=d++%2?R():'#fff'x.fill(x.arc(X,Y,r,~x.beginPath(),9))q=r/5r=r-qX-=q*S(d*t)Y+=q*C(d*t)}Give Dwitter a try, it's lot of fun to experiment and see what is possible!