Skip to content

Commit a616959

Browse files
committed
fix: checking that engine images exists, if not it will be initialized
1 parent 40c0f1e commit a616959

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

shapes/image/src/GifUtils/Utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function parseExtensionBlock(
154154

155155
/**
156156
* __read `len` bits from `imageData` at `pos`__
157-
* @param imageData - `Uint8ClampedArray` to read from
157+
* @param imageData - `Uint8Array` to read from
158158
* @param pos - bit position in `imageData`
159159
* @param len - bit length to read [1-12 bits]
160160
* @returns `len` bits at `pos`

shapes/image/src/ImageDrawer.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export class ImageDrawer implements IShapeDrawer<ImageParticle> {
3232
* @param image - the image to add to the container collection
3333
*/
3434
addImage(image: IImage): void {
35-
this._engine.images?.push(image);
35+
this._engine.images ??= [];
36+
37+
this._engine.images.push(image);
3638
}
3739

3840
/**
@@ -98,7 +100,9 @@ export class ImageDrawer implements IShapeDrawer<ImageParticle> {
98100
return;
99101
}
100102

101-
const image = this._engine.images?.find((t: IImage) => t.name === imageData.name || t.source === imageData.src);
103+
this._engine.images ??= [];
104+
105+
const image = this._engine.images.find((t: IImage) => t.name === imageData.name || t.source === imageData.src);
102106

103107
if (image) {
104108
return;
@@ -119,6 +123,8 @@ export class ImageDrawer implements IShapeDrawer<ImageParticle> {
119123
return;
120124
}
121125

126+
this._engine.images ??= [];
127+
122128
const images = this._engine.images,
123129
imageData = particle.shapeData as IImageShape | undefined;
124130

@@ -127,7 +133,7 @@ export class ImageDrawer implements IShapeDrawer<ImageParticle> {
127133
}
128134

129135
const color = particle.getFillColor(),
130-
image = images?.find((t: IImage) => t.name === imageData.name || t.source === imageData.src);
136+
image = images.find((t: IImage) => t.name === imageData.name || t.source === imageData.src);
131137

132138
if (!image) {
133139
return;

0 commit comments

Comments
 (0)