"""Small plotting helpers used by the literal MATLAB-to-Python conversions."""

from __future__ import annotations

import numpy as np
from matplotlib.axes import Axes
from matplotlib.patches import FancyArrowPatch


CO = np.array([
    [0, 0, 1],
    [0, 0.5, 0],
    [1, 0, 0],
    [0, 0.75, 0.75],
    [0.75, 0, 0.75],
    [0.75, 0.75, 0],
    [0.25, 0.25, 0.25],
])


def bold_ticks(ax: Axes, fontsize: float) -> None:
    """Apply the MATLAB FontSize/FontWeight settings to both axes."""
    ax.tick_params(labelsize=fontsize)
    for label in ax.get_xticklabels() + ax.get_yticklabels():
        label.set_fontweight("bold")


def arrowhead(
    ax: Axes,
    x: list[float] | tuple[float, float] | np.ndarray,
    y: list[float] | tuple[float, float] | np.ndarray,
    color: str = "k",
    scale: float = 12,
    linewidth: float = 1,
) -> None:
    """Draw an arrowhead at the end of a two-point line."""
    patch = FancyArrowPatch(
        (float(x[0]), float(y[0])),
        (float(x[-1]), float(y[-1])),
        arrowstyle="-|>",
        mutation_scale=scale,
        color=color,
        linewidth=linewidth,
        shrinkA=0,
        shrinkB=0,
    )
    ax.add_patch(patch)
