Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add new povray elements to vapory? #22

Open
tanuva opened this issue Oct 28, 2015 · 2 comments
Open

How to add new povray elements to vapory? #22

tanuva opened this issue Oct 28, 2015 · 2 comments

Comments

@tanuva
Copy link
Contributor

tanuva commented Oct 28, 2015

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.

@tanuva tanuva changed the title Adding new povray elements to vapory How to add new povray elements to vapory? Oct 28, 2015
@Zulko
Copy link
Owner

Zulko commented Oct 28, 2015

please provide the whole code (in particular the implementation of imagemap)

@tanuva
Copy link
Contributor Author

tanuva commented Oct 29, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants