vibesketch.document.highlights

Atoms and bonds marked in colour, on the canvas and in figures (#91).

The canvas engine keeps no highlight in its drawing, so the document does: a Highlight names a species, a colour and the canonical ranks of its marked heavy atoms (RDKit’s CanonicalRankAtoms with ties broken), which every drawing of the species maps back to its own atoms. Bonds between two marked atoms of one highlight are marked too, so marking a ring’s atoms marks the ring. On a symmetric molecule a mark may land on an equivalent atom when the structure is drawn anew, since such atoms are told apart only by their order.

The colours are Okabe and Ito’s palette for colour-vision deficiency (“Color Universal Design”, 2008, https://jfly.uni-koeln.de/color/), printed as an opaque 40 % tint on white so the line art stays legible in every journal preset and in SVG, PNG and PDF alike.

Module Attributes

PALETTE

Okabe and Ito's colours by name.

Functions

highlight_points(document, ket)

Where the marked atoms are drawn in ket, by colour, for the canvas to show.

marks_for(document, species, mol)

The species' highlights as atom indices of mol, a drawing of it, with colours.

tint(colour)

The printed fill of colour: an opaque tint, as RDKit takes colours (0 to 1).

with_highlight(document, species, atoms[, ...])

document with atoms of species marked, numbered from 0 as in its report.

with_selection_highlighted(document, ket, ...)

document with the atoms drawn at points in ket, the canvas's own copy, marked.

without_highlights(document[, species])

document without its highlights, or without those of species.

Exceptions

HighlightRefused

A highlight that cannot be made as asked.

vibesketch.document.highlights.PALETTE: dict[str, str] = {'blue': '#0072B2', 'green': '#009E73', 'orange': '#E69F00', 'purple': '#CC79A7', 'sky-blue': '#56B4E9', 'vermillion': '#D55E00'}

Okabe and Ito’s colours by name.

exception vibesketch.document.highlights.HighlightRefused[source]

Bases: ValueError

A highlight that cannot be made as asked.

vibesketch.document.highlights.highlight_points(document, ket)[source]

Where the marked atoms are drawn in ket, by colour, for the canvas to show.

Parameters:
Return type:

list[dict[str, Any]]

vibesketch.document.highlights.marks_for(document, species, mol)[source]

The species’ highlights as atom indices of mol, a drawing of it, with colours.

Parameters:
Return type:

list[tuple[list[int], str]]

vibesketch.document.highlights.tint(colour)[source]

The printed fill of colour: an opaque tint, as RDKit takes colours (0 to 1).

Parameters:

colour (str)

Return type:

tuple[float, float, float]

vibesketch.document.highlights.with_highlight(document, species, atoms, colour='orange')[source]

document with atoms of species marked, numbered from 0 as in its report.

Parameters:
Return type:

Document

vibesketch.document.highlights.with_selection_highlighted(document, ket, points, colour)[source]

document with the atoms drawn at points in ket, the canvas’s own copy, marked.

Parameters:
Return type:

Document

vibesketch.document.highlights.without_highlights(document, species=None)[source]

document without its highlights, or without those of species.

Parameters:
Return type:

Document