Repository navigation
Conversation
Resetting the random number generator to seed at 0 is done as part of rewinding the `Sketch` path convertor. However, this causes the seed to be reset on every call to `draw` if Agg is being used which interferes with users how are using `rand` in their own code and embedding python [1]. This moves the `srand` call inside the conditional that deals with paths that really are sketched so you only get disrupted if you are really using this feature. 1 http://stackoverflow.com/q/34422244/380231
Member
|
I don't know if that's a system call of just a C library call, but this should be a modest speed improvement as well. As alternative solution might be to not use the C random number calls (which use global state), to using one of the more modern C++ implementations where the object could manage its own state. Or, honestly, if you don't care about crypto (which we don't here) we could just write our own random number generator in a few lines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resetting the random number generator to seed at 0 is done as part
of rewinding the
Sketchpath convertor. However, this causesthe seed to be reset on every call to
drawif Agg is being used whichinterferes with users how are using
randin their own code andembedding python [1].
This moves the
srandcall inside the conditional that deals with pathsthat really are sketched so you only get disrupted if you are really
using this feature.
1 http://stackoverflow.com/q/34422244/380231
@mdboom