ChemfilesViewer.add_label!Method
function add_label!(label::AbstractDict{String,<:Any}; chemviewer_id::String="")

Adds a labels. Examples:

add_label!(Dict(
    "label" => "label text",
    "location" => [0,0,2],
    "color" => "#f00000"
))

add_label!(Dict(
    "label" => "some other text",
    "location" => [2,5,5],
    "style" => "font-weight:bold;color:blue;"
))

If the chemviewer_id is not specified, the most recent instance is used.

ChemfilesViewer.clear_labels!Method
function clear_labels!(; chemviewer_id::String="")

Removes all labels (except for the atom-labels) from the render.

If the chemviewer_id is not specified, the most recent instance is used.

ChemfilesViewer.fadeout_imgFunction
fadeout_img(fname::String, ratio::Real=0.08)

Creates a fadeout image from and image specified by its filename fname by making a gradient of relative width ratio.

ChemfilesViewer.fadeout_imgFunction
fadeout_img(img::Matrix{<:RGBA}, ratio::Float=0.08)

Creates a fadeout image from img by making a gradient of relative width ratio. img is given as a Matrix of `RGBA values.

ChemfilesViewer.generate_dict_moleculeMethod
function generate_dict_molecule(molecule::Chemfiles.Frame; atom_labels=false)

Generate a dictionary for the molecule specifying the atoms, bonds and unit cell. If atom_labels is true, then labels will be generated for each atom.

ChemfilesViewer.get_referenceMethod
get_reference(chemviewer_id::String)

Helper function to get the most recent output reference (i.e. Window or Vector of Observable) associated with the given chemviewer_id.

ChemfilesViewer.render_dict_moleculeMethod
render_dict_molecule(dict_molecule::AbstractDict{String,<:Any}; chemviewer_id::String="", options::AbstractDict{String,<:Any}=Dict{String,Any}(), output::String="")

Render the molecule from a dictionary containing the atoms, bonds and unit cell. If chemviewer_id is not given, a new electron window will be created. Additional options for rendering can be provided.

The parameter output specfies whether to display the render in an external window (when set to external) or inline within Jupyter or Pluto (when set to inline). Leaving output empty will autodetect the output medium.

ChemfilesViewer.render_dict_molecule_externalMethod
function render_dict_molecule_external(dict_molecule::AbstractDict{String,<:Any}; chemviewer_id::String="", options::AbstractDict{String,<:Any}=Dict{String,Any}())

Render the molecule from a dictionary containing the atoms, bonds and unit cell. If chemviewer_id is not given, a new electron window will be created. Additional options for rendering can be provided. The render is shown in an external window.

ChemfilesViewer.render_dict_molecule_inlineMethod
function render_dict_molecule_inline(dict_molecule::AbstractDict{String,<:Any}; chemviewer_id::String="", options::AbstractDict{String,<:Any}=Dict{String,Any}())

Render the molecule from a dictionary containing the atoms, bonds and unit cell. If chemviewer_id is not given, a new electron window will be created. Additional options for rendering can be provided. The render is shown inline in Jupyter or Pluto.

ChemfilesViewer.render_moleculeMethod
function render_molecule(molecule::Chemfiles.Frame; chemviewer_id::String="", options::AbstractDict{String,<:Any}=Dict{String,Any}(), atom_labels=false, output::String="")

Render the molecule (a Chemfiles frame). If chemviewer_id is not given, a new electron window will be created. Additional options for rendering can be provided.

If atom_labels is true, then labels will be generated for each atom.

The parameter output specfies whether to display the render in an external window (when set to external) or inline within Jupyter or Pluto (when set to inline). Leaving output empty will autodetect the output medium.

ChemfilesViewer.save_imageMethod
function save_image(filename::AbstractString; chemviewer_id::String="")

Save a png image of the render to filename. The image size is specified by the parameters renderWidth and renderHeight, which can be set by set_options!.

Note that labels are not saved. To save the labels use save_image_labels.

If the chemviewer_id is not specified, the most recent instance is used.

ChemfilesViewer.save_image_labelsMethod
function save_image_labels(filename::AbstractString; chemviewer_id::String="")

Save a png image of the labels in the render to filename. The image size is specified by the parameters renderWidth and renderHeight, which can be set by set_options!.

Note that this is an experimental feature. The resulting image might deviate from what is rendered in the output.

If the chemviewer_id is not specified, the most recent instance is used.

ChemfilesViewer.save_overlayMethod
function save_overlay(filename::AbstractString, filename_input1::AbstractString, filename_input2::AbstractString)

Saves an image to filename that is constructed from overlaying filename_input2 over filename_input1.

ChemfilesViewer.set_camera_position!Function
function set_camera_position!(axis::String="z", direction::String="+"; chemviewer_id::String="")

Set the camera position to be along one of the axis x, y, z or the unit cell vectors a, b, c. The direction of + or - specifies in which direction the camera is moved. If the chemviewer_id is not specified, the most recent instance is used.

ChemfilesViewer.set_options!Method
function set_options!(options::AbstractDict{String,<:Any}; chemviewer_id::String="")

Set options for the render. Available options are:

  • shader: basic, phong, lambert (default)
  • drawingType: ball and stick (default), space filling, wireframe
  • cameraType: perspective (default), orthographic
  • quality: high (default), low
  • showUnitCell: true (default), false
  • showLabels: true, false (default)
  • styles: dictionary of element styles, e.g. Dict("Au" => Dict("color" => "#f0f0c0", "radius" => 2.6))
  • cameraFov: field of view of the perspective camera, default is 40
  • cameraDistance: distance of the perspective camera, will be automatic
  • cameraZoom: camera zoom, default is 1
  • cameraAxis: set the camera view along this axis (x, y, z (default) or the unit cell vectors a, b, c), see also set_camera_position!
  • cameraAxisDirection: direction of the camera along cameraAxis: + (default), -
  • hemisphereLightIntensity: light intensity of hemiphere light, defaults to 1.0
  • directionalLightIntensity: light intensity of directional light, defaults to 0.05
  • center: center of the render, will be automatically calculated if not given
  • rotateSpeed: speed of rotation via mouse control, defaults to 2
  • renderWidth: width of the saved image, default is 1600
  • renderHeight: height of the saved image, default is 1600

If the chemviewer_id is not specified, the most recent instance is used.

ChemfilesViewer.write_imageMethod
function write_image(filename::AbstractString, img_base64::String)

Saves a base64 image string to a file.