Open lgautier opened 2 years ago
I'm surprised that smoothscale is faster; each pixel will be blended between 4 values rather than just copied. So if this is faster then it should be possible to go faster still...
The (code to run the) benchmark is in a comment for issue #270. Beside numpy
not being as fast as one would expect, possible reasons for increased performance are:
An alternative I have considered is to create a first column of pixels (one pixel per row) and scale across the width. That approach would be better if considering stripes in gradients that are several pixels tall. With a bit of attention this could also help make partial gradients (e.g., sunset or sunrise skies, transition between a planet's atmosphere and space). However, for this to be most useful there would be the need to change the API in pygame zero. Since using scalesmooth was already so much faster that the current implementation, and achieved my goal of removing a strict dependency on numpy
. I did not bother experimenting much further.
Make gradients between 4 and 5 times faster while at it.
This is a proposed partial fix for issue #270. Current version of
ptext
used still requiresnumpy
.