cheminfo / openchemlib-js

JavaScript port of OpenChemLib
https://cheminfo.github.io/openchemlib-js/index.html
BSD 3-Clause "New" or "Revised" License
71 stars 21 forks source link

Draw molecule on specific canvas area using drawMolecule #124

Open vdyma opened 2 years ago

vdyma commented 2 years ago

We at Datagrok are using openchemlib for rendering molecules. It is a common task to render multiple molecules simultaneously, but currently it is necessary to use separate canvas element to be able to draw each molecule in a specific area of a larger canvas meaning excessive resources usage. It would be very useful to be able to draw a molecule in a specific canvas area when using drawMolecule by providing such parameters as xy coordinates of top left vertex of the area rectangle as well as its width and height.

targos commented 2 years ago

It looks like something that could be supported, but it needs some thinking about how to expose it in the API. This is where the drawing actually happens: https://github.com/cheminfo/openchemlib-js/blob/77dfc46130dab7a3ad3e85b2527986b78cde6cd8/src/com/actelion/research/gwt/gui/viewer/StructureView.java#L236-L239 Would you like to look into it and propose something?

vdyma commented 2 years ago

It seems the best if drawMolecule function had additional properties of the options parameter that would represent x and y coordinates of top left area vertex, its height and width. Another parameter clear could also prove useful to clear the specified area before drawing.

StLeonidas commented 1 year ago

@targos , this option remains significant. Are there any thoughts if it can or planned to be exposed to API?