Skip to content
This repository has been archived by the owner on Apr 11, 2020. It is now read-only.

explaining sketch().run() #56

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[book]
title = "The Nannou Guide"
authors = ["mitchmindtree", "JoshuaBatty", "freesig"]
authors = ["mitchmindtree", "JoshuaBatty", "freesig", "tpltnt"]
src = "src"
description = "A one-stop shop for Nannou Knowledge!"
multilingual = false
60 changes: 60 additions & 0 deletions src/getting_started/updating.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,63 @@ the following:
```bash
rustup update
```

## Updating old code

Sometimes you have to touch old code and make it work in a new environment.
This sections helps you deal with problems you might encounter.

In general it helps to read all the CHANGELOG files from your old source
version to the target you want to upgrade to.


### Sketches don't run

Your old code looks like this:
```
extern crate nannou;
use nannou::prelude::*;

fn main() {
nannou::sketch(view);
}

fn view(_app: &App, _frame: Frame) {
// the sketch code
}
```

Nannou 0.13 introduced a change to allow the user to specify the size of the sketch in this way
```
nannou::sketch(view).size(width, height).run()
```

This required changing the `sketch()` function to return a builder type rather than running immediately as done in the past.
Specifying the size of a window in the view function felt awkward and caused a panic on Windows after a winit update.

Adding `.run()` after the sketch function should display the sketch again.
```
extern crate nannou;
use nannou::prelude::*;

fn main() {
nannou::sketch(view).run();
}

fn view(_app: &App, _frame: Frame) {
// the sketch code
}
```

### Window sizing does not work / with_dimension is gone

If you have code like
```
new_window().with_dimension(600,600)
```
won't work after 0.13.1

Use `size()` in this manner:
```
new_window().size(600, 600)
```