All files / core/src/types displayArea.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                     
import type InterpolationType from '../enums/InterpolationType';
 
/**
 * The display area type allows specifying or updating the image position and
 * size based on the display area that it is shown in and based on the image
 * size.
 *
 * Two types are currently defined, the default 'FIT', specifies scaling
 * to fit the given image area.  For this type, the area  that is scaled to
 * fit is the imageArea times the image size.  For example, an imageArea of
 * `[0.5,2]` with a 512 square image will try to fit 0.5*512 = 256 pixels width wise,
 * and 2*512 = 1024 height wise.
 *
 * The type 'SCALE' means to use a scale factor, such as 1.0, which means to make
 * every image pixel fit one physical display pixel.
 *
 * Then, the image is positioned such that the image fractional position imagePoint
 * is located at the canvas fractional point canvasPoint.  Using fractional
 * points allows being independent of image size.
 *
 * Finally, the store as initial camera allows the zoom and pan values to be
 * set to 1 and [0,0] respectively for the initially displayed position, as well
 * as having the reset camera reset to the specified display area.
 */
interface DisplayArea {
  type?: 'SCALE' | 'FIT';
  scale?: number;
  interpolationType?: InterpolationType;
  imageArea?: [number, number]; // areaX, areaY
  imageCanvasPoint?: {
    /** Use the fractional imagePoint as the target image point to position */
    imagePoint: [number, number]; // imageX, imageY
    /** Pan the image such that the target imagePoint is located at the
     * canvas point fraction of the canvas.
     */
    canvasPoint?: [number, number]; // canvasX, canvasY
  };
  /** Make this display area the default and reset/navigate will reapply this */
  storeAsInitialCamera?: boolean;
}
 
export type { DisplayArea as default };