Skip to content

Pen-and-ink molecule viewing, inspired by https://github.com/spite/cross-hatching.git (spite) and the Microsoft Research paper on real-time cross-hatching (Praun et al. 2001)

License

Notifications You must be signed in to change notification settings

amacbride/sketchmol

Repository files navigation

SketchMol

Pen-and-ink molecular visualization with real-time cross-hatching.

SketchMol rendering of a molecule

SketchMol renders molecular structures in an artistic pen-and-ink style, inspired by the spite cross-hatching project and the Microsoft Research paper on real-time hatching (Praun et al., 2001).

Features

  • Cross-hatching shading - 6-level progressive hatching based on lighting
  • Interactive viewer - Real-time OpenGL viewer with mouse/keyboard controls
  • Multiple input formats - PDB, XYZ, and SMILES strings
  • CPK colors - Optional element-based coloring
  • Paper textures - Customizable background textures
  • Export - PNG and PDF output

CPK colored molecules lysine

Installation

Using conda (recommended)

conda env create -f env/sketchmol.yaml
conda activate sketchmol

Usage

Interactive Mode (default)

# From a PDB file
python sketchmol.py molecule.pdb

# From a SMILES string
python sketchmol.py "CCO"  # ethanol

# From an XYZ file
python sketchmol.py structure.xyz

Batch Rendering

# Render to PNG
python sketchmol.py molecule.pdb --render -o output.png

# With CPK colors
python sketchmol.py "c1ccccc1" --render --cpk-colors -o benzene.png

# Custom size
python sketchmol.py molecule.pdb --render --width 1920 --height 1080 -o hires.png

Interactive Controls

Control Action
Arrow keys Rotate molecule
WASD Pan view
+/- Zoom in/out
Mouse drag (left) Rotate
Mouse drag (right) Pan
Scroll wheel Zoom
R Reset view
Z Toggle Z-axis rotation mode
F1/F2/F3 Toggle auto-rotate X/Y/Z
Q / Esc Quit

Options

--render          Render to file instead of interactive viewer
-o, --output      Output filename (default: molecule.png)
--width           Width in pixels (default: 800)
--height          Height in pixels (default: 600)
--paper           Paper texture file
--ink R,G,B       Ink color (default: 41,41,202)
--cpk-colors      Use element-based CPK colors
--show-symbols    Show element labels next to atoms
--label-size      Label size: small, medium, or large (default: small)
--no-outline      Disable atom outlines
--solid-render    Solid shading instead of cross-hatching
--radius-scale    Atom radius scale factor (default: 0.15)

Credits

  • Cross-hatching technique inspired by spite/cross-hatching
  • Based on "Real-Time Hatching" by Praun et al. (Microsoft Research, 2001)

License

MIT License - see LICENSE for details.

About

Pen-and-ink molecule viewing, inspired by https://github.com/spite/cross-hatching.git (spite) and the Microsoft Research paper on real-time cross-hatching (Praun et al. 2001)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages