Skip to content

Commit 64b3dba

Browse files
committed
(#204) Introduced additional id property to images
1 parent 577ecba commit 64b3dba

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

Diff for: lib/image.class.ts

+29-27
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,35 @@
22
* The {@link Image} class represents generic image data
33
*/
44
export class Image {
5-
/**
6-
* {@link Image} class constructor
7-
* @param width {@link Image} width in pixels
8-
* @param height {@link Image} height in pixels
9-
* @param data Generic {@link Image} data
10-
* @param channels Amount of {@link Image} channels
11-
* @param pixelDensity Object containing scale info to work with e.g. Retina display data where the reported display size and pixel size differ (Default: {scaleX: 1.0, scaleY: 1.0})
12-
*/
13-
constructor(
14-
public readonly width: number,
15-
public readonly height: number,
16-
public readonly data: any,
17-
public readonly channels: number,
18-
public readonly pixelDensity: { scaleX: number; scaleY: number } = {
19-
scaleX: 1.0,
20-
scaleY: 1.0,
21-
},
22-
) {
23-
if (channels <= 0) {
24-
throw new Error("Channel <= 0");
5+
/**
6+
* {@link Image} class constructor
7+
* @param width {@link Image} width in pixels
8+
* @param height {@link Image} height in pixels
9+
* @param data Generic {@link Image} data
10+
* @param channels Amount of {@link Image} channels
11+
* @param id Image identifier
12+
* @param pixelDensity Object containing scale info to work with e.g. Retina display data where the reported display size and pixel size differ (Default: {scaleX: 1.0, scaleY: 1.0})
13+
*/
14+
constructor(
15+
public readonly width: number,
16+
public readonly height: number,
17+
public readonly data: any,
18+
public readonly channels: number,
19+
public readonly id: string,
20+
public readonly pixelDensity: { scaleX: number; scaleY: number } = {
21+
scaleX: 1.0,
22+
scaleY: 1.0,
23+
},
24+
) {
25+
if (channels <= 0) {
26+
throw new Error("Channel <= 0");
27+
}
2528
}
26-
}
2729

28-
/**
29-
* {@link hasAlphaChannel} return true if an {@link Image} has an additional (fourth) alpha channel
30-
*/
31-
public get hasAlphaChannel() {
32-
return this.channels > 3;
33-
}
30+
/**
31+
* {@link hasAlphaChannel} return true if an {@link Image} has an additional (fourth) alpha channel
32+
*/
33+
public get hasAlphaChannel() {
34+
return this.channels > 3;
35+
}
3436
}

0 commit comments

Comments
 (0)