PageRenderTime 398ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/openclnoise/scaletrans.py

https://github.com/freethenation/OpenCLNoise
Python | 41 lines | 33 code | 8 blank | 0 comment | 1 complexity | b9dea7f2dd21eb3a597b198d642cc07d MD5 | raw file
Possible License(s): MIT
  1. from basefilter import *
  2. class ScaleTrans(BaseFilter):
  3. _filename = "scaletrans.cl"
  4. def __init__(self,scale=(1.0,1.0,1.0),translate=(0.0,0.0,0.0)):
  5. super(type(self),self).__init__()
  6. self._scale = scale
  7. self._translate = translate
  8. def get_name(self):
  9. return "scaletrans"
  10. def get_number_of_inputs(self):
  11. return 1
  12. def __mul__(self,other):
  13. if type(other) in (int,float,long):
  14. return ScaleTrans(scale=map(lambda x: other*x,self.scale),translate=self.translate)
  15. return NotImplemented
  16. def __div__(self,other):
  17. return self * (1.0/other)
  18. @filter_argument(ArgumentTypes.FLOAT4, 0)
  19. def scale():
  20. def fget(self):
  21. return float4(self._scale)
  22. def fset(self, value):
  23. self._scale = float4(value)
  24. return fget, fset, None
  25. @filter_argument(ArgumentTypes.FLOAT4, 1)
  26. def translate():
  27. def fget(self):
  28. return float4(self._translate)
  29. def fset(self, value):
  30. self._translate = float4(value)
  31. return fget, fset, None
  32. def __repr__(self):
  33. return "ScaleTrans(scale=(%.2f,%.2f,%.2f), translate=(%.2f,%.2f,%.2f))" % (self.scale[0],self.scale[1],self.scale[2],self.translate[0],self.translate[1],self.translate[2])