Drawing with Emitters

Play Drawing with Emitters
Sign in to queue

The Discussion

  • User profile image

    pColor on line 47 is not used at all. Also, I wrote lines 33-35 like this: 

    var nextParticle = particles[particleIndex++];
    particleIndex %= particles.length;
    nextParticle.reset(targetx, targety);

    %= will constrain the particleIndex to the size of the array, so once particleIndex is 100, the 100 % 100 = 0, 101 % 100 = 1, etc. I post-increment particleIndex as soon as it's used, as this is a little clearer for me here than inside an if, and it makes the line that follows simpler. The only downside that I can see to this is that it's writing to particleIndex twice at every call, whereas your implementation will only write twice every 100 calls. Considering that this is fired based on user input, though, I'd say that this becomes insignificant.Overall this was a good video, and I really enjoyed playing with the numbers and seeing the changes occur.

  • User profile image
    Thanks for the code, zshift! I've never thought of doing it that way, but will definitely keep it in mind as well. Looks clean.
  • User profile image

    rbarraza thanks for the videos, I've watched 3 of them so far and I've been doing them in d3.js and using svg instead of canvas. All your explainations have been easy for me to follow and recreate. Thank you. I've also used jquery ui slider control and knockoutjs to create controls for the numbers so I could tweek the settings while viewing the visualizations. I've been having a lot of fun with these. Keep em coming :)

  • User profile image


    First - awesome manatee pic. You're already a winner. Second, that sounds really cool! If you ever put those up publicly, let me know. I'd love to check them out and help spread the word. Nice.

Add Your 2 Cents