@tsparticles/shape-image 3.0.0-beta.3 → 3.0.0-beta.5

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.
@@ -100,8 +100,8 @@ export class ImageDrawer {
100
100
  const ratio = image.ratio, pos = {
101
101
  x: -radius,
102
102
  y: -radius,
103
- };
104
- context.drawImage(element, pos.x, pos.y, radius * 2, (radius * 2) / ratio);
103
+ }, diameter = radius * 2;
104
+ context.drawImage(element, pos.x, pos.y, diameter, diameter / ratio);
105
105
  }
106
106
  context.globalAlpha = 1;
107
107
  }
@@ -124,7 +124,11 @@ export class ImageDrawer {
124
124
  if (!this._engine.images) {
125
125
  this._engine.images = [];
126
126
  }
127
- const imageData = particle.shapeData, image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
127
+ const imageData = particle.shapeData;
128
+ if (!imageData) {
129
+ return;
130
+ }
131
+ const image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
128
132
  if (!image) {
129
133
  this.loadImageShape(imageData).then(() => {
130
134
  this.loadShape(particle);
@@ -138,7 +142,11 @@ export class ImageDrawer {
138
142
  if (!this._engine.images) {
139
143
  this._engine.images = [];
140
144
  }
141
- const images = this._engine.images, imageData = particle.shapeData, color = particle.getFillColor(), image = images.find((t) => t.name === imageData.name || t.source === imageData.src);
145
+ const images = this._engine.images, imageData = particle.shapeData;
146
+ if (!imageData) {
147
+ return;
148
+ }
149
+ const color = particle.getFillColor(), image = images.find((t) => t.name === imageData.name || t.source === imageData.src);
142
150
  if (!image) {
143
151
  return;
144
152
  }
@@ -171,14 +179,14 @@ export class ImageDrawer {
171
179
  if (!imageRes.ratio) {
172
180
  imageRes.ratio = 1;
173
181
  }
174
- const fill = imageData.fill ?? particle.fill, close = imageData.close ?? particle.close, imageShape = {
182
+ const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
175
183
  image: imageRes,
176
184
  fill,
177
185
  close,
178
186
  };
179
187
  particle.image = imageShape.image;
180
- particle.fill = imageShape.fill;
181
- particle.close = imageShape.close;
188
+ particle.shapeFill = imageShape.fill;
189
+ particle.shapeClose = imageShape.close;
182
190
  })();
183
191
  }
184
192
  }
@@ -103,8 +103,8 @@ class ImageDrawer {
103
103
  const ratio = image.ratio, pos = {
104
104
  x: -radius,
105
105
  y: -radius,
106
- };
107
- context.drawImage(element, pos.x, pos.y, radius * 2, (radius * 2) / ratio);
106
+ }, diameter = radius * 2;
107
+ context.drawImage(element, pos.x, pos.y, diameter, diameter / ratio);
108
108
  }
109
109
  context.globalAlpha = 1;
110
110
  }
@@ -127,7 +127,11 @@ class ImageDrawer {
127
127
  if (!this._engine.images) {
128
128
  this._engine.images = [];
129
129
  }
130
- const imageData = particle.shapeData, image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
130
+ const imageData = particle.shapeData;
131
+ if (!imageData) {
132
+ return;
133
+ }
134
+ const image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
131
135
  if (!image) {
132
136
  this.loadImageShape(imageData).then(() => {
133
137
  this.loadShape(particle);
@@ -141,7 +145,11 @@ class ImageDrawer {
141
145
  if (!this._engine.images) {
142
146
  this._engine.images = [];
143
147
  }
144
- const images = this._engine.images, imageData = particle.shapeData, color = particle.getFillColor(), image = images.find((t) => t.name === imageData.name || t.source === imageData.src);
148
+ const images = this._engine.images, imageData = particle.shapeData;
149
+ if (!imageData) {
150
+ return;
151
+ }
152
+ const color = particle.getFillColor(), image = images.find((t) => t.name === imageData.name || t.source === imageData.src);
145
153
  if (!image) {
146
154
  return;
147
155
  }
@@ -174,14 +182,14 @@ class ImageDrawer {
174
182
  if (!imageRes.ratio) {
175
183
  imageRes.ratio = 1;
176
184
  }
177
- const fill = imageData.fill ?? particle.fill, close = imageData.close ?? particle.close, imageShape = {
185
+ const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
178
186
  image: imageRes,
179
187
  fill,
180
188
  close,
181
189
  };
182
190
  particle.image = imageShape.image;
183
- particle.fill = imageShape.fill;
184
- particle.close = imageShape.close;
191
+ particle.shapeFill = imageShape.fill;
192
+ particle.shapeClose = imageShape.close;
185
193
  })();
186
194
  }
187
195
  }
@@ -100,8 +100,8 @@ export class ImageDrawer {
100
100
  const ratio = image.ratio, pos = {
101
101
  x: -radius,
102
102
  y: -radius,
103
- };
104
- context.drawImage(element, pos.x, pos.y, radius * 2, (radius * 2) / ratio);
103
+ }, diameter = radius * 2;
104
+ context.drawImage(element, pos.x, pos.y, diameter, diameter / ratio);
105
105
  }
106
106
  context.globalAlpha = 1;
107
107
  }
@@ -124,7 +124,11 @@ export class ImageDrawer {
124
124
  if (!this._engine.images) {
125
125
  this._engine.images = [];
126
126
  }
127
- const imageData = particle.shapeData, image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
127
+ const imageData = particle.shapeData;
128
+ if (!imageData) {
129
+ return;
130
+ }
131
+ const image = this._engine.images.find((t) => t.name === imageData.name || t.source === imageData.src);
128
132
  if (!image) {
129
133
  this.loadImageShape(imageData).then(() => {
130
134
  this.loadShape(particle);
@@ -138,7 +142,11 @@ export class ImageDrawer {
138
142
  if (!this._engine.images) {
139
143
  this._engine.images = [];
140
144
  }
141
- const images = this._engine.images, imageData = particle.shapeData, color = particle.getFillColor(), image = images.find((t) => t.name === imageData.name || t.source === imageData.src);
145
+ const images = this._engine.images, imageData = particle.shapeData;
146
+ if (!imageData) {
147
+ return;
148
+ }
149
+ const color = particle.getFillColor(), image = images.find((t) => t.name === imageData.name || t.source === imageData.src);
142
150
  if (!image) {
143
151
  return;
144
152
  }
@@ -171,14 +179,14 @@ export class ImageDrawer {
171
179
  if (!imageRes.ratio) {
172
180
  imageRes.ratio = 1;
173
181
  }
174
- const fill = imageData.fill ?? particle.fill, close = imageData.close ?? particle.close, imageShape = {
182
+ const fill = imageData.fill ?? particle.shapeFill, close = imageData.close ?? particle.shapeClose, imageShape = {
175
183
  image: imageRes,
176
184
  fill,
177
185
  close,
178
186
  };
179
187
  particle.image = imageShape.image;
180
- particle.fill = imageShape.fill;
181
- particle.close = imageShape.close;
188
+ particle.shapeFill = imageShape.fill;
189
+ particle.shapeClose = imageShape.close;
182
190
  })();
183
191
  }
184
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/shape-image",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "tsParticles image shape",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "css3",
34
34
  "animated",
35
35
  "background",
36
- "@tsparticles/shape"
36
+ "tsparticles-shape"
37
37
  ],
38
38
  "author": "Matteo Bruni <matteo.bruni@me.com>",
39
39
  "license": "MIT",
@@ -59,7 +59,7 @@
59
59
  "./package.json": "./package.json"
60
60
  },
61
61
  "dependencies": {
62
- "@tsparticles/engine": "^3.0.0-beta.3"
62
+ "@tsparticles/engine": "^3.0.0-beta.5"
63
63
  },
64
64
  "publishConfig": {
65
65
  "access": "public"