Thursday, 2 February 2012

Tweaking ChemDoodle

Patrik Rydberg posted some code to automatically scale a molecule in the ChemDoodle canvas. I was looking for something like this for quite some time. Now I could this improve for my settings having molFile from many different sources by first scaling the molecule with the scaleToAverageBondLength(Number length) function.

See an example here:

My code (taken from Patrik) is below:

structure = ChemDoodle.readMOL(molFile);
size = structure.getDimension();
scale = Math.min(canvas.width / size.x, canvas.height / size.y);
canvas.specs.scale = scale * .9;


No comments:

Post a Comment