Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Algorithmic Patterns and Recursion | Advanced Generative Techniques
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

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 1

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

bookAlgorithmic Patterns and Recursion

Deslize para mostrar o menu

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

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 1
some-alt