From 12b3cd96125a3b396e8fd367b1d78254f0572de6 Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Thu, 26 Mar 2020 00:32:41 +0100 Subject: [PATCH 1/9] started porting from other frameworks section --- src/porting_from_other_frameworks.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/porting_from_other_frameworks.md diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md new file mode 100644 index 0000000..faf612a --- /dev/null +++ b/src/porting_from_other_frameworks.md @@ -0,0 +1,5 @@ +# Porting from other frameworks + +Nannou is inspired by other creative coding frameworks inspired like Processing, OpenFrameworks, and Cinder. +This section is intended to help everyone making the switch to nannou and bringing their code with them. + From 4fff794840b57c81dfe5bb0d5564558230019226 Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Thu, 26 Mar 2020 00:33:30 +0100 Subject: [PATCH 2/9] linked in ToC --- src/SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 50b9921..8ad9ea3 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -15,6 +15,7 @@ - [Basics - Anatomy of a Nannou App](./tutorials/basics/anatomy-of-a-nannou-app.md) - [Basics - Drawing 2D Shapes](./tutorials/basics/drawing-2d-shapes.md) - [Developer Reference](./developer_reference.md) +- [Porting From Other Frameworks](./porting_from_other_frameworks.md) - [API Reference](./api_reference.md) - [Showcases](./showcases.md) From 56dde0d8a78eb58b0a39e74329a463017af919d6 Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Thu, 26 Mar 2020 00:36:06 +0100 Subject: [PATCH 3/9] added links to other frameworks --- src/porting_from_other_frameworks.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md index faf612a..55e4db4 100644 --- a/src/porting_from_other_frameworks.md +++ b/src/porting_from_other_frameworks.md @@ -1,5 +1,6 @@ # Porting from other frameworks -Nannou is inspired by other creative coding frameworks inspired like Processing, OpenFrameworks, and Cinder. +Nannou is inspired by other creative coding frameworks inspired like [Processing](https://processing.org), +[openFrameworks](https://openframeworks.cc), and [Cinder](https://libcinder.org/). This section is intended to help everyone making the switch to nannou and bringing their code with them. From 40bec6196d11be154fc952919b75346a4f67ce97 Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Thu, 26 Mar 2020 00:37:38 +0100 Subject: [PATCH 4/9] listed new sections --- src/porting_from_other_frameworks.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md index 55e4db4..e259f17 100644 --- a/src/porting_from_other_frameworks.md +++ b/src/porting_from_other_frameworks.md @@ -4,3 +4,14 @@ Nannou is inspired by other creative coding frameworks inspired like [Processing [openFrameworks](https://openframeworks.cc), and [Cinder](https://libcinder.org/). This section is intended to help everyone making the switch to nannou and bringing their code with them. +## General +**This section shall contain general information** + +## Processing +**This section shall contain processing-specific information** + +## openFrameworks +**This section shall contain openFrameworks-specific information** + +## Cinder +**This section shall contain Cinder-specific information** From 6c74ebd39a88f57131b09b148a1430dfecce199c Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Thu, 26 Mar 2020 00:46:36 +0100 Subject: [PATCH 5/9] explain setup() emulation from processing --- src/porting_from_other_frameworks.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md index e259f17..fec7fff 100644 --- a/src/porting_from_other_frameworks.md +++ b/src/porting_from_other_frameworks.md @@ -8,7 +8,23 @@ This section is intended to help everyone making the switch to nannou and bringi **This section shall contain general information** ## Processing -**This section shall contain processing-specific information** +Processing has two famous functions. The `setup()` function prepares everything and takes care of +the initial setup. The `draw()` actuallly changes things on the screen. + +Sometimes the `setup()` function is used to prepare the screen (e.g. to set the background). This +behaviour can be emulated using `.nth()`, which counts the number of frames displayed in the +associated window. +```rust +fn view(app: &App, m: &Model, frame: &Frame) { + let draw = app.draw(); + if frame.nth() == 0 { + // do one-time preparations of the screen here + } + // general drawing code + draw.to_frame(app, &frame).unwrap(); +} +``` + ## openFrameworks **This section shall contain openFrameworks-specific information** From be27d454da01e6b47e5d1e6cd5200952618a718f Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Thu, 26 Mar 2020 00:47:39 +0100 Subject: [PATCH 6/9] WIP note --- src/porting_from_other_frameworks.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md index fec7fff..70be957 100644 --- a/src/porting_from_other_frameworks.md +++ b/src/porting_from_other_frameworks.md @@ -4,6 +4,8 @@ Nannou is inspired by other creative coding frameworks inspired like [Processing [openFrameworks](https://openframeworks.cc), and [Cinder](https://libcinder.org/). This section is intended to help everyone making the switch to nannou and bringing their code with them. +**note: This is very much a work in progress. It will be extended as we learn about porting issues.** + ## General **This section shall contain general information** From ec981535f22f9b8990479299fd993b38b696e4ab Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Thu, 26 Mar 2020 01:00:33 +0100 Subject: [PATCH 7/9] slightly better phrasing --- src/porting_from_other_frameworks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md index 70be957..ac8cd97 100644 --- a/src/porting_from_other_frameworks.md +++ b/src/porting_from_other_frameworks.md @@ -13,9 +13,9 @@ This section is intended to help everyone making the switch to nannou and bringi Processing has two famous functions. The `setup()` function prepares everything and takes care of the initial setup. The `draw()` actuallly changes things on the screen. -Sometimes the `setup()` function is used to prepare the screen (e.g. to set the background). This -behaviour can be emulated using `.nth()`, which counts the number of frames displayed in the -associated window. +Sometimes the `setup()` function is used to prepare the screen. Sometimes code already draws +in this phase (e.g. to set the background). This behaviour can be emulated using `.nth()`, which +counts the number of frames displayed in the associated window. ```rust fn view(app: &App, m: &Model, frame: &Frame) { let draw = app.draw(); From 8e127920fdd1edb77b728696a3ef8f60fcffb1bb Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Sat, 28 Mar 2020 13:33:41 +0100 Subject: [PATCH 8/9] relationship setup() and model() --- src/porting_from_other_frameworks.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md index ac8cd97..bb9adb1 100644 --- a/src/porting_from_other_frameworks.md +++ b/src/porting_from_other_frameworks.md @@ -13,6 +13,10 @@ This section is intended to help everyone making the switch to nannou and bringi Processing has two famous functions. The `setup()` function prepares everything and takes care of the initial setup. The `draw()` actuallly changes things on the screen. +Most tasks of the `setup()` function in processing are taken care of by the `model()` function in nannou. +This is where the inital state of the world (model) is created. This model information is then processed +later by other functions. + Sometimes the `setup()` function is used to prepare the screen. Sometimes code already draws in this phase (e.g. to set the background). This behaviour can be emulated using `.nth()`, which counts the number of frames displayed in the associated window. From 9040bd20acbdaf7ad1e10d20d33931469f7419bf Mon Sep 17 00:00:00 2001 From: tpltnt <1172976+tpltnt@users.noreply.github.com> Date: Sat, 28 Mar 2020 13:37:58 +0100 Subject: [PATCH 9/9] draw() vs. view() and update() --- src/porting_from_other_frameworks.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/porting_from_other_frameworks.md b/src/porting_from_other_frameworks.md index bb9adb1..cf20ad9 100644 --- a/src/porting_from_other_frameworks.md +++ b/src/porting_from_other_frameworks.md @@ -31,6 +31,12 @@ fn view(app: &App, m: &Model, frame: &Frame) { } ``` +The `draw()` function in processing is used to both draw on the screen and also to change the state +of to be displayed. Nannou takes a more explicit approach here. The function `view()` in nannou +displays things. Functions like `update()` or `event()` are used to (only) change the state of the +model to be displayed. Thus there are dedicated places which take care of either showing things +or changing things. + ## openFrameworks **This section shall contain openFrameworks-specific information**