crystal_toolkit.core.scene module
- class crystal_toolkit.core.scene.Arrows(positionPairs: list[list[list[float]]], _animate: list[list[list[float]]] | None = None, color: str | None = None, radius: float | None = None, headLength: float | None = None, headWidth: float | None = None, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
Primitive
Create a set of arrows. All arrows will have the same color radius and head shape. :param positionPairs: This is a list of pairs of lists corresponding to the start and end position of the cylinder. :param color: Cylinder color as a hexadecimal string, e.g. #ff0000 :param radius: The radius of the cylinder, defaults to 1. :param visible: If False, will hide the object by default. :param reference: name to reference the primitive for callback :param clickable: if true, allows this primitive to be clicked and trigger and event
- property bounding_box: list[list[float]]
- clickable: bool = False
- color: str | None = None
- headLength: float | None = None
- headWidth: float | None = None
- property key
- positionPairs: list[list[list[float]]]
- radius: float | None = None
- reference: str | None = None
- type: str = 'arrows'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Bezier(controlPoints: list[list[list[float]]] | None = None, color: list[str] | None = None, radius: list[float] | None = None, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
object
A tube shaped by Bézier control points.
- clickable: bool = False
- color: list[str] | None = None
- controlPoints: list[list[list[float]]] | None = None
- radius: list[float] | None = None
- reference: str | None = None
- type: str = 'bezier'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Convex(positions: list[list[float]], _animate: list[list[float]] | None = None, color: str | None = None, opacity: float | None = None, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
object
Create a surface from the convex hull formed by list of points. Note that at least four points must be specified. The current Three.js renderer uses the QuickHull algorithm. Opacity can be set to enable transparency, but note that the current Three.js renderer doesn’t support nested transparent objects very well.
- property bounding_box: list[list[float]]
- clickable: bool = False
- color: str | None = None
- opacity: float | None = None
- positions: list[list[float]]
- reference: str | None = None
- type: str = 'convex'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Cubes(positions: list[list[float]], _animate: list[list[float]] | None = None, color: str | None = None, width: float | None = None, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
Primitive
Create a set of cubes. All cubes will have the same color and width. :param positions: This is a list of lists corresponding to the vector positions of the cubes. :param color: Cube color as a hexadecimal string, e.g. #ff0000 :param width: The width of the cube, defaults to 1. :param visible: If False, will hide the object by default. :param reference: name to reference the primitive for callback :param clickable: if true, allows this primitive to be clicked and trigger and event
- clickable: bool = False
- color: str | None = None
- property key
- positions: list[list[float]]
- reference: str | None = None
- type: str = 'cubes'
- visible: bool | None = None
- width: float | None = None
- class crystal_toolkit.core.scene.Cylinders(positionPairs: list[list[list[float]]], _animate: list[list[list[float]]] | None = None, color: str | None = None, radius: float | None = None, visible: bool | None = None, tooltip: str | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
Primitive
Create a set of cylinders. All cylinders will have the same color and radius. :param positionPairs: This is a list of pairs of lists corresponding to the start and end position of the cylinder. :param color: Cylinder color as a hexadecimal string, e.g. #ff0000 :param radius: The radius of the cylinder, defaults to 1. :param visible: If False, will hide the object by default. :param reference: name to reference the primitive for callback :param clickable: if true, allows this primitive to be clicked and trigger and event
- property bounding_box: list[list[float]]
- clickable: bool = False
- color: str | None = None
- property key
- positionPairs: list[list[list[float]]]
- radius: float | None = None
- reference: str | None = None
- tooltip: str | None = None
- type: str = 'cylinders'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Ellipsoids(scale: list[float], positions: list[list[float]], rotate_to: list[list[float]], _animate: list[list[float]] | None = None, color: str | None = None, phiStart: float | None = None, phiEnd: float | None = None, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
Primitive
Create a set of ellipsoids. All ellipsoids will have the same color, radius and segment size (if only drawing a section of a ellipsoid). :param scale: This is the scale to apply to the x,y and z axis of the ellipsoid prior to rotation to the target axes :param positions: This is a list of lists corresponding to the vector positions of the ellipsoids. :param rotate_to: This is a list of vectors that specify the direction the major axis of the ellipsoid should point
towards. The major axis is the z-axis: (0,0,1)
- Parameters
color – Ellipsoid color as a hexadecimal string, e.g. #ff0000
phiStart – Start angle in radians if drawing only a section of the
ellipsoid, defaults to 0 :param phiEnd: End angle in radians if drawing only a section of the ellipsoid, defaults to 2*pi :param visible: If False, will hide the object by default. :param reference: name to reference the primitive for callback :param clickable: if true, allows this primitive to be clicked and trigger and event
- clickable: bool = False
- color: str | None = None
- property key
- phiEnd: float | None = None
- phiStart: float | None = None
- positions: list[list[float]]
- reference: str | None = None
- rotate_to: list[list[float]]
- scale: list[float]
- type: str = 'ellipsoids'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Label(label: str, labelHover: str | None = None, position: list[list[float]] | None = None, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
object
Add a label to an object.
- clickable: bool = False
- label: str
- labelHover: str | None = None
- position: list[list[float]] | None = None
- reference: str | None = None
- type: str = 'labels'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Lines(positions: list[list[float]], _animate: list[list[float]] | None = None, color: str | None = None, linewidth: float | None = None, scale: float | None = None, dashSize: float | None = None, gapSize: float | None = None, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
Primitive
Create a set of lines. All lines will have the same color, thickness and (optional) dashes. :param positions: This is a list of lists corresponding to the positions of the lines. Each consecutive pair of vectors corresponds to the start and end position of a line segment (line segments do not have to be joined together). :param color: Line color as a hexadecimal string, e.g. #ff0000 :param linewidth: The width of the line, defaults to 1 :param scale: Optional, if provided will set a global scale for line dashes. :param dashSize: Optional, if provided will specify length of line dashes. :param gapSize: Optional, if provided will specify gap between line dashes. :param visible: If False, will hide the object by default. :param reference: name to reference the primitive for callback :param clickable: if true, allows this primitive to be clicked and trigger and event
- clickable: bool = False
- color: str | None = None
- dashSize: float | None = None
- gapSize: float | None = None
- property key
- linewidth: float | None = None
- positions: list[list[float]]
- reference: str | None = None
- scale: float | None = None
- type: str = 'lines'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Primitive[source]
Bases:
object
A Mixin class for standard plottable primitive behavior. For now, this just enforces some basic mergeability.
- property bounding_box: list[list[float]]
- abstract property key
- positions: tuple
- class crystal_toolkit.core.scene.Scene(name: str, contents: list = <factory>, origin: list[float] = (0, 0, 0), visible: bool = True, lattice: list[list[float]] | None = None, _meta: dict | None = None)[source]
Bases:
object
A Scene is defined by its name (a string, does not have to be unique), and its contents (a list of geometric primitives or other Scenes).
- property bounding_box: list[list[float]]
Returns the bounding box coordinates
- contents: list
- lattice: list[list[float]] | None = None
- static merge_primitives(primitives)[source]
If primitives are of the same type but differ only in position, they are merged together. This is a small optimization, has not been benchmarked. :param primitives: list of primitives (Spheres, Cylinders, etc.) :return: list of primitives
- name: str
- origin: list[float] = (0, 0, 0)
- to(filename)[source]
Write a Scene to a file. Can be opened by Jupyter Lab if Crystal Toolkit extension installed.
- Parameters
filename – The filename (can include path),
an extension will be set if not supplied. :return:
- to_json()[source]
Convert a Scene into JSON. It will implicitly assume all None values means that that attribute uses its default value, and so will be removed from the JSON to reduce the file size of the resulting JSON.
Note that this function actually returns a Python dict, but in a format that can be converted to a JSON string using the standard library JSON encoder.
- Parameters
scene – A Scene object
- Returns
dict in a format that can be parsed by CrystalToolkitSceneComponent
- visible: bool = True
- class crystal_toolkit.core.scene.Spheres(positions: list[list[float]], _animate: list[list[float]] | None = None, color: str | None = None, radius: float | None = None, phiStart: float | None = None, phiEnd: float | None = None, visible: bool | None = None, tooltip: str | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
Primitive
Create a set of spheres. All spheres will have the same color, radius and segment size (if only drawing a section of a sphere). :param positions: This is a list of lists corresponding to the vector positions of the spheres. :param color: Sphere color as a hexadecimal string, e.g. #ff0000 :param radius: The radius of the sphere, defaults to 1. :param phiStart: Start angle in radians if drawing only a section of the sphere, defaults to 0 :param phiEnd: End angle in radians if drawing only a section of the sphere, defaults to 2*pi :param visible: If False, will hide the object by default. :param reference: name to reference the primitive for callback :param clickable: if true, allows this primitive to be clicked and trigger and event
- clickable: bool = False
- color: str | None = None
- property key
- phiEnd: float | None = None
- phiStart: float | None = None
- positions: list[list[float]]
- radius: float | None = None
- reference: str | None = None
- tooltip: str | None = None
- type: str = 'spheres'
- visible: bool | None = None
- class crystal_toolkit.core.scene.Surface(positions: list[list[float]], _animate: list[list[float]] | None = None, normals: list[list[float]] | None = None, color: str | None = None, opacity: float | None = None, show_edges: bool = False, visible: bool | None = None, clickable: bool = False, reference: str | None = None, _meta: Any = None)[source]
Bases:
object
Define a surface by its vertices. Please also provide normals if known. Opacity can be set to enable transparency, but note that the current Three.js renderer doesn’t support nested transparent objects very well.
- property bounding_box: list[list[float]]
- clickable: bool = False
- color: str | None = None
- normals: list[list[float]] | None = None
- opacity: float | None = None
- positions: list[list[float]]
- reference: str | None = None
- show_edges: bool = False
- type: str = 'surface'
- visible: bool | None = None