miercuri, 30 august 2017

Fun programming 140: Recursive graphics

http://bit.do/dALXN NGwin secret sale page.
[Comments and more videos at funprogramming.org] Using recursion in computer programs allows us to generate beautiful and complex images with simple programs. Recursion is simply achieved by writing a function that calls itself one or more times. To avoid giving a headache to our computer, it's important to set a limit in how many times the function can call itself. Otherwise it will attempt to call itself infinite times, and the computer will stop liking you. There are different ways to set a limit. You can use a variable to count the recursion depth, and stop when the depth is enough for you. You could also set a limit by drawing shapes that get smaller and smaller, and then stop when they are small enough. In this episode, instead of coming up with random colors for the program, I use a color picker called Gcolor2 to grab colors from a photo. In Windows you can use picpick.org, and in Mac "DigitalColor Meter", already installed by default.

Niciun comentariu:

Trimiteți un comentariu