Coverage for pyrc\core\visualization\color\vpython.py: 67%
6 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-29 15:57 +0200
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-29 15:57 +0200
1# -------------------------------------------------------------------------------
2# Copyright (C) 2026 Joel Kimmich, Tim Jourdan
3# ------------------------------------------------------------------------------
4# License
5# This file is part of PyRC, distributed under GPL-3.0-or-later.
6# ------------------------------------------------------------------------------
8from typing import Generator
9from vpython import vector
10from pyrc.core.visualization.color.color import cycle_palette, initial_discrete_color_map
13def cycle_palette_vpython(cmap: str = initial_discrete_color_map) -> Generator[vector, None, None]:
14 """
15 Yield VPython vector colours from a colormap, cycling indefinitely.
17 Parameters
18 ----------
19 cmap : str
20 Colormap name passed to cycle_palette.
22 Yields
23 ------
24 vector
25 VPython color vector with components (r, g, b) in [0, 1].
27 Examples
28 --------
29 >>> generator = cycle_palette_vpython()
30 >>> first_three_colors = [next(generator) for _ in range(3)])
31 """
32 for rgb in cycle_palette(cmap):
33 yield vector(float(rgb[0]), float(rgb[1]), float(rgb[2]))