index.d.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import type { ENV } from '@pixi/constants';
  2. import { GC_MODES } from '@pixi/constants';
  3. import { MIPMAP_MODES } from '@pixi/constants';
  4. import { MSAA_QUALITY } from '@pixi/constants';
  5. import { PRECISION } from '@pixi/constants';
  6. import { SCALE_MODES } from '@pixi/constants';
  7. import { WRAP_MODES } from '@pixi/constants';
  8. export declare const BrowserAdapter: IAdapter;
  9. export declare type ContextIds = '2d' | 'webgl' | 'experimental-webgl' | 'webgl2';
  10. /**
  11. * This interface describes all the DOM dependent calls that Pixi makes throughout its codebase
  12. * Implementations of this interface can be used to make sure Pixi will work in any environment
  13. * such as browser, web workers, and node
  14. */
  15. export declare interface IAdapter {
  16. /** Returns a canvas object that can be used to create a webgl context. */
  17. createCanvas: (width?: number, height?: number) => HTMLCanvasElement;
  18. /** Returns a webgl rendering context. */
  19. getWebGLRenderingContext: () => typeof WebGLRenderingContext;
  20. /** Returns a partial implementation of the browsers window.navigator */
  21. getNavigator: () => {
  22. userAgent: string;
  23. };
  24. /** Returns the current base URL For browser environments this is either the document.baseURI or window.location.href */
  25. getBaseUrl: () => string;
  26. fetch: (url: RequestInfo, options?: RequestInit) => Promise<Response>;
  27. }
  28. export declare interface IRenderOptions {
  29. view: HTMLCanvasElement;
  30. width: number;
  31. height: number;
  32. autoDensity: boolean;
  33. backgroundColor: number;
  34. backgroundAlpha: number;
  35. useContextAlpha: boolean | 'notMultiplied';
  36. clearBeforeRender: boolean;
  37. antialias: boolean;
  38. preserveDrawingBuffer: boolean;
  39. }
  40. export declare interface ISettings {
  41. ADAPTER: IAdapter;
  42. MIPMAP_TEXTURES: MIPMAP_MODES;
  43. ANISOTROPIC_LEVEL: number;
  44. RESOLUTION: number;
  45. FILTER_RESOLUTION: number;
  46. FILTER_MULTISAMPLE: MSAA_QUALITY;
  47. SPRITE_MAX_TEXTURES: number;
  48. SPRITE_BATCH_SIZE: number;
  49. RENDER_OPTIONS: IRenderOptions;
  50. GC_MODE: GC_MODES;
  51. GC_MAX_IDLE: number;
  52. GC_MAX_CHECK_COUNT: number;
  53. WRAP_MODE: WRAP_MODES;
  54. SCALE_MODE: SCALE_MODES;
  55. PRECISION_VERTEX: PRECISION;
  56. PRECISION_FRAGMENT: PRECISION;
  57. CAN_UPLOAD_SAME_BUFFER: boolean;
  58. CREATE_IMAGE_BITMAP: boolean;
  59. ROUND_PIXELS: boolean;
  60. RETINA_PREFIX?: RegExp;
  61. FAIL_IF_MAJOR_PERFORMANCE_CAVEAT?: boolean;
  62. UPLOADS_PER_FRAME?: number;
  63. SORTABLE_CHILDREN?: boolean;
  64. PREFER_ENV?: ENV;
  65. STRICT_TEXTURE_CACHE?: boolean;
  66. MESH_CANVAS_PADDING?: number;
  67. TARGET_FPMS?: number;
  68. }
  69. export declare const isMobile: isMobileResult;
  70. declare type isMobileResult = {
  71. apple: {
  72. phone: boolean;
  73. ipod: boolean;
  74. tablet: boolean;
  75. universal: boolean;
  76. device: boolean;
  77. };
  78. amazon: {
  79. phone: boolean;
  80. tablet: boolean;
  81. device: boolean;
  82. };
  83. android: {
  84. phone: boolean;
  85. tablet: boolean;
  86. device: boolean;
  87. };
  88. windows: {
  89. phone: boolean;
  90. tablet: boolean;
  91. device: boolean;
  92. };
  93. other: {
  94. blackberry: boolean;
  95. blackberry10: boolean;
  96. opera: boolean;
  97. firefox: boolean;
  98. chrome: boolean;
  99. device: boolean;
  100. };
  101. phone: boolean;
  102. tablet: boolean;
  103. any: boolean;
  104. };
  105. /**
  106. * User's customizable globals for overriding the default PIXI settings, such
  107. * as a renderer's default resolution, framerate, float precision, etc.
  108. * @example
  109. * // Use the native window resolution as the default resolution
  110. * // will support high-density displays when rendering
  111. * PIXI.settings.RESOLUTION = window.devicePixelRatio;
  112. *
  113. * // Disable interpolation when scaling, will make texture be pixelated
  114. * PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
  115. * @namespace PIXI.settings
  116. */
  117. export declare const settings: ISettings;
  118. export { }