1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @flow
    
  8.  */
    
  9. 
    
  10. import type {Rect} from '../../view-base';
    
  11. 
    
  12. export function positioningScaleFactor(
    
  13.   intrinsicWidth: number,
    
  14.   frame: Rect,
    
  15. ): number {
    
  16.   return frame.size.width / intrinsicWidth;
    
  17. }
    
  18. 
    
  19. export function timestampToPosition(
    
  20.   timestamp: number,
    
  21.   scaleFactor: number,
    
  22.   frame: Rect,
    
  23. ): number {
    
  24.   return frame.origin.x + timestamp * scaleFactor;
    
  25. }
    
  26. 
    
  27. export function positionToTimestamp(
    
  28.   position: number,
    
  29.   scaleFactor: number,
    
  30.   frame: Rect,
    
  31. ): number {
    
  32.   return (position - frame.origin.x) / scaleFactor;
    
  33. }
    
  34. 
    
  35. export function durationToWidth(duration: number, scaleFactor: number): number {
    
  36.   return duration * scaleFactor;
    
  37. }
    
  38. 
    
  39. export function widthToDuration(width: number, scaleFactor: number): number {
    
  40.   return width / scaleFactor;
    
  41. }