This notebook is to test generating high quality images with povray and vapory


In [1]:
import numpy as np
from chemview import RepresentationViewer
from chemview.render import render_povray


:0: FutureWarning: IPython widgets are experimental and may change in the future.

In [2]:
coordinates = np.array([[0.0, 0.1, 0.1], [0.01, 0, 0]], 'float32')
colors = [0xFFFFFF, 0xFF999F]
sizes = [0.1, 0.2]

rv = RepresentationViewer(100, 100)
point_id = rv.add_representation('points', {'coordinates': coordinates, 'colors': colors, 'sizes': sizes})
rv

In [3]:
render_povray(rv.get_scene(), width=200, height=200, extra_opts={'radiosity':True})


Out[3]:

In [4]:
# Transparent spheres
transparency = [1.0, 0.5]
rv = RepresentationViewer(100, 100)
point_id = rv.add_representation('points', {'coordinates': coordinates,
                                            'colors': colors,
                                            'sizes': sizes,
                                            'transparency': transparency})
rv

In [5]:
scene = rv.get_scene()
render_povray(rv.get_scene(), width=500, height=200)


Out[5]:

In [6]:
coordinates = np.array([[0.0, 1.1, 0.1], [1, 0, 0]], 'float32')
colors = [0xFFFFFF, 0xFF999F]
radii = [0.1, 0.2]

rv = RepresentationViewer(100, 100)
point_id = rv.add_representation('spheres', {'coordinates': coordinates, 'colors': colors, 'radii': radii})
rv

In [7]:
render_povray(rv.get_scene(), width=200, height=200)


Out[7]:

In [8]:
# Let's try to do surface that represent a handly little squarey
verts = np.array([[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 
                  [1.0, 1.0, 0.0], [1.0, 0.0, 0.0]], 'float32')
faces = np.array([[0, 1, 3], [1, 2, 3]], 'int32')

#rv = RepresentationViewer(100, 100)
point_id = rv.add_representation('surface', { 'verts': verts, 
                                              'faces': faces, 
                                              'style': 'solid',
                                              'color': 0xff00ff})
rv

In [13]:
coordinates = np.array([[0, 0, 1], [1, 0, 0], [0, 1, 0]], 'float32')
colors = np.array([0xFF0000, 0x00FF00, 0x0000FF])
transparency = [1.0, 0.3, 1.0]

rv = RepresentationViewer()
cylinders_id = rv.add_representation('cylinders', {'startCoords': coordinates[[0, 1, 2]],
                                           'endCoords': coordinates[[1, 2, 0]],
                                           'radii': [0.2, 0.1, 0.1],
                                           'colors': colors[[0, 1, 2]].tolist(),
                                           'transparency': transparency})
rv

In [16]:
render_povray(rv.get_scene(), extra_opts={'radiosity': True})


Out[16]:

In [ ]: