|
@@ -1,8 +1,28 @@
|
1
|
1
|
import * as PIXI from 'pixi.js';
|
|
2
|
+import { randomInt } from './utils';
|
2
|
3
|
import './style.css';
|
3
|
4
|
|
4
|
5
|
const app = new PIXI.Application(window.innerWidth, window.innerHeight);
|
|
6
|
+const ticker = new PIXI.ticker.Ticker();
|
|
7
|
+const graphics = new PIXI.Graphics();
|
|
8
|
+const fpsText = new PIXI.Text('', { fontSize: '25px', fontFamily: 'monospace', fill: 'yellow' });
|
5
|
9
|
|
|
10
|
+fpsText.anchor = new PIXI.Point(1, 0);
|
|
11
|
+fpsText.x = window.innerWidth - 1;
|
|
12
|
+fpsText.y = 0;
|
|
13
|
+
|
|
14
|
+ticker.stop();
|
|
15
|
+ticker.add((deltaTime) => {
|
|
16
|
+ fpsText.setText(Math.round(ticker.FPS));
|
|
17
|
+ graphics.lineStyle(1, 0xaeaeae, 1);
|
|
18
|
+
|
|
19
|
+ graphics.moveTo(randomInt(9, window.innerWidth), randomInt(0, window.innerHeight));
|
|
20
|
+ graphics.lineTo(randomInt(9, window.innerWidth), randomInt(0, window.innerHeight));
|
|
21
|
+});
|
|
22
|
+ticker.start();
|
|
23
|
+
|
|
24
|
+app.stage.addChild(graphics);
|
|
25
|
+app.stage.addChild(fpsText);
|
6
|
26
|
document.body.appendChild(app.view);
|
7
|
27
|
|
8
|
28
|
window.addEventListener('resize', () => {
|