Molecule Drawing

JavaScript Library

In my high school class, we draw the chocolate molecule with SVG by placing each atom and atomic bond in its appropriate location, with gradients. We could make similar drawings using PHP on the web server, or even C++, which would output the SVG code as text. This project lets you draw many more molecules just by entering the data as a list of atoms with connections.

Draw Your Own

Source data for Adenine



  

Objective: Provide functions for drawing molecules using mostly just data and relatively clean code.

The molecule is an array of atoms, each of which indicates its connections to the other atoms in the molecule. The library has predefined colors for the different atomic elements.

The atoms should fit on a square that is 800x800. The system will try to center the molecule within this grid.

Problems: We still have to figure out and specify the individual atom locations. We could provide a method that lets you specify a hexagon or a pentagon and it would calculate the coordinates.