@antha/graphics-2d 0.1.0 → 0.1.2
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.
- package/README.md +38 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,11 +1,46 @@
|
|
|
1
1
|
# @antha/graphics-2d
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Demo: https://electrovir.github.io/antha/demo/graphics-2d
|
|
3
|
+
This package provides a pre-built [Antha game engine](https://www.npmjs.com/package/@antha/engine) mod that creates and manages a PixiJS application and its canvas.
|
|
6
4
|
|
|
7
5
|
## Install
|
|
8
6
|
|
|
9
7
|
```sh
|
|
10
8
|
npm i @antha/graphics-2d
|
|
11
9
|
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
<!-- example-link: src/readme-examples/drawing-graphics.example.ts -->
|
|
14
|
+
|
|
15
|
+
```TypeScript
|
|
16
|
+
import {AnthaEngine, defineAnthaMod} from '@antha/engine';
|
|
17
|
+
import {type AnthaGraphics2dModState, createAnthaGraphics2dMod, Graphics} from '@antha/graphics-2d';
|
|
18
|
+
|
|
19
|
+
type GameState = AnthaGraphics2dModState & {
|
|
20
|
+
hasAddedCircle: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const engine = new AnthaEngine<GameState>({
|
|
24
|
+
initState: {
|
|
25
|
+
hasAddedCircle: false,
|
|
26
|
+
},
|
|
27
|
+
mods: [
|
|
28
|
+
createAnthaGraphics2dMod(),
|
|
29
|
+
defineAnthaMod<GameState>({
|
|
30
|
+
modName: 'game-logic',
|
|
31
|
+
execute({state}) {
|
|
32
|
+
if (!state.pixi?.pixiApplication || state.hasAddedCircle) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
state.hasAddedCircle = true;
|
|
37
|
+
state.pixi.pixiApplication.stage.addChild(
|
|
38
|
+
new Graphics().circle(0, 0, 20).fill('white'),
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
engine.startLoop();
|
|
46
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/graphics-2d",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "An Antha mod for rendering 2D graphics to a canvas.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@augment-vir/common": "^32.2.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@antha/engine": "^0.1.
|
|
44
|
-
"@antha/web-test-runner-plugin-pixi": "^0.1.
|
|
43
|
+
"@antha/engine": "^0.1.2",
|
|
44
|
+
"@antha/web-test-runner-plugin-pixi": "^0.1.2",
|
|
45
45
|
"@augment-vir/test": "^32.2.2",
|
|
46
46
|
"@electrovir/color": "^1.7.11",
|
|
47
47
|
"@web/dev-server-esbuild": "^2.0.0",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"@web/test-runner-playwright": "^1.0.0",
|
|
50
50
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
51
51
|
"pixi.js": "^8.19.0",
|
|
52
|
-
"vira": "31.
|
|
52
|
+
"vira": "31.31.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@antha/engine": "
|
|
55
|
+
"@antha/engine": "^0.1.2",
|
|
56
56
|
"@electrovir/color": ">=1",
|
|
57
57
|
"element-vir": ">=26",
|
|
58
58
|
"pixi.js": ">=8",
|