1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Miscellaneous position utilities for rendering pipelines.
//!
//! This module provides utility functions for coordinate conversion and
//! position calculations, primarily focused on converting pixel-based UI
//! positions to normalized device coordinates (NDC). It is intended for use in
//! shape, text, and effect pipelines where consistent coordinate normalization
//! is required for rendering. The conversion assumes a top-left origin,
//! matching typical UI conventions, and ensures compatibility with graphics
//! APIs that expect NDC input.
//!
//! Typical scenarios include transforming UI element positions for GPU-based
//! rendering, shader pipelines, and any context where pixel-to-NDC mapping is
//! necessary for visual correctness.
use PxPosition;
/// Converts a pixel position to normalized device coordinates (NDC).
///
/// The origin is at the top-left corner, matching UI coordinate conventions.
///
/// # Parameters
/// - `pos`: The pixel position to convert.
/// - `screen_size`: The size of the screen as [width, height].
///
/// # Returns
/// An array `[x, y]` representing the NDC coordinates.