@twin.org/image 0.0.3-next.21 → 0.0.3-next.23
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/README.md
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
# TWIN Image
|
|
2
2
|
|
|
3
|
-
This package
|
|
4
|
-
|
|
5
|
-
- JpegEncoder
|
|
6
|
-
- PngEncoder
|
|
3
|
+
This package is part of the framework workspace and provides classes for image manipulation to support consistent development workflows across the ecosystem.
|
|
7
4
|
|
|
8
5
|
## Installation
|
|
9
6
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.23](https://github.com/twinfoundation/framework/compare/image-v0.0.3-next.22...image-v0.0.3-next.23) (2026-03-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **image:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
16
|
+
* @twin.org/nameof bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
20
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.22 to 0.0.3-next.23
|
|
21
|
+
|
|
22
|
+
## [0.0.3-next.22](https://github.com/twinfoundation/framework/compare/image-v0.0.3-next.21...image-v0.0.3-next.22) (2026-02-26)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Miscellaneous Chores
|
|
26
|
+
|
|
27
|
+
* **image:** Synchronize repo versions
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Dependencies
|
|
31
|
+
|
|
32
|
+
* The following workspace dependencies were updated
|
|
33
|
+
* dependencies
|
|
34
|
+
* @twin.org/core bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
35
|
+
* @twin.org/nameof bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
36
|
+
* devDependencies
|
|
37
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
38
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
39
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.21 to 0.0.3-next.22
|
|
2
40
|
|
|
3
41
|
## [0.0.3-next.21](https://github.com/twinfoundation/framework/compare/image-v0.0.3-next.20...image-v0.0.3-next.21) (2026-02-26)
|
|
4
42
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Image Examples
|
|
2
|
+
|
|
3
|
+
Use these snippets for colour handling and image encoding when generating image assets.
|
|
4
|
+
|
|
5
|
+
## Color
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Color } from '@twin.org/image';
|
|
9
|
+
|
|
10
|
+
const accent = Color.fromHex('#4a90e2');
|
|
11
|
+
|
|
12
|
+
accent.red(); // 74
|
|
13
|
+
accent.green(); // 144
|
|
14
|
+
accent.blue(); // 226
|
|
15
|
+
accent.hexWithAlpha(); // '#ff4a90e2'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## JpegEncoder
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { Color, JpegEncoder } from '@twin.org/image';
|
|
22
|
+
|
|
23
|
+
const pixels = [
|
|
24
|
+
[Color.fromHex('#111111'), Color.fromHex('#eeeeee')],
|
|
25
|
+
[Color.fromHex('#eeeeee'), Color.fromHex('#111111')]
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const jpegBytes = JpegEncoder.encode(pixels, {
|
|
29
|
+
quality: 90
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
jpegBytes.length > 0; // true
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## PngEncoder
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Color, PngEncoder } from '@twin.org/image';
|
|
39
|
+
|
|
40
|
+
const pixels = [
|
|
41
|
+
[Color.fromHex('#ff0000'), Color.fromHex('#00ff00')],
|
|
42
|
+
[Color.fromHex('#0000ff'), Color.fromHex('#ffffff')]
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const pngBytes = PngEncoder.encode(pixels);
|
|
46
|
+
|
|
47
|
+
pngBytes.length > 0; // true
|
|
48
|
+
```
|
|
@@ -42,7 +42,7 @@ The blue element of the color.
|
|
|
42
42
|
|
|
43
43
|
## Properties
|
|
44
44
|
|
|
45
|
-
### CLASS\_NAME
|
|
45
|
+
### CLASS\_NAME {#class_name}
|
|
46
46
|
|
|
47
47
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
48
48
|
|
|
@@ -50,7 +50,7 @@ Runtime name for the class.
|
|
|
50
50
|
|
|
51
51
|
## Methods
|
|
52
52
|
|
|
53
|
-
### fromHex()
|
|
53
|
+
### fromHex() {#fromhex}
|
|
54
54
|
|
|
55
55
|
> `static` **fromHex**(`hex`): `Color`
|
|
56
56
|
|
|
@@ -76,7 +76,7 @@ Error if the format is incorrect.
|
|
|
76
76
|
|
|
77
77
|
***
|
|
78
78
|
|
|
79
|
-
### coerce()
|
|
79
|
+
### coerce() {#coerce}
|
|
80
80
|
|
|
81
81
|
> `static` **coerce**(`value`): `Color` \| `undefined`
|
|
82
82
|
|
|
@@ -98,7 +98,7 @@ The color if one can be created.
|
|
|
98
98
|
|
|
99
99
|
***
|
|
100
100
|
|
|
101
|
-
### alpha()
|
|
101
|
+
### alpha() {#alpha}
|
|
102
102
|
|
|
103
103
|
> **alpha**(): `number`
|
|
104
104
|
|
|
@@ -112,7 +112,7 @@ The alpha element.
|
|
|
112
112
|
|
|
113
113
|
***
|
|
114
114
|
|
|
115
|
-
### red()
|
|
115
|
+
### red() {#red}
|
|
116
116
|
|
|
117
117
|
> **red**(): `number`
|
|
118
118
|
|
|
@@ -126,7 +126,7 @@ The red element.
|
|
|
126
126
|
|
|
127
127
|
***
|
|
128
128
|
|
|
129
|
-
### green()
|
|
129
|
+
### green() {#green}
|
|
130
130
|
|
|
131
131
|
> **green**(): `number`
|
|
132
132
|
|
|
@@ -140,7 +140,7 @@ The green element.
|
|
|
140
140
|
|
|
141
141
|
***
|
|
142
142
|
|
|
143
|
-
### blue()
|
|
143
|
+
### blue() {#blue}
|
|
144
144
|
|
|
145
145
|
> **blue**(): `number`
|
|
146
146
|
|
|
@@ -154,7 +154,7 @@ The blue element.
|
|
|
154
154
|
|
|
155
155
|
***
|
|
156
156
|
|
|
157
|
-
### argb()
|
|
157
|
+
### argb() {#argb}
|
|
158
158
|
|
|
159
159
|
> **argb**(): `number`
|
|
160
160
|
|
|
@@ -168,7 +168,7 @@ The color as argb.
|
|
|
168
168
|
|
|
169
169
|
***
|
|
170
170
|
|
|
171
|
-
### rgba()
|
|
171
|
+
### rgba() {#rgba}
|
|
172
172
|
|
|
173
173
|
> **rgba**(): `number`
|
|
174
174
|
|
|
@@ -182,7 +182,7 @@ The color as rgba.
|
|
|
182
182
|
|
|
183
183
|
***
|
|
184
184
|
|
|
185
|
-
### rgbText()
|
|
185
|
+
### rgbText() {#rgbtext}
|
|
186
186
|
|
|
187
187
|
> **rgbText**(): `string`
|
|
188
188
|
|
|
@@ -196,7 +196,7 @@ The color as rgb.
|
|
|
196
196
|
|
|
197
197
|
***
|
|
198
198
|
|
|
199
|
-
### rgbaText()
|
|
199
|
+
### rgbaText() {#rgbatext}
|
|
200
200
|
|
|
201
201
|
> **rgbaText**(): `string`
|
|
202
202
|
|
|
@@ -210,7 +210,7 @@ The color as rgba.
|
|
|
210
210
|
|
|
211
211
|
***
|
|
212
212
|
|
|
213
|
-
### hex()
|
|
213
|
+
### hex() {#hex}
|
|
214
214
|
|
|
215
215
|
> **hex**(): `string`
|
|
216
216
|
|
|
@@ -224,7 +224,7 @@ The color as hex with no alpha component.
|
|
|
224
224
|
|
|
225
225
|
***
|
|
226
226
|
|
|
227
|
-
### hexWithAlpha()
|
|
227
|
+
### hexWithAlpha() {#hexwithalpha}
|
|
228
228
|
|
|
229
229
|
> **hexWithAlpha**(): `string`
|
|
230
230
|
|
|
@@ -17,7 +17,7 @@ Create a new instance of JpegEncoder.
|
|
|
17
17
|
|
|
18
18
|
## Properties
|
|
19
19
|
|
|
20
|
-
### CLASS\_NAME
|
|
20
|
+
### CLASS\_NAME {#class_name}
|
|
21
21
|
|
|
22
22
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ Runtime name for the class.
|
|
|
25
25
|
|
|
26
26
|
## Methods
|
|
27
27
|
|
|
28
|
-
### encode()
|
|
28
|
+
### encode() {#encode}
|
|
29
29
|
|
|
30
30
|
> **encode**(`width`, `height`, `imageData`, `quality`): `Uint8Array`
|
|
31
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/image",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.23",
|
|
4
4
|
"description": "Classes for image manipulation",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0.3-next.
|
|
18
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
17
|
+
"@twin.org/core": "0.0.3-next.23",
|
|
18
|
+
"@twin.org/nameof": "0.0.3-next.23"
|
|
19
19
|
},
|
|
20
20
|
"main": "./dist/es/index.js",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|