minecraft-inventory 0.1.10 → 0.1.11

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": "minecraft-inventory",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "release": {
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  const POOL_SIZE = 8
7
- const OUTPUT_SIZE = 32
7
+ const OUTPUT_SIZE = 64
8
8
 
9
9
  const pool: HTMLCanvasElement[] = []
10
10
  const inUse = new Set<HTMLCanvasElement>()
@@ -59,42 +59,43 @@ export function renderBlockIcon(
59
59
  ctx.imageSmoothingEnabled = false
60
60
  ctx.clearRect(0, 0, OUTPUT_SIZE, OUTPUT_SIZE)
61
61
 
62
- const s = OUTPUT_SIZE / 2 - 2 // face size with padding (14px at 32px canvas)
63
- const ox = (OUTPUT_SIZE - 2 * s) / 2 // horizontal offset to center
64
- const oy = (OUTPUT_SIZE - 2 * s) / 2 // vertical offset to center
62
+ // Parameters from the original minecraft-inventory-gui renderer
63
+ const A = 0.9 // horizontal compression (makes blocks narrower/taller)
64
+ const K = 0.5 // skew factor
65
+ const s = OUTPUT_SIZE / 2 - 2
66
+ const cubeWidth = 2 * A * s
67
+ const cubeHeight = 2 * K * s + s
68
+ const ox = Math.round((OUTPUT_SIZE - cubeWidth) / 2)
69
+ const topY = Math.round((OUTPUT_SIZE - cubeHeight) / 2)
70
+ const ex = ox
71
+ const ey = topY + K * s
72
+
65
73
  const [tx, ty, tw, th] = top
66
74
  const [lx, ly, lw, lh] = left
67
75
  const [rx, ry, rw, rh] = right
68
76
 
69
- // Enable smoothing for isometric transforms (better diagonal edges)
70
77
  ctx.imageSmoothingEnabled = true
71
78
  ctx.imageSmoothingQuality = 'high'
72
79
 
73
- // Isometric cube using affine transforms.
74
- // Face vertices for a cube centered in OUTPUT_SIZE × OUTPUT_SIZE:
75
- // Top: (s+ox, oy) → (2s+ox, s/2+oy) → (s+ox, s+oy) → (ox, s/2+oy)
76
- // Left: (ox, s/2+oy) → (s+ox, s+oy) → (s+ox, 2s+oy) → (ox, 3s/2+oy)
77
- // Right: (s+ox, s+oy) → (2s+ox, s/2+oy) → (2s+ox, 3s/2+oy) → (s+ox, 2s+oy)
78
-
79
80
  // Top face
80
81
  ctx.save()
81
- ctx.setTransform(1, 0.5, -1, 0.5, s + ox, oy)
82
+ ctx.setTransform(A, -K, A, K, ex, ey)
82
83
  ctx.drawImage(image, tx, ty, tw, th, 0, 0, s, s)
83
84
  ctx.restore()
84
85
 
85
- // Left face (darkened)
86
+ // Left face (lightly darkened)
86
87
  ctx.save()
87
- ctx.setTransform(1, 0.5, 0, 1, ox, s / 2 + oy)
88
+ ctx.setTransform(A, K, 0, 1, ex, ey)
88
89
  ctx.drawImage(image, lx, ly, lw, lh, 0, 0, s, s)
89
- ctx.fillStyle = 'rgba(0, 0, 0, 0.4)'
90
+ ctx.fillStyle = 'rgba(0, 0, 0, 0.35)'
90
91
  ctx.fillRect(0, 0, s, s)
91
92
  ctx.restore()
92
93
 
93
- // Right face (slightly darkened)
94
+ // Right face (darkened — light comes from upper-left)
94
95
  ctx.save()
95
- ctx.setTransform(1, -0.5, 0, 1, s + ox, s + oy)
96
+ ctx.setTransform(A, -K, 0, 1, A * s + ex, K * s + ey)
96
97
  ctx.drawImage(image, rx, ry, rw, rh, 0, 0, s, s)
97
- ctx.fillStyle = 'rgba(0, 0, 0, 0.2)'
98
+ ctx.fillStyle = 'rgba(0, 0, 0, 0.5)'
98
99
  ctx.fillRect(0, 0, s, s)
99
100
  ctx.restore()
100
101
 
@@ -298,7 +298,7 @@ export function InventoryOverlay({
298
298
  lineHeight: 1,
299
299
  }}
300
300
  >
301
- INV 0.1.10
301
+ INV 0.1.11
302
302
  </a>
303
303
  )}
304
304