Skip to content

Commit e5efcef

Browse files
committed
Support head_color option
1 parent 6538312 commit e5efcef

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/phyjax2d/moderngl_vis.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ def __init__(
374374
voffsets: tuple[int, ...] = (),
375375
hoffsets: tuple[int, ...] = (),
376376
sc_color_opt: NDArray | None = None,
377+
head_color_opt: NDArray | None = None,
377378
sensor_color: NDArray | None = None,
378379
sensor_width: float = 0.001,
379380
sensor_fn: Callable[[StateDict], tuple[NDArray, NDArray]] | None = None,
@@ -513,11 +514,16 @@ def collect_sensors(stated: StateDict) -> NDArray:
513514
else:
514515
self._sensors, self._collect_sensors = None, None
515516

517+
if head_color_opt is None:
518+
head_color = np.array([0.5, 0.0, 1.0, 1.0], dtype=np.float32)
519+
else:
520+
head_color = head_color_opt
521+
516522
head_program = self._make_gl_program(
517523
vertex_shader=_LINE_VERTEX_SHADER,
518524
geometry_shader=_LINE_GEOMETRY_SHADER,
519525
fragment_shader=_LINE_FRAGMENT_SHADER,
520-
color=np.array([0.5, 0.0, 1.0, 1.0], dtype=np.float32),
526+
color=head_color.astype(np.float32),
521527
width=np.array([0.004], dtype=np.float32),
522528
)
523529
self._heads = SegmentVA(
@@ -631,6 +637,7 @@ def __init__(
631637
space: Space,
632638
stated: StateDict,
633639
sc_color: NDArray | None = None,
640+
head_color: NDArray | None = None,
634641
sensor_color: NDArray | None = None,
635642
figsize: tuple[float, float] | None = None,
636643
voffsets: tuple[int, ...] = (),
@@ -665,6 +672,7 @@ def __init__(
665672
voffsets=voffsets,
666673
hoffsets=hoffsets,
667674
sc_color_opt=sc_color,
675+
head_color_opt=head_color,
668676
sensor_color=sensor_color,
669677
sensor_width=sensor_width,
670678
sensor_fn=sensor_fn,

0 commit comments

Comments
 (0)