@painekillers/tree-builder-core 1.1.1 → 1.2.1

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": "@painekillers/tree-builder-core",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
package/themes/dark.js CHANGED
@@ -58,6 +58,7 @@ export default {
58
58
 
59
59
  node(ctx, object) {
60
60
  const pos = object.pos
61
+ const tile = object.tile
61
62
  const size = object.size
62
63
 
63
64
  const width = size.width * object.scale
@@ -104,13 +105,26 @@ export default {
104
105
 
105
106
  ctx.globalAlpha = object.hovered ? 1 : 0.92
106
107
 
107
- ctx.drawImage(
108
- object.image,
109
- x,
110
- y,
111
- width,
112
- height
113
- )
108
+ ctx.imageSmoothingEnabled = false;
109
+
110
+ if (tile) {
111
+ ctx.drawImage(
112
+ object.image,
113
+ tile.x, tile.y, tile.width, tile.height,
114
+ x,
115
+ y,
116
+ width,
117
+ height,
118
+ )
119
+ } else {
120
+ ctx.drawImage(
121
+ object.image,
122
+ x,
123
+ y,
124
+ width,
125
+ height,
126
+ )
127
+ }
114
128
 
115
129
  ctx.restore()
116
130
 
package/themes/default.js CHANGED
@@ -140,6 +140,7 @@ export default {
140
140
  node(ctx, object) {
141
141
  const pos = object.pos
142
142
  const size = object.size
143
+ const tile = object.tile
143
144
 
144
145
  const width = size.width * object.scale
145
146
  const height = size.height * object.scale
@@ -173,13 +174,26 @@ export default {
173
174
 
174
175
  ctx.globalAlpha = object.hovered ? 1 : 0.92
175
176
 
176
- ctx.drawImage(
177
- object.image,
178
- x,
179
- y,
180
- width,
181
- height
182
- )
177
+ ctx.imageSmoothingEnabled = false;
178
+
179
+ if (tile) {
180
+ ctx.drawImage(
181
+ object.image,
182
+ tile.x, tile.y, tile.width, tile.height,
183
+ x,
184
+ y,
185
+ width,
186
+ height,
187
+ )
188
+ } else {
189
+ ctx.drawImage(
190
+ object.image,
191
+ x,
192
+ y,
193
+ width,
194
+ height,
195
+ )
196
+ }
183
197
 
184
198
  ctx.restore()
185
199
 
package/world/bridge.js CHANGED
@@ -97,7 +97,8 @@ export default class Bridge {
97
97
  drawNode.height,
98
98
  drawNode.layoutNode.node,
99
99
  drawNode.layoutNode.node.val?.icon,
100
- drawNode
100
+ drawNode,
101
+ drawNode.layoutNode.node.val?.iconTile
101
102
  )
102
103
 
103
104
  obj.root =
package/world/objects.js CHANGED
@@ -100,11 +100,13 @@ placeholder.src = "data:image/svg+xml," + encodeURIComponent(`
100
100
 
101
101
  export class ImageInstance extends PSInstance {
102
102
  #image
103
+ #tile
103
104
 
104
- constructor(world, x, y, width, height, image) {
105
+ constructor(world, x, y, width, height, image, tile) {
105
106
  super(world, x, y, width, height)
106
107
 
107
108
  this.image = image
109
+ this.#tile = tile ?? null
108
110
  }
109
111
 
110
112
  set image(img) {
@@ -116,17 +118,37 @@ export class ImageInstance extends PSInstance {
116
118
  return this.#image ?? placeholder
117
119
  }
118
120
 
121
+ set tile(t) {
122
+ this.#tile = t
123
+ this.world.update()
124
+ }
125
+
126
+ get tile() {
127
+ return this.#tile
128
+ }
129
+
119
130
  draw(ctx, p, s) {
120
131
  let pos = p || this.pos
121
132
  let size = s || this.size
122
133
 
123
- ctx.drawImage(
124
- this.image,
125
- pos.x - size.width / 2,
126
- pos.y - size.height / 2,
127
- size.width,
128
- size.height
129
- )
134
+ if (this.#tile) {
135
+ ctx.drawImage(
136
+ this.image,
137
+ this.#tile.x, this.#tile.y, this.#tile.width, this.#tile.height,
138
+ pos.x - size.width / 2,
139
+ pos.y - size.height / 2,
140
+ size.width,
141
+ size.height,
142
+ )
143
+ } else {
144
+ ctx.drawImage(
145
+ this.image,
146
+ pos.x - size.width / 2,
147
+ pos.y - size.height / 2,
148
+ size.width,
149
+ size.height,
150
+ )
151
+ }
130
152
  }
131
153
  }
132
154
 
@@ -144,6 +166,7 @@ export class Line extends Object {
144
166
  }
145
167
  }
146
168
 
169
+ // Probably wanna change how this works too !!!!!!!!!!!
147
170
  export class NodeInstance extends ImageInstance {
148
171
  constructor(world, x, y, width, height, node, image, drawNode) {
149
172
  super(world, x, y, width, height, image)