Box#

[1]:
import sys

import fresnel

scene = fresnel.Scene()

The Box geometry is a convenience class that uses the Cylinder geometry to draw a box. The Box geometry supports triclinic boxes and follows hoomd-blue box conventions. For cubic boxes, only one length is needed.

[2]:
my_box = [5]
[3]:
geometry = fresnel.geometry.Box(scene, my_box)
[4]:
scene.camera = fresnel.camera.Orthographic.fit(scene)
fresnel.preview(scene)
[4]:
../../_images/examples_01-Primitives_05-Box-geometry_5_0.png

Orthorhombic boxes require an Lx, Ly, and Lz

[5]:
my_box = [5,6,7]
scene = fresnel.Scene()
geometry = fresnel.geometry.Box(scene, my_box)
scene.camera = fresnel.camera.Orthographic.fit(scene)
fresnel.preview(scene)
[5]:
../../_images/examples_01-Primitives_05-Box-geometry_7_0.png

Triclinic boxes are supported by using 6 terms, Lx, Ly, Lz, xy, xz, yz.

[6]:
my_box = [5,6,7, .2, 0, .9]
scene = fresnel.Scene()
geometry = fresnel.geometry.Box(scene, my_box)
scene.camera = fresnel.camera.Orthographic.fit(scene)
fresnel.preview(scene)
[6]:
../../_images/examples_01-Primitives_05-Box-geometry_9_0.png

The radius defaults to 0.5 but can be specifed when the box is created

[7]:
my_box = [5,6,7, .2, 0, .9]
scene = fresnel.Scene()
geometry = fresnel.geometry.Box(scene, my_box, box_radius=.1)
scene.camera = fresnel.camera.Orthographic.fit(scene)
fresnel.preview(scene)
[7]:
../../_images/examples_01-Primitives_05-Box-geometry_11_0.png

Or changed later

[8]:
geometry.box_radius = 1
scene.camera = fresnel.camera.Orthographic.fit(scene)
fresnel.preview(scene)
[8]:
../../_images/examples_01-Primitives_05-Box-geometry_13_0.png

The box color can also be set on initialization.

[9]:
my_box = [5, 6, 7, 0.2, 0, 0.9]
scene = fresnel.Scene()
geometry = fresnel.geometry.Box(scene, my_box, box_color=[214 / 255, 67 / 255, 9 / 255])
scene.camera = fresnel.camera.Orthographic.fit(scene)
fresnel.preview(scene)
[9]:
../../_images/examples_01-Primitives_05-Box-geometry_15_0.png

Or changed later.

[10]:
geometry.box_color = [0, 51 / 255, 160 / 255]
fresnel.preview(scene)
[10]:
../../_images/examples_01-Primitives_05-Box-geometry_17_0.png

The box size and shape can also be updated.

[11]:
geometry.box = [4, 4, 5, 0.6, 0,0]
fresnel.preview(scene)
[11]:
../../_images/examples_01-Primitives_05-Box-geometry_19_0.png