Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/freestyle/modules/freestyle/shaders.py
| Show First 20 Lines • Show All 875 Lines • ▼ Show 20 Lines | def shade(self, stroke): | ||||
| C = self.__random_center | C = self.__random_center | ||||
| # The directions (and phases) are calculated using a separate | # The directions (and phases) are calculated using a separate | ||||
| # function decorated with an lru-cache. This guarantees that | # function decorated with an lru-cache. This guarantees that | ||||
| # the directions (involving sin and cos) are calculated as few | # the directions (involving sin and cos) are calculated as few | ||||
| # times as possible. | # times as possible. | ||||
| # | # | ||||
| # This works because the phases and directions are only | # This works because the phases and directions are only | ||||
| # dependant on the stroke length, and the chance that | # dependent on the stroke length, and the chance that | ||||
| # stroke.resample() above produces strokes of the same length | # stroke.resample() above produces strokes of the same length | ||||
| # is quite high. | # is quite high. | ||||
| # | # | ||||
| # In tests, the amount of calls to sin() and cos() went from | # In tests, the amount of calls to sin() and cos() went from | ||||
| # over 21000 to just 32 times, yielding a speedup of over 100% | # over 21000 to just 32 times, yielding a speedup of over 100% | ||||
| directions = phase_to_direction(sv_nb) | directions = phase_to_direction(sv_nb) | ||||
| it = iter(stroke) | it = iter(stroke) | ||||
| ▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines | |||||