-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal for NTimes #353
Proposal for NTimes #353
Conversation
This makes a few small tweaks to nannou-org#353 - Make sure that we don't re-draw on every window/app/input event. That is, only draw if we have emitted an update. - Move the app timer to update before emitting events so that the `app.time` field is up-to-date when handling those events. This should probably be fixed in the `Wait` loop mode as well, but that can wait for a future PR. - Add documentation for the new `NTimes` loop mode. - Run `cargo fmt` to keep travis happy. For some reason I'm getting a `panic!` in the `loop_mode.rs` example soon after switching from the `NTimes` loop mode to the `Wait` loop mode, though I'm not sure if it's related to this PR. I'll do some investigating. In the meantime, feel free to merge this if you're happy with the tweaks and your PR should update automatically.
Only draw on updates. Update app timer before events. Update docs.
@JoshuaBatty do you remember there being some nature of code examples or generative gestaltung examples that required a "draw once" kinda thing? Maybe it's worth trying to get those updated in this PR too so they don't lag behind? |
I'll have a look now through the NOC examples and see which ones where waiting for this feature. |
Hi @CGUTA I just made a PR to your branch that adds in 4 new recursion examples that take advantage of this new |
adding in 4 NOC fractal examples with loop_once mode
It looks like this needs a |
src/app.rs
Outdated
@@ -1436,6 +1479,98 @@ where | |||
} | |||
} | |||
|
|||
// Run the application loop under the `Wait` mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh woops, just realised this comment needs to be fixed.
Time for v0.10! Here are some of the main changes to look out for: **Colour Overhaul** nannou-org#355 The **palette** crate dependency has been updated from v0.2 to v0.4. Nannou's old named colours (e.g. DARK_BLUE, PURPLE, etc based on the Tango desktop color selection) have been removed in favour of using the named colours provided by palette which are much more extensive and based on the the CSS spec. This means there's a high chance some of your code or colors might break! In some cases certain colours will be missing, in other cases the colour may now look different. We've added a new `named_color_reference.rs` example that should hopefully make it a little easier to find equivalent colours from the new selection. Friendlier colour constructors have been added to the prelude, so e.g. now we can do `rgb(r, g, b)` rather than `Rgb::new(r, g, b)`. The same goes for `hsl`, `hsv`, etc. The color constructors that take a continuous hue value as an argument (e.g. `hsl`, `hsv`) have been simplified so that they now expect the hue as a normalised value between 0.0 and 1.0. **View API Tweak** nannou-org#368 The `view` function used for presenting graphics to the frame for a window has been changed slightly so that the `Frame` argument is taken by reference, rather than by value. See nannou-org#366 for the motivation behind this change. This should hopefully be an easy fix - check out any of the updated examples to see how to update your view function signature. **Audio and OSC Refactor** nannou-org#331 nannou-org#334 The `osc` and `audio` modules have been moved into their own `nannou_osc` and `nannou_audio` crates respectively. This should hopefully speed up compile times a little for users who are using nannou purely for graphics/sketches and don't require either. There is very little difference in terms of usage and if you are using either the `osc` or `audio` modules breakage should be minimal - you can check out the osc or audio examples and the linked PRs for a demonstration of how to update your code. **NTimes Loop Mode** nannou-org#353 A new loop mode has been added that allows for looping *n* number of times before stopping and presenting only the last frame. This should be useful for users who only wish to render a single frame, or perhaps a specific number of frames for a fixed length animation. --- For more information on the other changes included within this release checkout the CHANGELOG!
I duplicated the Wait loop mode to get to know the code and because I think it is close (in edits) to what the Ntimes loop mode must be.
I moved the update execution inside an if. It only runs if there are pending updates within the specified framerate.
The window is still drawn and window events are still received, just no update is processed.
I am getting warnings because now
mut number_of_updates: usize,
is not used. But I could not manage to remove it, I do not understand whatufe
is innumber_of_updates: ufe,
.In this way the method guarantees that only the specified update events will be called. Which can be called as necessary to respond to events.