Style Module

This module contains classes for styling molecular depictions.

class Color(r: int, g: int, b: int)[source]

A color in RGB format.

Initialize the color.

Parameters:
  • r (int) – The red component of the color.

  • g (int) – The green component of the color.

  • b (int) – The blue component of the color.

Raises:

TypeError – If r, g, or b is not an integer.

to_hex() str[source]

Convert color to a hex string.

Returns:

Hex representation of the color.

Return type:

str

diffuse(alpha: float) Color[source]

Diffuse color with alpha value.

Parameters:

alpha (float) – Diffusion factor.

Returns:

Diffused color.

Return type:

Color

Raises:

TypeError – If alpha is not a float.

class AtomColoringScheme[source]

Abstract base class for atom coloring schemes.

abstract get_color(atom_symbol: str) Color[source]

Return the color of an atom.

Parameters:

atom_symbol (str) – The symbol of the atom.

Returns:

The color of the atom.

Return type:

Color

class CoreyPaulingKoltungAtomColor[source]

Corey-Pauling-Koltun coloring convention for atoms.

Source: https://en.wikipedia.org/wiki/CPK_coloring

get_color(atom_symbol: str) Color[source]

Return the color of an atom.

Parameters:

atom_symbol (str) – The symbol of the atom.

Returns:

The color of the atom.

Return type:

Color

class AtomRadiusScheme[source]

Abstract base class for atom radius schemes.

abstract to_angstrom(atom_symbol: str) float[source]

Return the radius of an atom in angstrom.

Parameters:

atom_symbol (str) – The symbol of the atom.

Returns:

The radius of the atom in angstrom.

Return type:

float

class PubChemAtomRadius[source]

Atomic radii (van der Waals) in picometer from PubChem.

Source: https://pubchem.ncbi.nlm.nih.gov/periodic-table/#property=AtomicRadius

to_angstrom(atom_symbol: str) float[source]

Return the radius of an atom in angstrom.

Parameters:

atom_symbol (str) – The symbol of the atom.

Returns:

The radius of the atom in angstrom.

Return type:

float

class Depiction[source]

Abstract base class for depiction styles.

class Cartoon(fill_color: ~cinemol.style.Color, outline_color: ~cinemol.style.Color = <factory>, outline_width: float = 0.05, opacity: float = 1.0)[source]

Cartoon fill style.

Parameters:
  • fill_color (Color) – The color of the fill.

  • outline_color (Color) – The color of the stroke.

  • outline_width (float) – The width of the stroke.

  • opacity (float) – The opacity of the fill.

class Glossy(fill_color: Color, opacity: float = 1.0)[source]

Glossy fill style.

Parameters:
  • fill_color – The color of the fill.

  • outline_color – The color of the stroke.

class FillStyle[source]

Abstract base class for fill styles.

class Wire(stroke_color: Color, stroke_width: float, opacity: float)[source]

Wire fill style.

Initialize the wire fill style.

Parameters:
  • stroke_color (Color) – The color of the stroke.

  • stroke_width (float) – The width of the stroke.

  • opacity (float) – The opacity of the stroke.

class Solid(fill_color: Color, stroke_color: Color, stroke_width: float, opacity: float)[source]

Solid fill style.

Initialize the solid fill style.

Parameters:
  • fill_color (Color) – The color of the fill.

  • stroke_color (Color) – The color of the stroke.

  • stroke_width (float) – The width of the stroke.

  • opacity (float) – The opacity of the fill.

class RadialGradient(fill_color: Color, center: Point2D, radius: float, opacity: float)[source]

Radial gradient fill style.

Initialize the radial gradient fill style.

Parameters:
  • fill_color (Color) – The color of the radial gradient.

  • center (Point2D) – The center of the radial gradient.

  • radius (float) – The radius of the radial gradient.

  • opacity (float) – The opacity of the radial gradient.

class LinearGradient(fill_color: Color, start: Point2D, end: Point2D, opacity: float)[source]

Linear gradient fill style.

Initialize the linear gradient fill style.

Parameters:
  • fill_color (Color) – The color of the linear gradient.

  • start (Point2D) – The start of the linear gradient.

  • end (Point2D) – The end of the linear gradient.

  • opacity (float) – The opacity of the linear gradient.

class Fill(reference: str, fill_style: FillStyle)[source]

Fill style.

Parameters:
  • reference (str) – The reference of the fill style.

  • fill_style (FillStyle) – The fill style.

to_svg() Tuple[str, str | None][source]

Return the SVG representation of the fill style.

Returns:

The SVG representation of the fill style. The first string is the style string, the second string is the definition string.

Return type:

str, str

Raises:

TypeError – If the fill style is not a FillStyle.