@antha/graphics-2d 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +1,17 @@
1
- import { type PartialWithUndefined, type RequireAtLeastOne } from '@augment-vir/common';
1
+ import { type AnthaVirtualViewportOptions, type AnthaVirtualViewportState, type VirtualViewportSize } from '@antha/asset';
2
2
  import { type AnthaGraphics2dModState } from './antha-graphics-2d.mod.js';
3
3
  /**
4
- * The logical dimensions and scale of a virtual viewport.
4
+ * Re-exported from {@link @antha/asset!VirtualViewport}.
5
5
  *
6
6
  * @category Internal
7
7
  */
8
- export type VirtualViewport = {
9
- height: number;
10
- scale: number;
11
- width: number;
12
- };
13
- /**
14
- * The dimensions of a virtual viewport without its scale.
15
- *
16
- * @category Internal
17
- */
18
- export type VirtualViewportSize = Pick<VirtualViewport, 'height' | 'width'>;
19
- /**
20
- * Options for {@link createAnthaVirtualViewportMod}.
21
- *
22
- * @category Pre-Built Mods
23
- */
24
- export type AnthaVirtualViewportOptions = RequireAtLeastOne<{
25
- virtualHeight: number;
26
- virtualWidth: number;
27
- }>;
8
+ export type { AnthaVirtualViewportOptions, AnthaVirtualViewportState, VirtualViewport, VirtualViewportSize, } from '@antha/asset';
28
9
  /**
29
10
  * State added by {@link createAnthaVirtualViewportMod}.
30
11
  *
31
12
  * @category Internal
32
13
  */
33
- export type AnthaVirtualViewportModState = AnthaGraphics2dModState & {
34
- virtualViewport: VirtualViewport | undefined;
35
- };
36
- /**
37
- * Calculates the logical viewport for a physical screen size.
38
- *
39
- * @category Util
40
- */
41
- export declare function calculateVirtualViewport({ screenSize, virtualHeight, virtualWidth, }: Readonly<PartialWithUndefined<AnthaVirtualViewportOptions> & {
42
- screenSize: Readonly<VirtualViewportSize>;
43
- }>): {
44
- height: number;
45
- scale: number;
46
- width: number;
47
- } | undefined;
14
+ export type AnthaVirtualViewportModState = AnthaGraphics2dModState & AnthaVirtualViewportState;
48
15
  /**
49
16
  * Maps a pointer position from canvas coordinates into a virtual viewport.
50
17
  *
@@ -1,44 +1,5 @@
1
+ import { calculateVirtualViewport, } from '@antha/asset';
1
2
  import { defineAnthaMod } from '@antha/engine';
2
- import { assertWrap } from '@augment-vir/assert';
3
- /**
4
- * Calculates the logical viewport for a physical screen size.
5
- *
6
- * @category Util
7
- */
8
- export function calculateVirtualViewport({ screenSize, virtualHeight, virtualWidth, }) {
9
- if (!screenSize.height ||
10
- !screenSize.width ||
11
- virtualHeight === 0 ||
12
- virtualWidth === 0 ||
13
- (virtualHeight == undefined && virtualWidth == undefined)) {
14
- return undefined;
15
- }
16
- else if (virtualHeight == undefined) {
17
- const definedVirtualWidth = assertWrap.isDefined(virtualWidth);
18
- const scale = screenSize.width / definedVirtualWidth;
19
- return {
20
- height: screenSize.height / scale,
21
- scale,
22
- width: definedVirtualWidth,
23
- };
24
- }
25
- else if (virtualWidth == undefined) {
26
- const scale = screenSize.height / virtualHeight;
27
- return {
28
- height: virtualHeight,
29
- scale,
30
- width: screenSize.width / scale,
31
- };
32
- }
33
- else {
34
- const scale = Math.min(screenSize.height / virtualHeight, screenSize.width / virtualWidth);
35
- return {
36
- height: virtualHeight,
37
- scale,
38
- width: virtualWidth,
39
- };
40
- }
41
- }
42
3
  /**
43
4
  * Maps a pointer position from canvas coordinates into a virtual viewport.
44
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/graphics-2d",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "An Antha mod for rendering 2D graphics to a canvas.",
5
5
  "keywords": [
6
6
  "vir",
@@ -40,8 +40,9 @@
40
40
  "@augment-vir/common": "^32.3.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@antha/engine": "^0.16.0",
44
- "@antha/web-test-runner-plugin-pixi": "^0.16.0",
43
+ "@antha/asset": "^0.18.0",
44
+ "@antha/engine": "^0.18.0",
45
+ "@antha/web-test-runner-plugin-pixi": "^0.18.0",
45
46
  "@augment-vir/test": "^32.3.0",
46
47
  "@electrovir/color": "^2.0.0",
47
48
  "@web/dev-server-esbuild": "^2.0.0",
@@ -52,7 +53,8 @@
52
53
  "vira": "32.0.0"
53
54
  },
54
55
  "peerDependencies": {
55
- "@antha/engine": "^0.16.0",
56
+ "@antha/asset": "^0.18.0",
57
+ "@antha/engine": "^0.18.0",
56
58
  "@electrovir/color": "^2",
57
59
  "element-vir": "^27",
58
60
  "pixi.js": "^8",