Changeset View
Standalone View
release/scripts/freestyle/modules/freestyle/utils.py
| Context not available. | |||||
| getCurrentScene, | getCurrentScene, | ||||
| integrate, | integrate, | ||||
| ) | ) | ||||
| """ | |||||
| Iteration helper functions | |||||
| """ | |||||
| def iter_pair(iterable): | |||||
| it = iter(iterable) | |||||
| prev = next(it) | |||||
| for svert in it: | |||||
| yield prev, svert | |||||
| prev = svert | |||||
| def iter_triplet(iterable): | |||||
| it = iter(iterable) | |||||
| prev = next(it) | |||||
| current = next(it) | |||||
| for obj in it: | |||||
| yield prev, current, obj | |||||
| prev, current = current, obj | |||||
kjym3: I guess this helper function needs to be renamed to `chromatize` as referred to in the code… | |||||
Not Done Inline ActionsI'm still unsure about the name. do you have a prefference? flokkievids: I'm still unsure about the name. do you have a prefference? | |||||
Not Done Inline ActionsI don't really have much preference: rgb_to_grayscale, rgb_to_intensity, chromatize, or whatever makes sense. One option is rgb_to_bw() since the same formula appears in source/blender/blenlib/intern/math_color_inline.c. kjym3: I don't really have much preference: rgb_to_grayscale, rgb_to_intensity, chromatize, or… | |||||
Not Done Inline Actionstook that one flokkievids: took that one | |||||
| def iter_as_cyclic(iterale): | |||||
| it = iter(iterable) | |||||
| first = next(it) | |||||
| it = iter(iterable) | |||||
| for obj in it: | |||||
| yield it | |||||
| yield first | |||||
| Context not available. | |||||
Not Done Inline ActionsThe function name could be rgb_to_intensity or rgb_to_grayscale. There are many named RGB-to-grayscale conversion methods (see http://en.wikipedia.org/wiki/Grayscale for more info), but the formula used here seems not any of them. I don't remember from where I took it... kjym3: The function name could be `rgb_to_intensity` or `rgb_to_grayscale`.
There are many named RGB… | |||||
Not Done Inline ActionsThis helper function seems not to work in the way the name suggests, since prev and svert are not being updated in the for loop. kjym3: This helper function seems not to work in the way the name suggests, since `prev` and `svert`… | |||||
Not Done Inline ActionsOriginally these iter_ helper functions were returning an iterator and extra object(s), because in the caller side, one might need to call 0D/1D functions which take an Interface0DIterator. It is true that returning a stroke vertex instead of an iterator saves one line of code (i.e., sv = it.object), but at the cost of creating an iterator in parallel to the iter_ loop on the caller side if it is necessary to call 0D/1D functions. To me returning an iterator instead of a stroke vertex seems a way to go since it will help make user code simple and straightforward although the extra line sv = it.object might appear clumsy. kjym3: Originally these `iter_` helper functions were returning an iterator and extra object(s)… | |||||
Not Done Inline ActionsI saw this helper function also in your regression test suite. Do you actually want to include this in the freestyle.utils module? kjym3: I saw this helper function also in your regression test suite. Do you actually want to include… | |||||
Not Done Inline ActionsI think it's not needed. (pretty nice recipe though) flokkievids: I think it's not needed. (pretty nice recipe though) | |||||
I guess this helper function needs to be renamed to chromatize as referred to in the code below?