PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/openclnoise/blend.py

https://github.com/freethenation/OpenCLNoise
Python | 60 lines | 50 code | 10 blank | 0 comment | 1 complexity | f142288aafa07f03e7e1057b5953f3ba MD5 | raw file
Possible License(s): MIT
  1. from basefilter import *
  2. class BlendMode:
  3. NORMAL='Normal'
  4. LIGHTEN='Lighten'
  5. DARKEN='Darken'
  6. MULTIPLY='Multiply'
  7. AVERAGE='Average'
  8. ADD='Add'
  9. SUBTRACT='Subtract'
  10. DIFFERENCE='Difference'
  11. NEGATION='Negation'
  12. SCREEN='Screen'
  13. EXCLUSION='Exclusion'
  14. OVERLAY='Overlay'
  15. SOFTLIGHT='SoftLight'
  16. HARDLIGHT='HardLight'
  17. COLORDODGE='ColorDodge'
  18. COLORBURN='ColorBurn'
  19. LINEARDODGE='LinearDodge'
  20. LINEARBURN='LinearBurn'
  21. LINEARLIGHT='LinearLight'
  22. VIVIDLIGHT='VividLight'
  23. PINLIGHT='PinLight'
  24. HARDMIX='HardMix'
  25. REFLECT='Reflect'
  26. GLOW='Glow'
  27. PHOENIX='Phoenix'
  28. class Blend(BaseFilter):
  29. _filename = 'blend.cl'
  30. def __init__(self,mode=BlendMode.NORMAL):
  31. super(type(self),self).__init__()
  32. self.__mode = mode
  33. def get_number_of_inputs(self):
  34. return 2
  35. @property
  36. def mode(self):
  37. return self.__mode
  38. @mode.setter
  39. def mode(self,value):
  40. if self.__mode != value:
  41. self.__mode = value
  42. self.on_code_dirty(self)
  43. def generate_code(self):
  44. code = '#define /*id*/CHANNEL_BLEND_FUNC ChannelBlend_{0}\n'.format(self.__mode)
  45. code += super(type(self),self).generate_code()
  46. return code
  47. def get_name(self):
  48. return 'blend'
  49. def __repr__(self):
  50. return 'Blend(mode = "{0}")'.format(self.__mode)