O'Reilly logo

Learn JavaScript with p5.js: Coding for Visual Learners by Engin Arslan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Engin Arslan 2018
Engin ArslanLearn JavaScript with p5.jshttps://doi.org/10.1007/978-1-4842-3426-6_7

7. Loops

Engin Arslan
(1)
Toronto, Ontario, Canada
 
One of things that computers are great at is repetition. Imagine having to create a thousand shapes onscreen with varying parameters. It would take us an unreasonable amount of time to do so with our current programming knowledge. For this kind of case where we want to repeat our code as it is or with variations, we can leverage a programming structure called loops. A loop allows us to execute a block of code over and over again.
We are already familiar with the idea of a loop in p5.js. If you think about it, the draw function is a continuous loop that gets executed over and over again until we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required