This class provides functionality for drawing the skeletal formula of molecules using the Cairo 2D graphics engine. The most common use case is simply:
MoleculeDrawer().draw(molecule, format='png', path='molecule.png')
molecule is the
Molecule object to draw. You can also
pass a dict of options to the constructor to affect how the molecules are
draw(molecule, format, target=None)¶
Draw the given molecule using the given image format - pdf, svg, ps, or png. If path is given, the drawing is saved to that location on disk. The options dict is an optional set of key-value pairs that can be used to control the generated drawing.
This function returns the Cairo surface and context used to create the drawing, as well as a bounding box for the molecule being drawn as the tuple (left, top, width, height).
Uses the Cairo graphics library to create a skeletal formula drawing of a molecule containing the list of atoms and dict of bonds to be drawn. The 2D position of each atom in atoms is given in the coordinates array. The symbols to use at each atomic position are given by the list symbols. You must specify the Cairo context cr to render to.