{ "cells": [ { "cell_type": "markdown", "id": "31ff2524", "metadata": {}, "source": [ "# Add text\n", "\n", "Text labels are 2D, screen-aligned markers you can attach to arbitrary positions. They do not rotate with the 3D scene." ] }, { "cell_type": "code", "execution_count": null, "id": "e7d6dbf1", "metadata": {}, "outputs": [], "source": [ "from ase.build import molecule\n", "from weas_widget import WeasWidget\n", "atoms = molecule(\"C2H6SO\")\n", "viewer = WeasWidget()\n", "viewer.from_ase(atoms)\n", "viewer.avr.model_style = 1\n", "viewer.text.settings = [\n", " {\n", " \"positions\": [atoms.positions[0]],\n", " \"texts\": \"here!\",\n", " \"color\": \"#ff0000\",\n", " \"fontSize\": \"18px\",\n", " \"className\": \"text-label\",\n", " \"renderMode\": \"shape\",\n", " },\n", " {\n", " \"positions\": [atoms.positions[1], atoms.positions[2]],\n", " \"texts\": \"x\",\n", " \"color\": \"#111111\",\n", " \"fontSize\": \"32px\",\n", " \"className\": \"text-label\",\n", " \"renderMode\": \"shape\",\n", " },\n", "]\n", "viewer" ] } ], "metadata": { "kernelspec": { "display_name": "aiida", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }