@inglorious/renderer-2d 0.5.0 → 0.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/renderer-2d",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "A renderer for the Inglorious Engine, using the Context2D of the Canvas API.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -24,13 +24,18 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@inglorious/engine": "0.10.0",
28
- "@inglorious/utils": "2.2.0"
27
+ "@inglorious/utils": "3.4.0",
28
+ "@inglorious/engine": "1.1.0"
29
+ },
30
+ "peerDependencies": {
31
+ "@inglorious/utils": "3.4.0",
32
+ "@inglorious/engine": "1.1.0"
29
33
  },
30
34
  "devDependencies": {
31
35
  "eslint": "^9.34.0",
32
36
  "prettier": "^3.6.2",
33
- "vitest": "^1.6.0"
37
+ "vitest": "^1.6.0",
38
+ "@inglorious/eslint-config": "1.0.0"
34
39
  },
35
40
  "scripts": {
36
41
  "format": "prettier --write '**/*.{js,jsx}'",
@@ -1,4 +1,4 @@
1
- import { snap, zero } from "@inglorious/utils/math/linear-algebra/vector.js"
1
+ import { snap, zero } from "@inglorious/utils/math/vector.js"
2
2
 
3
3
  export function absolutePosition(render) {
4
4
  return (entity, ctx, { api }) => {
package/src/fps.js CHANGED
@@ -7,7 +7,7 @@ export function renderFps(entity, ctx) {
7
7
 
8
8
  renderText(
9
9
  {
10
- ...entity.dt,
10
+ ...entity,
11
11
  value: `FPS: ${(ONE_SECOND / value).toFixed(accuracy)}`,
12
12
  },
13
13
  ctx,
@@ -1,4 +1,4 @@
1
- import { to2D } from "@inglorious/utils/math/linear-algebra/2d.js"
1
+ import { to2D } from "@inglorious/utils/math/vector.js"
2
2
 
3
3
  import { absolutePosition } from "./absolute-position.js"
4
4
 
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-magic-numbers */
2
2
 
3
- import { zero } from "@inglorious/utils/math/linear-algebra/vector.js"
4
3
  import { pi } from "@inglorious/utils/math/trigonometry.js"
4
+ import { zero } from "@inglorious/utils/math/vector.js"
5
5
 
6
6
  export function renderCircle(entity, ctx) {
7
7
  const {
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-magic-numbers */
2
2
 
3
- import { zero } from "@inglorious/utils/math/linear-algebra/vector.js"
3
+ import { zero } from "@inglorious/utils/math/vector.js"
4
4
 
5
5
  export function renderRectangle(entity, ctx) {
6
6
  const {
package/src/text.js CHANGED
@@ -2,13 +2,21 @@ const DEFAULT_SIZE = 16
2
2
  const DEFAULT_PADDING = 10
3
3
 
4
4
  export function renderText(entity, ctx) {
5
- const { size = DEFAULT_SIZE, value = "" } = entity
5
+ const {
6
+ size = DEFAULT_SIZE,
7
+ padding = DEFAULT_PADDING,
8
+ color = "black",
9
+ font = "sans-serif",
10
+ textAlign = "left",
11
+ value = "",
12
+ } = entity
6
13
 
7
14
  ctx.save()
8
15
 
9
- ctx.font = `${size}px sans serif`
10
- ctx.fillStyle = "black"
11
- ctx.fillText(value, DEFAULT_PADDING, DEFAULT_PADDING + size)
16
+ ctx.font = `${size}px ${font}`
17
+ ctx.fillStyle = color
18
+ ctx.textAlign = textAlign
19
+ ctx.fillText(value, padding, padding + size)
12
20
 
13
21
  ctx.restore()
14
22
  }