Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

schotter

> 编程语言
Open source

Nannou/Rust tutorial based on Schotter by Georg Nees

179 stars0 likes2 views
WebsiteGitHub

About

Nannou/Rust tutorial based on Schotter by Georg Nees

Schotter Four Ways

Schotter (German for gravel) is a piece by computer art pioneer Georg Nees. It consists of a grid of squares 12 across and 22 down with random rotation and displacement that increases towards the bottom.

The original was created using a pen plotter. I don't know if Dr. Nees had access to a graphics terminal (fairly rare at the time) to preview the result or if he ran the program multiple times to get different results before choosing this as the final.

Schotter is fairly simple to code; at least it is today with modern graphics libraries. Several other people have written tutorials for how to code this using various platforms. I'm adding to this collection with a series of tutorials for coding it in Rust using the nannou library.

This tutorial assumes you are familiar with the Rust language and, if you will be following along (which I certainly encourage), access to a working Rust coding environment. We will be using a Rust "workspace", which allows grouping multiple related programs together. (You can learn more about workspaces in chapters of The Rust Programming Language or The Cargo Book.)

Here are the steps I use for creating a Rust workspace:

  1. Create a new directory for the workspace.
  2. Create a new file named "Cargo.toml" in that directory with the following contents:
    [workspace]
    members=[ ]
    resolver="3"
    
    [workspace.dependencies]
    nannou = "0.20"
    
    [profile.dev]
    opt-level = 1
    
    [profile.dev.package."*"]
    opt-level = 3

The "members" is a list of workspace members; we'll add our variations to it as we go. Nannou requires it to be at least "2", but we'll use the latest: "3".

The "workspace.dependencies" section lists the common dependencies for the projects in the workspace. Specifying the version of nannou here allows changing it in a single place when we need to change it.

Nannou is updated frequently with new features and bug fixes, so when you start a new project, you may want to be sure you are using the latest version of nannou. You can look that up with the command cargo search nannou. The output will contain a line such as the following:

nannou = "0.20.0"             # A Creative Coding Framework for Rust.

When I first wrote this in May 2021, the latest version was 0.16.0, but a new version was released the next month so I updated this tutorial to use 0.17.0. This actually required changing some of the code since the parameters for the random number generator function gen_range() changed (we'll see this in schotter2). When version 0.18.0 was released five months later, yet more changes were needed. And when version 0.20.0 was released five years later, even more changes were needed. Specifying the exact version of the libraries in Cargo.toml prevents changes from breaking our code when libraries are updated.

The "profile" sections determine what optimization level to use. The first one specifies a low optimization level for the programs in our workspace and the other specifies a high optimization level for the packages it uses (such as nannou). This allows debugging to be used for our programs but makes nannou run much faster.

  1. Optionally initialize configuration management for that directory. I like to use git for this. When I get something I like (and that works), I commit the files in git. Then as I make changes, I can easily compare what I have done to that version, and I can easily revert back to that version if I really mess things up and want to start again. This also makes it easy to publish the result online (for example, on GitHub). There are two steps:

    • Initialize the repository. This can be done with the command line (git init). Alternatively, many editors have a method to do this. For example, in VS Code go to the Source Control view (Ctrl+Shift+G) and click Initialize Repository.

    • Create a file ".gitignore" containing the files that should not be managed by git. For Rust programs there are two:

      /target
      Cargo.lock
  2. Optionally create standard information files in the directory:

    • LICENSE.txt, containing the license you want to use. You can pick one from https://choosealicense.com/; I like the permissive MIT license for most of my generative art code. Just copy the license text, paste it into LICENSE.txt, and fill in the copyright information (year and your name).
    • README.md, containing general information about the project in MarkDown format. If you publish it to GitHub, this file will be displayed on the main repository page.

We'll be coding Schotter four different ways, each building on the previous version. Click a link for a short tutorial; they are designed to be done in order. You can find the end result for each tutorial in the appropriate directory.

Schotter1: Use the nannou "sketch" facility to code a simple version with no frills.

Schotter2: Change the code to a nannou "app" with persistent data and simple keyboard commands to adjust some parameters.

Schotter3: Add a control panel using egui to make it easier to adjust parameters on the fly.

Schotter4: Animate the squares, so they move from the starting grid to their displaced positions, and from there to new positions.

I may add some variations later; after all, that's what creative coding is all about! They may or may not be accompanied by full tutorials. But that's it for now.

Note: This tutorial was updated for nannou version 0.20.0, released in June 2026. This was a major update, rewriting it to use the Bevy game engine. And there are a few glitches in the first version using Bevy. The ones that affect the tutorial are described along with workarounds to make the tutorial work.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言