Fresnel Backend

The fresnel backend uses fresnel to generate high-quality, ray-traced images of scenes.

All fresnel primitives accept an argument material of type fresnel.material.Material to define how lights interact with the primitives.

Note

Translucency is not currently supported in the fresnel backend. All particles will be opaque.

class plato.draw.fresnel.Scene(*args, tracer_kwargs={}, **kwargs)[source]

A container to hold and display collections of primitives.

Scene keeps track of global information about a set of things to be rendered and handles configuration of optional (possibly backend-specific) rendering parameters.

Global information managed by a Scene includes the size of the viewing window, translation and rotation applied to the scene as a whole, and a zoom level.

Primitives can be added to a scene through the primitives argument of the constructor or the add_primitive method. Primitives can be retrieved by iterating over the scene:

for prim in scene:
    # (do something with prim)

Primitives can also be accessed in the order they were added to the scene using list-like syntax:

first_three_prims = scene[:3]
last_prim = scene[-1]

Optional rendering arguments are enabled as features, which are name-value pairs identifying a feature by name and any configuration of the feature in the value.

This Scene supports the following features:

  • antialiasing: Enable antialiasing, for the preview tracer only. This uses fresnel’s aa_level=3 if set, 0 otherwise.
  • pathtracer: Enable the path tracer. Accepts parameter samples with default value 64.
  • directional_light: Add directional lights. The given vector(s) indicates the light direction. The length of the vector(s) determines the magnitude of the light(s).
  • ambient_light: Enable ambient lighting. The given value indicates the magnitude of the light.
render()[source]

Render this Scene object.

save(filename)[source]

Render and save an image of this Scene.

Parameters:filename – target filename to save the image into
show()[source]

Render the scene to an image and display using IPython.

2D Graphics Primitives

class plato.draw.fresnel.Arrows2D(*args, **kwargs)[source]

A collection of 2D arrows.

Each arrow has an independent position, orientation, color, and magnitude. The shape of arrows can be configured by changing its vertices attribute. The default orientation and scale of the vertices is an arrow centered at (0, 0), pointing in the (1, 0) direction, with length 1.

The origin of the arrows can be shifted to have the base lie on the given position by modifying vertices:

arrows.vertices = arrows.vertices + (0.5, 0)
This primitive has the following attributes:
  • positions: Position of each particle
  • orientations: Orientation quaternion of each particle
  • colors: Color, RGBA, [0, 1] for each particle
  • vertices: Vertices in local coordinates for the shape, to be replicated for each particle (CCW order)
  • outline: Outline width for all particles
class plato.draw.fresnel.Disks(*args, **kwargs)[source]

A collection of disks in 2D.

Each disk can have a different color and diameter.

This primitive has the following attributes:
  • positions: Position of each particle
  • colors: Color, RGBA, [0, 1] for each particle
  • radii: Radius of each particle
  • outline: Outline width for all particles
class plato.draw.fresnel.Polygons(*args, **kwargs)[source]

A collection of polygons.

A Polygons object has a common shape for the whole collection. Each shape can have a different orientation and color. Vertices should be specified in counterclockwise order.

This primitive has the following attributes:
  • positions: Position of each particle
  • orientations: Orientation quaternion of each particle
  • colors: Color, RGBA, [0, 1] for each particle
  • vertices: Vertices in local coordinates for the shape, to be replicated for each particle (CCW order)
  • outline: Outline width for all particles
class plato.draw.fresnel.Spheropolygons(*args, **kwargs)[source]

A collection of rounded polygons.

A Spheropolygons object has a common shape and rounding radius for the whole collection. Each shape can have a different orientation and color. Vertices should be specified in counterclockwise order.

This primitive has the following attributes:
  • positions: Position of each particle
  • orientations: Orientation quaternion of each particle
  • colors: Color, RGBA, [0, 1] for each particle
  • vertices: Vertices in local coordinates for the interior (non-rounded) shape, to be replicated for each particle (CCW order)
  • outline: Outline width for all particles
  • radius: Rounding radius for all particles

3D Graphics Primitives

class plato.draw.fresnel.Box(*args, **kwargs)[source]

A triclinic box frame.

This primitive draws a triclinic box centered at the origin. It is specified in terms of three lattice vector lengths Lx, Ly, Lz and tilt factors, defined using the hoomd-blue schema.

Rather than directly initializing via attributes, Box objects can also be automatically created from box-type objects using the from_box() method.

Examples:

Lx = Ly = Lz = 10
xy = xz = yz = 0
box_primitive = draw.Box(Lx=Lx, Ly=Ly, Lz=Lz, width=width, color=color)
box_tuple = (Lx, Ly, Lz, xy, xz, yz)
box_primitive = draw.Box.from_box(box_tuple)
This primitive has the following attributes:
  • start_points: Beginning coordinate for each line segment
  • end_points: Ending coordinate for each line segment
  • widths: Width of each line segment
  • colors: Color, RGBA, [0, 1] for each line segment
  • Lx: Length of first box vector
  • Ly: Length of second box vector
  • Lz: Length of third box vector
  • xy: Tilt factor between the first and second box vectors
  • xz: Tilt factor between the first and third box vectors
  • yz: Tilt factor between the second and third box vectors
  • width: Width of box line segments
  • color: Color, RGBA, [0, 1] for the box line segments
class plato.draw.fresnel.ConvexPolyhedra(*args, **kwargs)[source]

A collection of identically-shaped convex polyhedra.

Each shape can have its own position, orientation, and color.

This primitive has the following attributes:
  • positions: Position of each particle
  • orientations: Orientation quaternion of each particle
  • colors: Color, RGBA, [0, 1] for each particle
  • vertices: Vertices in local coordinates for the shape, to be replicated for each particle
  • outline: Outline width for all shapes
  • outline: Outline width for all particles
colors

Color, RGBA, [0, 1] for each particle

orientations

Orientation quaternion of each particle

outline

Outline width for all particles

positions

Position of each particle

vertices

Vertices in local coordinates for the shape, to be replicated for each particle

class plato.draw.fresnel.Ellipsoids(*args, **kwargs)[source]

A collection of ellipsoids with identical dimensions.

Each ellipsoid can have its own position, orientation, and color. All shapes drawn by this primitive share common principal axis lengths.

This primitive has the following attributes:
  • positions: Position of each particle
  • orientations: Orientation quaternion of each particle
  • colors: Color, RGBA, [0, 1] for each particle
  • a: Radius in the x-direction
  • b: Radius in the y-direction
  • c: Radius in the z-direction
  • outline: Outline width for all particles
  • vertex_count: Number of vertices used to render ellipsoid
a

Radius in the x-direction

b

Radius in the y-direction

c

Radius in the z-direction

colors

Color, RGBA, [0, 1] for each particle

orientations

Orientation quaternion of each particle

outline

Outline width for all particles

positions

Position of each particle

vertex_count

Number of vertices used to render ellipsoid

class plato.draw.fresnel.Lines(*args, **kwargs)[source]

A collection of line segments.

Each segment can have a different color and width. Lines can be used in both 2D and 3D scenes, but they are currently not shaded and may look out of place in 3D.

This primitive has the following attributes:
  • start_points: Beginning coordinate for each line segment
  • end_points: Ending coordinate for each line segment
  • widths: Width of each line segment
  • colors: Color, RGBA, [0, 1] for each line segment
  • outline: Outline width for all particles
colors

Color, RGBA, [0, 1] for each line segment

end_points

Ending coordinate for each line segment

outline

Outline width for all particles

start_points

Beginning coordinate for each line segment

widths

Width of each line segment

class plato.draw.fresnel.SphereUnions(*args, **kwargs)[source]

A collection of identical sphere-union bodies in 3D.

A SphereUnions object is a union of spheres, each of which has its own color, radius, and local position. The SphereUnions object can be rigidly rotated and translated via its position and orientation attributes.

This primitive has the following attributes:
  • positions: Position of each particle
  • orientations: Orientation quaternion of each particle
  • colors: Color, RGBA, [0, 1] for each sphere in the union
  • points: Positions in local coordinates for the spheres in the union, to be replicated for each particle
  • radii: Radius of each sphere in the union
class plato.draw.fresnel.Spheres(*args, **kwargs)[source]

A collection of spheres in 3D.

Each sphere can have a different color and diameter.

This primitive has the following attributes:
  • positions: Position of each particle
  • colors: Color, RGBA, [0, 1] for each particle
  • radii: Radius of each particle