Created
August 9, 2012 11:59
-
-
Save GrahamDumpleton/3303610 to your computer and use it in GitHub Desktop.
Resin adjust with extended history.
This file contains 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
class ResinAdjust(object): | |
def __init__(self): | |
self._lastBlack = 0 | |
self._lastWhite = 1 | |
def __call__(self, value): | |
value = min(value, 180) | |
if self._lastBlack: | |
if value < 128: | |
self._lastBlack = 0 | |
self._lastWhite = 1 | |
return 0 | |
else: | |
self._lastBlack += 1 | |
return value - min((self._lastBlack**2), 32) | |
else: | |
if value < 128: | |
self._lastWhite += 1 | |
return 20 | |
else: | |
self._lastBlack = 1 | |
self._lastWhite = 0 | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment