vapory
vapory copied to clipboard
How to add new povray elements to vapory?
tl;dr: How does the syntax used in the class documentation comments that specify a POVRayElement's content work?
I'm trying to make heightfields available in vapory. From the existing POVRayElements, I deduce the syntax should be something like """ 'parameter_name', default_value_implying_type, 'parameter2_name', another_default """
.
-
How about string parameters?
-
How does that work for something like ImageMap which doesn't have a named parameter? If I extend ImageMap like this:
""" ImageMap('image', 'my_image.png') """
(before adding additional image_map parameters), Python throws the following at me:Traceback (most recent call last): File "scene.py", line 36, in <module> VideoClip(make_frame, duration = 2).write_gif("anim.gif",fps = 20) File "/Library/Python/2.7/site-packages/moviepy/video/VideoClip.py", line 106, in __init__ self.size = self.get_frame(0).shape[:2][::-1] File "<decorator-gen-14>", line 2, in get_frame File "/Library/Python/2.7/site-packages/moviepy/decorators.py", line 89, in wrapper return f(*new_a, **new_kw) File "/Library/Python/2.7/site-packages/moviepy/Clip.py", line 95, in get_frame return self.make_frame(t) File "scene.py", line 31, in make_frame return scene(t).render(width = 300, height = 200, File "scene.py", line 14, in scene ImageMap(image = "map.png"), TypeError: __init__() got an unexpected keyword argument 'image'
This is vapory 0.1.1 from pip on Python 2.7.
please provide the whole code (in particular the implementation of imagemap)
I'm sorry, should've added that right away. The whole implementation is this (actual code wasn't changed):
class ImageMap(POVRayElement):
""" ImageMap('image', 'my_image.png') """
povray_name= 'image_map'
url = wikiref+'Image_Map'
The code using it is this (excerpt):
sphere1 = Sphere([-4, 2, 2], 2.0,
ImageMap(image = "map.png"))
(Not sure if that would even result in correct pov syntax, but I'd expect vapory to write at least a pov file I can check manually.)
I actually only changed the class comment but don't really understand how it is parsed. Reading vapory's readme again (RTFM, future self!), I understand that those comments are not parsed by some magic but simple usage instructions. I see now how POVRayElement
works, but I don't get how ImageMap breaks here as the default implementation of POVRayElement works the same way f.e. for Camera
.