The easiest way to get familiar with nannou is to explore the examples.
Nannou provides three collections of examples:
|A collection of examples with categorised demonstrations of nannou.|
|Examples from Generative Gestaltung, ported from p5.js to nannou.|
|Examples from Nature of Code, ported from Processing to nannou.|
To get the examples we can clone the nannou repository.
git clone https://github.com/nannou-org/nannou
If you do not have
git installed you can press the "Clone or download" button
at the top of this page and then press "Download .zip".
Now, change the current directory to
Run the example using cargo!
cargo run --release --example draw
--release flag means we want to build with optimisations enabled.
The value passed via the
--example flag matches the
name property of an
entry within the
[[examples]] table of the package's
Cargo.toml file. The
path property points to the source file to build:
# Draw [[example]] name = "draw" path = "draw/draw.rs"
If we were to look through the nature of code directory and decide we want to run the following example:
# Chapter 1 Vectors [[example]] name = "1_1_bouncingball_novectors" path = "chp_01_vectors/1_1_bouncingball_novectors.rs"
We could do so with the following:
cargo run --release --example 1_1_bouncingball_novectors
In general, the name of the example will almost always be the file name without
If you are compiling nannou for the first time you will see cargo download and build all the necessary dependencies. This might take a while! Luckily, we only have to wait for this the first time.
Once the example compiles you should see the following window appear.
To run any of the other examples, replace
draw with the name of the