Skip to content

Instantly share code, notes, and snippets.

@GrahamDumpleton
Created August 9, 2012 11:59
Show Gist options
  • Save GrahamDumpleton/3303610 to your computer and use it in GitHub Desktop.
Save GrahamDumpleton/3303610 to your computer and use it in GitHub Desktop.
Resin adjust with extended history.
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