Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Algorithmic Patterns and Recursion | Advanced Generative Techniques
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Generative Art with JavaScript and P5.js

bookAlgorithmic Patterns and Recursion

index.html

index.html

copy

To create visually complex patterns in generative art, you often rely on algorithms and recursion. Recursion is a programming technique where a function calls itself to solve smaller instances of a problem. In generative art, recursion allows you to build intricate structures—like trees, fractals, or spirals—by repeatedly applying the same drawing logic at different scales and positions.

A recursive function always needs a base case: this is a condition that tells the function when to stop calling itself. Without a base case, the recursion would continue forever, eventually causing a stack overflow error. In the recursive tree example above, the base case is if (len < 8) { return; }, which halts further branching when the branch length becomes small enough. By carefully designing your recursive rules and base cases, you can control the density and complexity of your generative visuals.

Algorithmic thinking is at the heart of generative art. You break down a visual idea into a set of rules or steps that can be repeated or modified programmatically. This approach lets you create patterns that would be difficult or impossible to draw by hand, but are easy for a computer to generate through code. Recursive algorithms, in particular, unlock a world of self-similar, organic, and endlessly intricate designs.

question mark

What is a base case in a recursive function?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 4. Hoofdstuk 1

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

bookAlgorithmic Patterns and Recursion

Veeg om het menu te tonen

index.html

index.html

copy

To create visually complex patterns in generative art, you often rely on algorithms and recursion. Recursion is a programming technique where a function calls itself to solve smaller instances of a problem. In generative art, recursion allows you to build intricate structures—like trees, fractals, or spirals—by repeatedly applying the same drawing logic at different scales and positions.

A recursive function always needs a base case: this is a condition that tells the function when to stop calling itself. Without a base case, the recursion would continue forever, eventually causing a stack overflow error. In the recursive tree example above, the base case is if (len < 8) { return; }, which halts further branching when the branch length becomes small enough. By carefully designing your recursive rules and base cases, you can control the density and complexity of your generative visuals.

Algorithmic thinking is at the heart of generative art. You break down a visual idea into a set of rules or steps that can be repeated or modified programmatically. This approach lets you create patterns that would be difficult or impossible to draw by hand, but are easy for a computer to generate through code. Recursive algorithms, in particular, unlock a world of self-similar, organic, and endlessly intricate designs.

question mark

What is a base case in a recursive function?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 4. Hoofdstuk 1
some-alt