# sec_interp.core.utils.rendering module

Rendering and polychromy Utilities Module.

This module provides visualization and coordinate transformation utilities for profile rendering.

sec_interp.core.utils.rendering.calculate_bounds(topo_data: list[tuple[float, float]], geol_data: list[GeologySegment] | None = None) → dict[str, float]

  Calculate the bounding box for all profile data with padding.

  Calculates the minimum and maximum distance and elevation across topography and optional geological segments.

  Parameters:

    - topo_data – List of (distance, elevation) tuples for topography.

    - geol_data – Optional list of geological segments.

  Returns:

    Bounds containing ‘min_d’, ‘max_d’, ‘min_e’, ‘max_e’ with 5% padding.

sec_interp.core.utils.rendering.calculate_interval(data_range: float) → float

  Calculate a ‘nice’ interval for axis labels based on the data range.

  Parameters:

    data_range – The total range of data values (e.g., max_d - min_d).

  Returns:

    A human-readable interval (e.g., 1, 2, 5, 10, etc.) for grid lines.

sec_interp.core.utils.rendering.create_coordinate_transform(bounds: dict[str, float], view_w: int, view_h: int, margin: int, vert_exag: float = 1.0) → Callable[[float, float], tuple[float, float]]

  Create a coordinate transformation function for screen projection.

  Returns a function that transforms data coordinates (distance, elevation) to pixel coordinates (x, y) based on the provided view dimensions.

  Parameters:

    - bounds – Dictionary with ‘min_d’, ‘max_d’, ‘min_e’, ‘max_e’.

    - view_w – Screen/view width in pixels.

    - view_h – Screen/view height in pixels.

    - margin – Plot margin in pixels.

    - vert_exag – Vertical exaggeration multiplier (default 1.0).

  Returns:

    A function transform(dist, elev) -> (x, y) converting data to pixels.