/// Converts an input event touch to a display coordinate, which is the coordinate space in
/// which Scenic handles events.
///
/// The display coordinate is calculated by normalizing the contact position to the display
/// size. It does not account for the viewport position, which Scenic handles directly.
///
/// # Parameters
/// - `contact`: The contact to get the display coordinate from.
/// - `touch_descriptor`: The device descriptor for the device that generated the event.
///                       This is used to compute the device coordinate.
///
/// # Returns
/// (x, y) coordinates.
Converts an input event touch to a display coordinate, which is the coordinate space in
which Scenic handles events.

The display coordinate is calculated by normalizing the contact position to the display
size. It does not account for the viewport position, which Scenic handles directly.
Converts an input event touch to a display coordinate which is the coordinate space in which Scenic handles events . The display coordinate is calculated by normalizing the contact position to the display size . It does not account for the viewport position which Scenic handles directly .
fn display_coordinate_from_contact(
        contact: &touch_binding::TouchContact,
        touch_descriptor: &touch_binding::TouchDeviceDescriptor,
        display_size: &Size,
    ) -> Position {
        if let Some(contact_descriptor) = touch_descriptor.contacts.first() {
            // Scale the x position.
            let x_range: f32 =
                contact_descriptor.x_range.max as f32 - contact_descriptor.x_range.min as f32;
            let x_wrt_range: f32 = contact.position.x - contact_descriptor.x_range.min as f32;
            let x: f32 = (display_size.width * x_wrt_range) / x_range;
            // Scale the y position.
            let y_range: f32 =
                contact_descriptor.y_range.max as f32 - contact_descriptor.y_range.min as f32;
            let y_wrt_range: f32 = contact.position.y - contact_descriptor.y_range.min as f32;
            let y: f32 = (display_size.height * y_wrt_range) / y_range;
            Position { x, y }
        } else {
            return contact.position;
        }
    }
fn display_coordinate_from_contact ( contact : & touch_binding :: TouchContact , touch_descriptor : & touch_binding :: TouchDeviceDescriptor , display_size : & Size , ) -> Position { if let Some ( contact_descriptor ) = touch_descriptor . contacts . first ( ) { // Scale the x position. let x_range : f32 = contact_descriptor . x_range . max as f32 - contact_descriptor . x_range . min as f32 ; let x_wrt_range : f32 = contact . position . x - contact_descriptor . x_range . min as f32 ; let x : f32 = ( display_size . width * x_wrt_range ) / x_range ; // Scale the y position. let y_range : f32 = contact_descriptor . y_range . max as f32 - contact_descriptor . y_range . min as f32 ; let y_wrt_range : f32 = contact . position . y - contact_descriptor . y_range . min as f32 ; let y : f32 = ( display_size . height * y_wrt_range ) / y_range ; Position { x , y } } else { return contact . position ; } }
Converts an input event touch to a display coordinate, which is the coordinate space in
which Scenic handles events.
Converts an input event touch to a display coordinate which is the coordinate space in which Scenic handles events .
(x, y) coordinates.
( x y ) coordinates .
contact
&touch_binding::TouchContact
The contact to get the display coordinate from.
The contact to get the display coordinate from .
touch_descriptor
&touch_binding::TouchDeviceDescriptor
The device descriptor for the device that generated the event.
This is used to compute the device coordinate.
The device descriptor for the device that generated the event . This is used to compute the device coordinate .
display_size
&Size