PageRenderTime 429ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/openclnoise/perlin.py

https://github.com/freethenation/OpenCLNoise
Python | 62 lines | 43 code | 12 blank | 7 comment | 0 complexity | 8f9fc15ce12247b36f882c3274b518cd MD5 | raw file
Possible License(s): MIT
  1. from basefilter import *
  2. #~ DISTANCES = {
  3. #~ 'euclidian': 0,
  4. #~ 'manhattan': 1,
  5. #~ 'chebyshev': 2,
  6. #~ 'chessboard': 2,
  7. #~ }
  8. #import re
  9. class Perlin(BaseFilter):
  10. _filename = 'perlin.cl'
  11. def __init__(self,seed=0,maxdepth=8,persistence=0.8,initial_amplitude=0.4,initial_frequency=1.0):
  12. super(type(self),self).__init__()
  13. self._seed = seed
  14. self._maxdepth = maxdepth
  15. self._persistence = persistence
  16. self._initial_amplitude = initial_amplitude
  17. @filter_argument(ArgumentTypes.FLOAT, 0)
  18. def persistence():
  19. def fget(self):
  20. return self._persistence
  21. def fset(self, value):
  22. self._persistence = float(value)
  23. return fget, fset, None
  24. @filter_argument(ArgumentTypes.FLOAT, 1)
  25. def initial_amplitude():
  26. def fget(self):
  27. return self._initial_amplitude
  28. def fset(self, value):
  29. self._initial_amplitude = float(value)
  30. return fget, fset, None
  31. @filter_argument(ArgumentTypes.INT, 2)
  32. def maxdepth():
  33. def fget(self):
  34. return self._maxdepth
  35. def fset(self, value):
  36. self._maxdepth = int(value)
  37. return fget, fset, None
  38. @filter_argument(ArgumentTypes.INT, 3)
  39. def seed():
  40. def fget(self):
  41. return self._seed
  42. def fset(self, value):
  43. self._seed = int(value)
  44. return fget, fset, None
  45. def get_number_of_inputs(self):
  46. return 1
  47. def get_name(self):
  48. return 'perlin'
  49. def __repr__(self):
  50. return "Perlin(seed={0},maxdepth={1},persistence={2},initial_amplitude={3})".format(self._seed, self._maxdepth, self._persistence, self._initial_amplitude)