@oh-my-pi/pi-coding-agent 5.6.70 → 5.7.67
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/CHANGELOG.md +6 -22
- package/package.json +5 -6
- package/src/utils/image-convert.ts +1 -1
- package/src/utils/image-resize.ts +2 -2
- package/src/vendor/photon/LICENSE.md +201 -0
- package/src/vendor/photon/README.md +158 -0
- package/src/vendor/photon/index.d.ts +3013 -0
- package/src/vendor/photon/index.js +4459 -0
- package/src/vendor/photon/photon_rs_bg.wasm +0 -0
- package/src/vendor/photon/photon_rs_bg.wasm.d.ts +193 -0
|
@@ -0,0 +1,4459 @@
|
|
|
1
|
+
/* @ts-self-types="./photon_rs.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Provides the image's height, width, and contains the image's raw pixels.
|
|
5
|
+
* For use when communicating between JS and WASM, and also natively.
|
|
6
|
+
*/
|
|
7
|
+
export class PhotonImage {
|
|
8
|
+
static __wrap(ptr) {
|
|
9
|
+
ptr = ptr >>> 0;
|
|
10
|
+
const obj = Object.create(PhotonImage.prototype);
|
|
11
|
+
obj.__wbg_ptr = ptr;
|
|
12
|
+
PhotonImageFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
__destroy_into_raw() {
|
|
16
|
+
const ptr = this.__wbg_ptr;
|
|
17
|
+
this.__wbg_ptr = 0;
|
|
18
|
+
PhotonImageFinalization.unregister(this);
|
|
19
|
+
return ptr;
|
|
20
|
+
}
|
|
21
|
+
free() {
|
|
22
|
+
const ptr = this.__destroy_into_raw();
|
|
23
|
+
wasm.__wbg_photonimage_free(ptr, 0);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert the PhotonImage to base64.
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
get_base64() {
|
|
30
|
+
let deferred1_0;
|
|
31
|
+
let deferred1_1;
|
|
32
|
+
try {
|
|
33
|
+
const ret = wasm.photonimage_get_base64(this.__wbg_ptr);
|
|
34
|
+
deferred1_0 = ret[0];
|
|
35
|
+
deferred1_1 = ret[1];
|
|
36
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
37
|
+
} finally {
|
|
38
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Convert the PhotonImage to raw bytes. Returns PNG.
|
|
43
|
+
* @returns {Uint8Array}
|
|
44
|
+
*/
|
|
45
|
+
get_bytes() {
|
|
46
|
+
const ret = wasm.photonimage_get_bytes(this.__wbg_ptr);
|
|
47
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
48
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
49
|
+
return v1;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert the PhotonImage to raw bytes. Returns a JPEG.
|
|
53
|
+
* @param {number} quality
|
|
54
|
+
* @returns {Uint8Array}
|
|
55
|
+
*/
|
|
56
|
+
get_bytes_jpeg(quality) {
|
|
57
|
+
const ret = wasm.photonimage_get_bytes_jpeg(this.__wbg_ptr, quality);
|
|
58
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
59
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
60
|
+
return v1;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Convert the PhotonImage to raw bytes. Returns a WEBP.
|
|
64
|
+
* @returns {Uint8Array}
|
|
65
|
+
*/
|
|
66
|
+
get_bytes_webp() {
|
|
67
|
+
const ret = wasm.photonimage_get_bytes_webp(this.__wbg_ptr);
|
|
68
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
69
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
70
|
+
return v1;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Calculates estimated filesize and returns number of bytes
|
|
74
|
+
* @returns {bigint}
|
|
75
|
+
*/
|
|
76
|
+
get_estimated_filesize() {
|
|
77
|
+
const ret = wasm.photonimage_get_estimated_filesize(this.__wbg_ptr);
|
|
78
|
+
return BigInt.asUintN(64, ret);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the height of the PhotonImage.
|
|
82
|
+
* @returns {number}
|
|
83
|
+
*/
|
|
84
|
+
get_height() {
|
|
85
|
+
const ret = wasm.photonimage_get_height(this.__wbg_ptr);
|
|
86
|
+
return ret >>> 0;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Convert the PhotonImage's raw pixels to JS-compatible ImageData.
|
|
90
|
+
* @returns {ImageData}
|
|
91
|
+
*/
|
|
92
|
+
get_image_data() {
|
|
93
|
+
const ret = wasm.photonimage_get_image_data(this.__wbg_ptr);
|
|
94
|
+
return ret;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get the PhotonImage's pixels as a Vec of u8s.
|
|
98
|
+
* @returns {Uint8Array}
|
|
99
|
+
*/
|
|
100
|
+
get_raw_pixels() {
|
|
101
|
+
const ret = wasm.photonimage_get_raw_pixels(this.__wbg_ptr);
|
|
102
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
103
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
104
|
+
return v1;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the width of the PhotonImage.
|
|
108
|
+
* @returns {number}
|
|
109
|
+
*/
|
|
110
|
+
get_width() {
|
|
111
|
+
const ret = wasm.photonimage_get_width(this.__wbg_ptr);
|
|
112
|
+
return ret >>> 0;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a new PhotonImage from a Vec of u8s, which represent raw pixels.
|
|
116
|
+
* @param {Uint8Array} raw_pixels
|
|
117
|
+
* @param {number} width
|
|
118
|
+
* @param {number} height
|
|
119
|
+
*/
|
|
120
|
+
constructor(raw_pixels, width, height) {
|
|
121
|
+
const ptr0 = passArray8ToWasm0(raw_pixels, wasm.__wbindgen_malloc);
|
|
122
|
+
const len0 = WASM_VECTOR_LEN;
|
|
123
|
+
const ret = wasm.photonimage_new(ptr0, len0, width, height);
|
|
124
|
+
this.__wbg_ptr = ret >>> 0;
|
|
125
|
+
PhotonImageFinalization.register(this, this.__wbg_ptr, this);
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Create a new PhotonImage from a base64 string.
|
|
130
|
+
* @param {string} base64
|
|
131
|
+
* @returns {PhotonImage}
|
|
132
|
+
*/
|
|
133
|
+
static new_from_base64(base64) {
|
|
134
|
+
const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
135
|
+
const len0 = WASM_VECTOR_LEN;
|
|
136
|
+
const ret = wasm.base64_to_image(ptr0, len0);
|
|
137
|
+
return PhotonImage.__wrap(ret);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Create a new PhotonImage from a Blob/File.
|
|
141
|
+
* @param {Blob} blob
|
|
142
|
+
* @returns {PhotonImage}
|
|
143
|
+
*/
|
|
144
|
+
static new_from_blob(blob) {
|
|
145
|
+
const ret = wasm.photonimage_new_from_blob(blob);
|
|
146
|
+
return PhotonImage.__wrap(ret);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Create a new PhotonImage from a byteslice.
|
|
150
|
+
* @param {Uint8Array} vec
|
|
151
|
+
* @returns {PhotonImage}
|
|
152
|
+
*/
|
|
153
|
+
static new_from_byteslice(vec) {
|
|
154
|
+
const ptr0 = passArray8ToWasm0(vec, wasm.__wbindgen_malloc);
|
|
155
|
+
const len0 = WASM_VECTOR_LEN;
|
|
156
|
+
const ret = wasm.photonimage_new_from_byteslice(ptr0, len0);
|
|
157
|
+
return PhotonImage.__wrap(ret);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create a new PhotonImage from a HTMLImageElement
|
|
161
|
+
* @param {HTMLImageElement} image
|
|
162
|
+
* @returns {PhotonImage}
|
|
163
|
+
*/
|
|
164
|
+
static new_from_image(image) {
|
|
165
|
+
const ret = wasm.photonimage_new_from_image(image);
|
|
166
|
+
return PhotonImage.__wrap(ret);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Convert ImageData to raw pixels, and update the PhotonImage's raw pixels to this.
|
|
170
|
+
* @param {ImageData} img_data
|
|
171
|
+
*/
|
|
172
|
+
set_imgdata(img_data) {
|
|
173
|
+
wasm.photonimage_set_imgdata(this.__wbg_ptr, img_data);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (Symbol.dispose) PhotonImage.prototype[Symbol.dispose] = PhotonImage.prototype.free;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* RGB color type.
|
|
180
|
+
*/
|
|
181
|
+
export class Rgb {
|
|
182
|
+
__destroy_into_raw() {
|
|
183
|
+
const ptr = this.__wbg_ptr;
|
|
184
|
+
this.__wbg_ptr = 0;
|
|
185
|
+
RgbFinalization.unregister(this);
|
|
186
|
+
return ptr;
|
|
187
|
+
}
|
|
188
|
+
free() {
|
|
189
|
+
const ptr = this.__destroy_into_raw();
|
|
190
|
+
wasm.__wbg_rgb_free(ptr, 0);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get the Blue value.
|
|
194
|
+
* @returns {number}
|
|
195
|
+
*/
|
|
196
|
+
get_blue() {
|
|
197
|
+
const ret = wasm.rgb_get_blue(this.__wbg_ptr);
|
|
198
|
+
return ret;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get the Green value.
|
|
202
|
+
* @returns {number}
|
|
203
|
+
*/
|
|
204
|
+
get_green() {
|
|
205
|
+
const ret = wasm.rgb_get_green(this.__wbg_ptr);
|
|
206
|
+
return ret;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get the Red value.
|
|
210
|
+
* @returns {number}
|
|
211
|
+
*/
|
|
212
|
+
get_red() {
|
|
213
|
+
const ret = wasm.rgb_get_red(this.__wbg_ptr);
|
|
214
|
+
return ret;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Create a new RGB struct.
|
|
218
|
+
* @param {number} r
|
|
219
|
+
* @param {number} g
|
|
220
|
+
* @param {number} b
|
|
221
|
+
*/
|
|
222
|
+
constructor(r, g, b) {
|
|
223
|
+
const ret = wasm.rgb_new(r, g, b);
|
|
224
|
+
this.__wbg_ptr = ret >>> 0;
|
|
225
|
+
RgbFinalization.register(this, this.__wbg_ptr, this);
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Set the Blue value.
|
|
230
|
+
* @param {number} b
|
|
231
|
+
*/
|
|
232
|
+
set_blue(b) {
|
|
233
|
+
wasm.rgb_set_blue(this.__wbg_ptr, b);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get the Green value.
|
|
237
|
+
* @param {number} g
|
|
238
|
+
*/
|
|
239
|
+
set_green(g) {
|
|
240
|
+
wasm.rgb_set_green(this.__wbg_ptr, g);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Set the Red value.
|
|
244
|
+
* @param {number} r
|
|
245
|
+
*/
|
|
246
|
+
set_red(r) {
|
|
247
|
+
wasm.rgb_set_red(this.__wbg_ptr, r);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
if (Symbol.dispose) Rgb.prototype[Symbol.dispose] = Rgb.prototype.free;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* RGBA color type.
|
|
254
|
+
*/
|
|
255
|
+
export class Rgba {
|
|
256
|
+
__destroy_into_raw() {
|
|
257
|
+
const ptr = this.__wbg_ptr;
|
|
258
|
+
this.__wbg_ptr = 0;
|
|
259
|
+
RgbaFinalization.unregister(this);
|
|
260
|
+
return ptr;
|
|
261
|
+
}
|
|
262
|
+
free() {
|
|
263
|
+
const ptr = this.__destroy_into_raw();
|
|
264
|
+
wasm.__wbg_rgba_free(ptr, 0);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get the alpha value for this color.
|
|
268
|
+
* @returns {number}
|
|
269
|
+
*/
|
|
270
|
+
get_alpha() {
|
|
271
|
+
const ret = wasm.rgba_get_alpha(this.__wbg_ptr);
|
|
272
|
+
return ret;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Get the Blue value.
|
|
276
|
+
* @returns {number}
|
|
277
|
+
*/
|
|
278
|
+
get_blue() {
|
|
279
|
+
const ret = wasm.rgb_get_blue(this.__wbg_ptr);
|
|
280
|
+
return ret;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Get the Green value.
|
|
284
|
+
* @returns {number}
|
|
285
|
+
*/
|
|
286
|
+
get_green() {
|
|
287
|
+
const ret = wasm.rgb_get_green(this.__wbg_ptr);
|
|
288
|
+
return ret;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Get the Red value.
|
|
292
|
+
* @returns {number}
|
|
293
|
+
*/
|
|
294
|
+
get_red() {
|
|
295
|
+
const ret = wasm.rgb_get_red(this.__wbg_ptr);
|
|
296
|
+
return ret;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Create a new RGBA struct.
|
|
300
|
+
* @param {number} r
|
|
301
|
+
* @param {number} g
|
|
302
|
+
* @param {number} b
|
|
303
|
+
* @param {number} a
|
|
304
|
+
*/
|
|
305
|
+
constructor(r, g, b, a) {
|
|
306
|
+
const ret = wasm.rgba_new(r, g, b, a);
|
|
307
|
+
this.__wbg_ptr = ret >>> 0;
|
|
308
|
+
RgbaFinalization.register(this, this.__wbg_ptr, this);
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Set the alpha value.
|
|
313
|
+
* @param {number} a
|
|
314
|
+
*/
|
|
315
|
+
set_alpha(a) {
|
|
316
|
+
wasm.rgba_set_alpha(this.__wbg_ptr, a);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Set the Blue value.
|
|
320
|
+
* @param {number} b
|
|
321
|
+
*/
|
|
322
|
+
set_blue(b) {
|
|
323
|
+
wasm.rgb_set_blue(this.__wbg_ptr, b);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Get the Green value.
|
|
327
|
+
* @param {number} g
|
|
328
|
+
*/
|
|
329
|
+
set_green(g) {
|
|
330
|
+
wasm.rgb_set_green(this.__wbg_ptr, g);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Set the Red value.
|
|
334
|
+
* @param {number} r
|
|
335
|
+
*/
|
|
336
|
+
set_red(r) {
|
|
337
|
+
wasm.rgb_set_red(this.__wbg_ptr, r);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (Symbol.dispose) Rgba.prototype[Symbol.dispose] = Rgba.prototype.free;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* @enum {1 | 2 | 3 | 4 | 5}
|
|
344
|
+
*/
|
|
345
|
+
export const SamplingFilter = Object.freeze({
|
|
346
|
+
Nearest: 1, "1": "Nearest",
|
|
347
|
+
Triangle: 2, "2": "Triangle",
|
|
348
|
+
CatmullRom: 3, "3": "CatmullRom",
|
|
349
|
+
Gaussian: 4, "4": "Gaussian",
|
|
350
|
+
Lanczos3: 5, "5": "Lanczos3",
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Add randomized noise to an image.
|
|
355
|
+
* This function adds a Gaussian Noise Sample to each pixel through incrementing each channel by a randomized offset.
|
|
356
|
+
* This randomized offset is generated by creating a randomized thread pool.
|
|
357
|
+
* **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but
|
|
358
|
+
* a workaround using js_sys::Math::random works now.
|
|
359
|
+
* # Arguments
|
|
360
|
+
* * `img` - A PhotonImage.
|
|
361
|
+
*
|
|
362
|
+
* # Example
|
|
363
|
+
*
|
|
364
|
+
* ```no_run
|
|
365
|
+
* // For example:
|
|
366
|
+
* use photon_rs::native::open_image;
|
|
367
|
+
* use photon_rs::noise::add_noise_rand;
|
|
368
|
+
* use photon_rs::PhotonImage;
|
|
369
|
+
*
|
|
370
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
371
|
+
* add_noise_rand(&mut img);
|
|
372
|
+
* ```
|
|
373
|
+
* @param {PhotonImage} photon_image
|
|
374
|
+
*/
|
|
375
|
+
export function add_noise_rand(photon_image) {
|
|
376
|
+
_assertClass(photon_image, PhotonImage);
|
|
377
|
+
wasm.add_noise_rand(photon_image.__wbg_ptr);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Adjust the brightness of an image by a factor.
|
|
382
|
+
*
|
|
383
|
+
* # Arguments
|
|
384
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
385
|
+
* * `brightness` - A u8 to add or subtract to the brightness. To increase
|
|
386
|
+
* the brightness, pass a positive number (up to 255). To decrease the brightness,
|
|
387
|
+
* pass a negative number instead.
|
|
388
|
+
* # Example
|
|
389
|
+
*
|
|
390
|
+
* ```no_run
|
|
391
|
+
* use photon_rs::effects::adjust_brightness;
|
|
392
|
+
* use photon_rs::native::open_image;
|
|
393
|
+
*
|
|
394
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
395
|
+
* adjust_brightness(&mut img, 10_i16);
|
|
396
|
+
* ```
|
|
397
|
+
* @param {PhotonImage} photon_image
|
|
398
|
+
* @param {number} brightness
|
|
399
|
+
*/
|
|
400
|
+
export function adjust_brightness(photon_image, brightness) {
|
|
401
|
+
_assertClass(photon_image, PhotonImage);
|
|
402
|
+
wasm.adjust_brightness(photon_image.__wbg_ptr, brightness);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Adjust the contrast of an image by a factor.
|
|
407
|
+
*
|
|
408
|
+
* # Arguments
|
|
409
|
+
* * `photon_image` - A PhotonImage that contains a view into the image.
|
|
410
|
+
* * `contrast` - An f32 factor used to adjust contrast. Between [-255.0, 255.0]. The algorithm will
|
|
411
|
+
* clamp results if passed factor is out of range.
|
|
412
|
+
* # Example
|
|
413
|
+
*
|
|
414
|
+
* ```no_run
|
|
415
|
+
* use photon_rs::effects::adjust_contrast;
|
|
416
|
+
* use photon_rs::native::open_image;
|
|
417
|
+
*
|
|
418
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
419
|
+
* adjust_contrast(&mut img, 30_f32);
|
|
420
|
+
* ```
|
|
421
|
+
* @param {PhotonImage} photon_image
|
|
422
|
+
* @param {number} contrast
|
|
423
|
+
*/
|
|
424
|
+
export function adjust_contrast(photon_image, contrast) {
|
|
425
|
+
_assertClass(photon_image, PhotonImage);
|
|
426
|
+
wasm.adjust_contrast(photon_image.__wbg_ptr, contrast);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Increment or decrement every pixel's Blue channel by a constant.
|
|
431
|
+
*
|
|
432
|
+
* # Arguments
|
|
433
|
+
* * `img` - A PhotonImage.
|
|
434
|
+
* * `amt` - The amount to increment or decrement the channel's value by for that pixel.
|
|
435
|
+
*
|
|
436
|
+
* # Example
|
|
437
|
+
*
|
|
438
|
+
* ```no_run
|
|
439
|
+
* // For example, to increase the Blue channel for all pixels by 10:
|
|
440
|
+
* use photon_rs::channels::alter_blue_channel;
|
|
441
|
+
* use photon_rs::native::open_image;
|
|
442
|
+
*
|
|
443
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
444
|
+
* alter_blue_channel(&mut img, 10_i16);
|
|
445
|
+
* ```
|
|
446
|
+
* @param {PhotonImage} img
|
|
447
|
+
* @param {number} amt
|
|
448
|
+
*/
|
|
449
|
+
export function alter_blue_channel(img, amt) {
|
|
450
|
+
_assertClass(img, PhotonImage);
|
|
451
|
+
wasm.alter_blue_channel(img.__wbg_ptr, amt);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Alter a select channel by incrementing or decrementing its value by a constant.
|
|
456
|
+
*
|
|
457
|
+
* # Arguments
|
|
458
|
+
* * `img` - A PhotonImage.
|
|
459
|
+
* * `channel` - The channel you wish to alter, it should be either 0, 1 or 2,
|
|
460
|
+
* representing R, G, or B respectively. (O=Red, 1=Green, 2=Blue)
|
|
461
|
+
* * `amount` - The amount to increment/decrement the channel's value by for that pixel.
|
|
462
|
+
* A positive value will increment/decrement the channel's value, a negative value will decrement the channel's value.
|
|
463
|
+
*
|
|
464
|
+
* ## Example
|
|
465
|
+
*
|
|
466
|
+
* ```no_run
|
|
467
|
+
* // For example, to increase the Red channel for all pixels by 10:
|
|
468
|
+
* use photon_rs::channels::alter_channel;
|
|
469
|
+
* use photon_rs::native::{open_image};
|
|
470
|
+
*
|
|
471
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
472
|
+
* alter_channel(&mut img, 0_usize, 10_i16);
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* Adds a constant to a select R, G, or B channel's value.
|
|
476
|
+
*
|
|
477
|
+
* ### Decrease a channel's value
|
|
478
|
+
* // For example, to decrease the Green channel for all pixels by 20:
|
|
479
|
+
* ```no_run
|
|
480
|
+
* use photon_rs::channels::alter_channel;
|
|
481
|
+
* use photon_rs::native::open_image;
|
|
482
|
+
*
|
|
483
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
484
|
+
* alter_channel(&mut img, 1_usize, -20_i16);
|
|
485
|
+
* ```
|
|
486
|
+
* **Note**: Note the use of a minus symbol when decreasing the channel.
|
|
487
|
+
* @param {PhotonImage} img
|
|
488
|
+
* @param {number} channel
|
|
489
|
+
* @param {number} amt
|
|
490
|
+
*/
|
|
491
|
+
export function alter_channel(img, channel, amt) {
|
|
492
|
+
_assertClass(img, PhotonImage);
|
|
493
|
+
wasm.alter_channel(img.__wbg_ptr, channel, amt);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Increment all 3 channels' values by adding an amt to each channel per pixel.
|
|
498
|
+
*
|
|
499
|
+
* # Arguments
|
|
500
|
+
* * `img` - A PhotonImage.
|
|
501
|
+
* * `r_amt` - The amount to increment/decrement the Red channel by.
|
|
502
|
+
* * `g_amt` - The amount to increment/decrement the Green channel by.
|
|
503
|
+
* * `b_amt` - The amount to increment/decrement the Blue channel by.
|
|
504
|
+
*
|
|
505
|
+
* # Example
|
|
506
|
+
*
|
|
507
|
+
* ```no_run
|
|
508
|
+
* // For example, to increase the values of the Red channel by 10, the Green channel by 20,
|
|
509
|
+
* // and the Blue channel by 50:
|
|
510
|
+
* use photon_rs::channels::alter_channels;
|
|
511
|
+
* use photon_rs::native::open_image;
|
|
512
|
+
*
|
|
513
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
514
|
+
* alter_channels(&mut img, 10_i16, 20_i16, 50_i16);
|
|
515
|
+
* ```
|
|
516
|
+
* @param {PhotonImage} img
|
|
517
|
+
* @param {number} r_amt
|
|
518
|
+
* @param {number} g_amt
|
|
519
|
+
* @param {number} b_amt
|
|
520
|
+
*/
|
|
521
|
+
export function alter_channels(img, r_amt, g_amt, b_amt) {
|
|
522
|
+
_assertClass(img, PhotonImage);
|
|
523
|
+
wasm.alter_channels(img.__wbg_ptr, r_amt, g_amt, b_amt);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Increment or decrement every pixel's Green channel by a constant.
|
|
528
|
+
*
|
|
529
|
+
* # Arguments
|
|
530
|
+
* * `img` - A PhotonImage.
|
|
531
|
+
* * `amt` - The amount to increment/decrement the channel's value by for that pixel.
|
|
532
|
+
*
|
|
533
|
+
* # Example
|
|
534
|
+
*
|
|
535
|
+
* ```no_run
|
|
536
|
+
* // For example, to increase the Green channel for all pixels by 20:
|
|
537
|
+
* use photon_rs::channels::alter_green_channel;
|
|
538
|
+
* use photon_rs::native::open_image;
|
|
539
|
+
*
|
|
540
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
541
|
+
* alter_green_channel(&mut img, 20_i16);
|
|
542
|
+
* ```
|
|
543
|
+
* @param {PhotonImage} img
|
|
544
|
+
* @param {number} amt
|
|
545
|
+
*/
|
|
546
|
+
export function alter_green_channel(img, amt) {
|
|
547
|
+
_assertClass(img, PhotonImage);
|
|
548
|
+
wasm.alter_green_channel(img.__wbg_ptr, amt);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Increment or decrement every pixel's Red channel by a constant.
|
|
553
|
+
*
|
|
554
|
+
* # Arguments
|
|
555
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
556
|
+
* * `amt` - The amount to increment or decrement the channel's value by for that pixel.
|
|
557
|
+
*
|
|
558
|
+
* # Example
|
|
559
|
+
*
|
|
560
|
+
* ```no_run
|
|
561
|
+
* // For example, to increase the Red channel for all pixels by 10:
|
|
562
|
+
* use photon_rs::channels::alter_red_channel;
|
|
563
|
+
* use photon_rs::native::open_image;
|
|
564
|
+
*
|
|
565
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
566
|
+
* alter_red_channel(&mut img, 10_i16);
|
|
567
|
+
* ```
|
|
568
|
+
* @param {PhotonImage} photon_image
|
|
569
|
+
* @param {number} amt
|
|
570
|
+
*/
|
|
571
|
+
export function alter_red_channel(photon_image, amt) {
|
|
572
|
+
_assertClass(photon_image, PhotonImage);
|
|
573
|
+
wasm.alter_red_channel(photon_image.__wbg_ptr, amt);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Increment/decrement two channels' values simultaneously by adding an amt to each channel per pixel.
|
|
578
|
+
*
|
|
579
|
+
* # Arguments
|
|
580
|
+
* * `img` - A PhotonImage.
|
|
581
|
+
* * `channel1` - A usize from 0 to 2 that represents either the R, G or B channels.
|
|
582
|
+
* * `amt1` - The amount to increment/decrement the channel's value by for that pixel.
|
|
583
|
+
* * `channel2` -A usize from 0 to 2 that represents either the R, G or B channels.
|
|
584
|
+
* * `amt2` - The amount to increment/decrement the channel's value by for that pixel.
|
|
585
|
+
*
|
|
586
|
+
* # Example
|
|
587
|
+
*
|
|
588
|
+
* ```no_run
|
|
589
|
+
* // For example, to increase the values of the Red and Blue channels per pixel:
|
|
590
|
+
* use photon_rs::channels::alter_two_channels;
|
|
591
|
+
* use photon_rs::native::open_image;
|
|
592
|
+
*
|
|
593
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
594
|
+
* alter_two_channels(&mut img, 0_usize, 10_i16, 2_usize, 20_i16);
|
|
595
|
+
* ```
|
|
596
|
+
* @param {PhotonImage} img
|
|
597
|
+
* @param {number} channel1
|
|
598
|
+
* @param {number} amt1
|
|
599
|
+
* @param {number} channel2
|
|
600
|
+
* @param {number} amt2
|
|
601
|
+
*/
|
|
602
|
+
export function alter_two_channels(img, channel1, amt1, channel2, amt2) {
|
|
603
|
+
_assertClass(img, PhotonImage);
|
|
604
|
+
wasm.alter_two_channels(img.__wbg_ptr, channel1, amt1, channel2, amt2);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Apply a gradient to an image.
|
|
609
|
+
* @param {PhotonImage} image
|
|
610
|
+
*/
|
|
611
|
+
export function apply_gradient(image) {
|
|
612
|
+
_assertClass(image, PhotonImage);
|
|
613
|
+
wasm.apply_gradient(image.__wbg_ptr);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Convert an image to grayscale by setting a pixel's 3 RGB values to the Blue channel's value.
|
|
618
|
+
*
|
|
619
|
+
* # Arguments
|
|
620
|
+
* * `photon_image` - A PhotonImage.
|
|
621
|
+
*
|
|
622
|
+
* # Example
|
|
623
|
+
*
|
|
624
|
+
* ```no_run
|
|
625
|
+
* use photon_rs::monochrome::b_grayscale;
|
|
626
|
+
* use photon_rs::native::open_image;
|
|
627
|
+
*
|
|
628
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
629
|
+
* b_grayscale(&mut img);
|
|
630
|
+
* ```
|
|
631
|
+
* @param {PhotonImage} photon_image
|
|
632
|
+
*/
|
|
633
|
+
export function b_grayscale(photon_image) {
|
|
634
|
+
_assertClass(photon_image, PhotonImage);
|
|
635
|
+
wasm.b_grayscale(photon_image.__wbg_ptr);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Convert a base64 string to a PhotonImage.
|
|
640
|
+
* @param {string} base64
|
|
641
|
+
* @returns {PhotonImage}
|
|
642
|
+
*/
|
|
643
|
+
export function base64_to_image(base64) {
|
|
644
|
+
const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
645
|
+
const len0 = WASM_VECTOR_LEN;
|
|
646
|
+
const ret = wasm.base64_to_image(ptr0, len0);
|
|
647
|
+
return PhotonImage.__wrap(ret);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Convert a base64 string to a Vec of u8s.
|
|
652
|
+
* @param {string} base64
|
|
653
|
+
* @returns {Uint8Array}
|
|
654
|
+
*/
|
|
655
|
+
export function base64_to_vec(base64) {
|
|
656
|
+
const ptr0 = passStringToWasm0(base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
657
|
+
const len0 = WASM_VECTOR_LEN;
|
|
658
|
+
const ret = wasm.base64_to_vec(ptr0, len0);
|
|
659
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
660
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
661
|
+
return v2;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Blend two images together.
|
|
666
|
+
*
|
|
667
|
+
* The `blend_mode` (3rd param) determines which blending mode to use; change this for varying effects.
|
|
668
|
+
* The blend modes available include: `overlay`, `over`, `atop`, `xor`, `plus`, `multiply`, `burn`,
|
|
669
|
+
* `difference`, `soft_light`, `screen`, `hard_light`, `dodge`, `exclusion`, `lighten`, `darken` (more to come)
|
|
670
|
+
* NOTE: The first image must be smaller than the second image passed as params.
|
|
671
|
+
* If the first image were larger than the second, then there would be overflowing pixels which would have no corresponding pixels
|
|
672
|
+
* in the second image.
|
|
673
|
+
* # Arguments
|
|
674
|
+
* * `img` - A DynamicImage that contains a view into the image.
|
|
675
|
+
* * `img2` - The 2nd DynamicImage to be blended with the first.
|
|
676
|
+
* * `blend_mode` - The blending mode to use. See above for complete list of blend modes available.
|
|
677
|
+
* # Example
|
|
678
|
+
*
|
|
679
|
+
* ```no_run
|
|
680
|
+
* // For example, to blend two images with the `multiply` blend mode:
|
|
681
|
+
* use photon_rs::multiple::blend;
|
|
682
|
+
* use photon_rs::native::open_image;
|
|
683
|
+
*
|
|
684
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
685
|
+
* let img2 = open_image("img2.jpg").expect("File should open");
|
|
686
|
+
* blend(&mut img, &img2, "multiply");
|
|
687
|
+
* ```
|
|
688
|
+
* @param {PhotonImage} photon_image
|
|
689
|
+
* @param {PhotonImage} photon_image2
|
|
690
|
+
* @param {string} blend_mode
|
|
691
|
+
*/
|
|
692
|
+
export function blend(photon_image, photon_image2, blend_mode) {
|
|
693
|
+
_assertClass(photon_image, PhotonImage);
|
|
694
|
+
_assertClass(photon_image2, PhotonImage);
|
|
695
|
+
const ptr0 = passStringToWasm0(blend_mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
696
|
+
const len0 = WASM_VECTOR_LEN;
|
|
697
|
+
wasm.blend(photon_image.__wbg_ptr, photon_image2.__wbg_ptr, ptr0, len0);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Apply a box blur effect.
|
|
702
|
+
*
|
|
703
|
+
* # Arguments
|
|
704
|
+
* * `img` - A PhotonImage.
|
|
705
|
+
*
|
|
706
|
+
* # Example
|
|
707
|
+
*
|
|
708
|
+
* ```no_run
|
|
709
|
+
* // For example, to apply a box blur effect:
|
|
710
|
+
* use photon_rs::conv::box_blur;
|
|
711
|
+
* use photon_rs::native::open_image;
|
|
712
|
+
*
|
|
713
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
714
|
+
* box_blur(&mut img);
|
|
715
|
+
* ```
|
|
716
|
+
* @param {PhotonImage} photon_image
|
|
717
|
+
*/
|
|
718
|
+
export function box_blur(photon_image) {
|
|
719
|
+
_assertClass(photon_image, PhotonImage);
|
|
720
|
+
wasm.box_blur(photon_image.__wbg_ptr);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Increased contrast filter effect.
|
|
725
|
+
*
|
|
726
|
+
* # Arguments
|
|
727
|
+
* * `img` - A PhotonImage.
|
|
728
|
+
* # Example
|
|
729
|
+
*
|
|
730
|
+
* ```no_run
|
|
731
|
+
* use photon_rs::filters::cali;
|
|
732
|
+
* use photon_rs::native::open_image;
|
|
733
|
+
*
|
|
734
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
735
|
+
* cali(&mut img);
|
|
736
|
+
* ```
|
|
737
|
+
* @param {PhotonImage} img
|
|
738
|
+
*/
|
|
739
|
+
export function cali(img) {
|
|
740
|
+
_assertClass(img, PhotonImage);
|
|
741
|
+
wasm.cali(img.__wbg_ptr);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Horizontal strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well.
|
|
746
|
+
*
|
|
747
|
+
* # Arguments
|
|
748
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
749
|
+
* * `num_strips` - The numbder of strips
|
|
750
|
+
* * `color` - Color of strips.
|
|
751
|
+
* # Example
|
|
752
|
+
*
|
|
753
|
+
* ```no_run
|
|
754
|
+
* // For example, to draw blue horizontal strips on a `PhotonImage`:
|
|
755
|
+
* use photon_rs::effects::color_horizontal_strips;
|
|
756
|
+
* use photon_rs::native::open_image;
|
|
757
|
+
* use photon_rs::Rgb;
|
|
758
|
+
*
|
|
759
|
+
* let color = Rgb::new(255u8, 0u8, 0u8);
|
|
760
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
761
|
+
* color_horizontal_strips(&mut img, 8u8, color);
|
|
762
|
+
* ```
|
|
763
|
+
* @param {PhotonImage} photon_image
|
|
764
|
+
* @param {number} num_strips
|
|
765
|
+
* @param {Rgb} color
|
|
766
|
+
*/
|
|
767
|
+
export function color_horizontal_strips(photon_image, num_strips, color) {
|
|
768
|
+
_assertClass(photon_image, PhotonImage);
|
|
769
|
+
_assertClass(color, Rgb);
|
|
770
|
+
var ptr0 = color.__destroy_into_raw();
|
|
771
|
+
wasm.color_horizontal_strips(photon_image.__wbg_ptr, num_strips, ptr0);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect. Sepcify a color as well.
|
|
776
|
+
*
|
|
777
|
+
* # Arguments
|
|
778
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
779
|
+
* * `num_strips` - The numbder of strips
|
|
780
|
+
* * `color` - Color of strips.
|
|
781
|
+
* # Example
|
|
782
|
+
*
|
|
783
|
+
* ```no_run
|
|
784
|
+
* // For example, to draw red vertical strips on a `PhotonImage`:
|
|
785
|
+
* use photon_rs::effects::color_vertical_strips;
|
|
786
|
+
* use photon_rs::native::open_image;
|
|
787
|
+
* use photon_rs::Rgb;
|
|
788
|
+
*
|
|
789
|
+
* let color = Rgb::new(255u8, 0u8, 0u8);
|
|
790
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
791
|
+
* color_vertical_strips(&mut img, 8u8, color);
|
|
792
|
+
* ```
|
|
793
|
+
* @param {PhotonImage} photon_image
|
|
794
|
+
* @param {number} num_strips
|
|
795
|
+
* @param {Rgb} color
|
|
796
|
+
*/
|
|
797
|
+
export function color_vertical_strips(photon_image, num_strips, color) {
|
|
798
|
+
_assertClass(photon_image, PhotonImage);
|
|
799
|
+
_assertClass(color, Rgb);
|
|
800
|
+
var ptr0 = color.__destroy_into_raw();
|
|
801
|
+
wasm.color_vertical_strips(photon_image.__wbg_ptr, num_strips, ptr0);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Colorizes the green channels of the image.
|
|
806
|
+
*
|
|
807
|
+
* # Arguments
|
|
808
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
809
|
+
* # Example
|
|
810
|
+
*
|
|
811
|
+
* ```no_run
|
|
812
|
+
* // For example, to colorize an image of type `PhotonImage`:
|
|
813
|
+
* use photon_rs::effects::colorize;
|
|
814
|
+
* use photon_rs::native::open_image;
|
|
815
|
+
*
|
|
816
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
817
|
+
* colorize(&mut img);
|
|
818
|
+
* ```
|
|
819
|
+
* @param {PhotonImage} photon_image
|
|
820
|
+
*/
|
|
821
|
+
export function colorize(photon_image) {
|
|
822
|
+
_assertClass(photon_image, PhotonImage);
|
|
823
|
+
wasm.colorize(photon_image.__wbg_ptr);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* @param {number} width
|
|
828
|
+
* @param {number} height
|
|
829
|
+
* @returns {PhotonImage}
|
|
830
|
+
*/
|
|
831
|
+
export function create_gradient(width, height) {
|
|
832
|
+
const ret = wasm.create_gradient(width, height);
|
|
833
|
+
return PhotonImage.__wrap(ret);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Crop an image.
|
|
838
|
+
*
|
|
839
|
+
* # Arguments
|
|
840
|
+
* * `img` - A PhotonImage.
|
|
841
|
+
*
|
|
842
|
+
* # Example
|
|
843
|
+
*
|
|
844
|
+
* ```no_run
|
|
845
|
+
* // For example, to crop an image at (0, 0) to (500, 800)
|
|
846
|
+
* use photon_rs::native::{open_image};
|
|
847
|
+
* use photon_rs::transform::crop;
|
|
848
|
+
* use photon_rs::PhotonImage;
|
|
849
|
+
*
|
|
850
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
851
|
+
* let cropped_img: PhotonImage = crop(&img, 0_u32, 0_u32, 500_u32, 800_u32);
|
|
852
|
+
* // Write the contents of this image in JPG format.
|
|
853
|
+
* ```
|
|
854
|
+
* @param {PhotonImage} photon_image
|
|
855
|
+
* @param {number} x1
|
|
856
|
+
* @param {number} y1
|
|
857
|
+
* @param {number} x2
|
|
858
|
+
* @param {number} y2
|
|
859
|
+
* @returns {PhotonImage}
|
|
860
|
+
*/
|
|
861
|
+
export function crop(photon_image, x1, y1, x2, y2) {
|
|
862
|
+
_assertClass(photon_image, PhotonImage);
|
|
863
|
+
const ret = wasm.crop(photon_image.__wbg_ptr, x1, y1, x2, y2);
|
|
864
|
+
return PhotonImage.__wrap(ret);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* @param {HTMLCanvasElement} source_canvas
|
|
869
|
+
* @param {number} width
|
|
870
|
+
* @param {number} height
|
|
871
|
+
* @param {number} left
|
|
872
|
+
* @param {number} top
|
|
873
|
+
* @returns {HTMLCanvasElement}
|
|
874
|
+
*/
|
|
875
|
+
export function crop_img_browser(source_canvas, width, height, left, top) {
|
|
876
|
+
const ret = wasm.crop_img_browser(source_canvas, width, height, left, top);
|
|
877
|
+
return ret;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* Darken the image by a specified amount in the HSL colour space.
|
|
882
|
+
*
|
|
883
|
+
* # Arguments
|
|
884
|
+
* * `img` - A PhotonImage.
|
|
885
|
+
* * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
|
|
886
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
887
|
+
* Darkening by 80% would be represented by a `level` of 0.8
|
|
888
|
+
*
|
|
889
|
+
* # Example
|
|
890
|
+
* ```no_run
|
|
891
|
+
* // For example to darken an image by 10% in the HSL colour space:
|
|
892
|
+
* use photon_rs::colour_spaces::darken_hsl;
|
|
893
|
+
* use photon_rs::native::open_image;
|
|
894
|
+
*
|
|
895
|
+
* // Open the image. A PhotonImage is returned.
|
|
896
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
897
|
+
* darken_hsl(&mut img, 0.1_f32);
|
|
898
|
+
* ```
|
|
899
|
+
* @param {PhotonImage} img
|
|
900
|
+
* @param {number} level
|
|
901
|
+
*/
|
|
902
|
+
export function darken_hsl(img, level) {
|
|
903
|
+
_assertClass(img, PhotonImage);
|
|
904
|
+
wasm.darken_hsl(img.__wbg_ptr, level);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Darken the image by a specified amount in the HSLuv colour space.
|
|
909
|
+
*
|
|
910
|
+
* # Arguments
|
|
911
|
+
* * `img` - A PhotonImage.
|
|
912
|
+
* * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
|
|
913
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
914
|
+
* Darkening by 80% would be represented by a `level` of 0.8
|
|
915
|
+
*
|
|
916
|
+
* # Example
|
|
917
|
+
* ```no_run
|
|
918
|
+
* // For example to darken an image by 10% in the HSLuv colour space:
|
|
919
|
+
* use photon_rs::colour_spaces::darken_hsluv;
|
|
920
|
+
* use photon_rs::native::open_image;
|
|
921
|
+
*
|
|
922
|
+
* // Open the image. A PhotonImage is returned.
|
|
923
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
924
|
+
* darken_hsluv(&mut img, 0.1_f32);
|
|
925
|
+
* ```
|
|
926
|
+
* @param {PhotonImage} img
|
|
927
|
+
* @param {number} level
|
|
928
|
+
*/
|
|
929
|
+
export function darken_hsluv(img, level) {
|
|
930
|
+
_assertClass(img, PhotonImage);
|
|
931
|
+
wasm.darken_hsluv(img.__wbg_ptr, level);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Darken the image's colours by a specified amount in the HSV colour space.
|
|
936
|
+
*
|
|
937
|
+
* # Arguments
|
|
938
|
+
* * `img` - A PhotonImage.
|
|
939
|
+
* * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
|
|
940
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
941
|
+
* Darkening by 80% would be represented by a `level` of 0.8
|
|
942
|
+
*
|
|
943
|
+
* # Example
|
|
944
|
+
* ```no_run
|
|
945
|
+
* // For example to darken an image by 10% in the HSV colour space:
|
|
946
|
+
* use photon_rs::colour_spaces::darken_hsv;
|
|
947
|
+
* use photon_rs::native::open_image;
|
|
948
|
+
*
|
|
949
|
+
* // Open the image. A PhotonImage is returned.
|
|
950
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
951
|
+
* darken_hsv(&mut img, 0.1_f32);
|
|
952
|
+
* ```
|
|
953
|
+
* @param {PhotonImage} img
|
|
954
|
+
* @param {number} level
|
|
955
|
+
*/
|
|
956
|
+
export function darken_hsv(img, level) {
|
|
957
|
+
_assertClass(img, PhotonImage);
|
|
958
|
+
wasm.darken_hsv(img.__wbg_ptr, level);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Darken the image by a specified amount in the LCh colour space.
|
|
963
|
+
*
|
|
964
|
+
* # Arguments
|
|
965
|
+
* * `img` - A PhotonImage.
|
|
966
|
+
* * `level` - Float value from 0 to 1 representing the level to which to darken the image by.
|
|
967
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
968
|
+
* Darkening by 80% would be represented by a `level` of 0.8
|
|
969
|
+
*
|
|
970
|
+
* # Example
|
|
971
|
+
* ```no_run
|
|
972
|
+
* // For example to darken an image by 10% in the LCh colour space:
|
|
973
|
+
* use photon_rs::colour_spaces::darken_lch;
|
|
974
|
+
* use photon_rs::native::open_image;
|
|
975
|
+
*
|
|
976
|
+
* // Open the image. A PhotonImage is returned.
|
|
977
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
978
|
+
* darken_lch(&mut img, 0.1_f32);
|
|
979
|
+
* ```
|
|
980
|
+
* @param {PhotonImage} img
|
|
981
|
+
* @param {number} level
|
|
982
|
+
*/
|
|
983
|
+
export function darken_lch(img, level) {
|
|
984
|
+
_assertClass(img, PhotonImage);
|
|
985
|
+
wasm.darken_lch(img.__wbg_ptr, level);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Decrease the brightness of an image by a constant.
|
|
990
|
+
*
|
|
991
|
+
* # Arguments
|
|
992
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
993
|
+
* * `brightness` - A u8 to subtract from the brightness. It should be a positive number,
|
|
994
|
+
* and this value will then be subtracted from the brightness.
|
|
995
|
+
* # Example
|
|
996
|
+
*
|
|
997
|
+
* ```no_run
|
|
998
|
+
* use photon_rs::effects::dec_brightness;
|
|
999
|
+
* use photon_rs::native::open_image;
|
|
1000
|
+
*
|
|
1001
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1002
|
+
* dec_brightness(&mut img, 10_u8);
|
|
1003
|
+
* ```
|
|
1004
|
+
* @param {PhotonImage} photon_image
|
|
1005
|
+
* @param {number} brightness
|
|
1006
|
+
*/
|
|
1007
|
+
export function dec_brightness(photon_image, brightness) {
|
|
1008
|
+
_assertClass(photon_image, PhotonImage);
|
|
1009
|
+
wasm.dec_brightness(photon_image.__wbg_ptr, brightness);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Uses a max. decomposition algorithm to convert an image to greyscale.
|
|
1014
|
+
*
|
|
1015
|
+
* # Arguments
|
|
1016
|
+
* * `photon_image` - A PhotonImage.
|
|
1017
|
+
*
|
|
1018
|
+
* # Example
|
|
1019
|
+
*
|
|
1020
|
+
* ```no_run
|
|
1021
|
+
* // For example, to decompose an image with max decomposition:
|
|
1022
|
+
* use photon_rs::monochrome::decompose_max;
|
|
1023
|
+
* use photon_rs::native::open_image;
|
|
1024
|
+
*
|
|
1025
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1026
|
+
* decompose_max(&mut img);
|
|
1027
|
+
* ```
|
|
1028
|
+
* @param {PhotonImage} img
|
|
1029
|
+
*/
|
|
1030
|
+
export function decompose_max(img) {
|
|
1031
|
+
_assertClass(img, PhotonImage);
|
|
1032
|
+
wasm.decompose_max(img.__wbg_ptr);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Uses a min. decomposition algorithm to convert an image to greyscale.
|
|
1037
|
+
*
|
|
1038
|
+
* # Arguments
|
|
1039
|
+
* * `photon_image` - A PhotonImage.
|
|
1040
|
+
*
|
|
1041
|
+
* # Example
|
|
1042
|
+
*
|
|
1043
|
+
* ```no_run
|
|
1044
|
+
* // For example, to decompose an image with min decomposition:
|
|
1045
|
+
* use photon_rs::monochrome::decompose_min;
|
|
1046
|
+
* use photon_rs::native::open_image;
|
|
1047
|
+
*
|
|
1048
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1049
|
+
* decompose_min(&mut img);
|
|
1050
|
+
* ```
|
|
1051
|
+
* @param {PhotonImage} img
|
|
1052
|
+
*/
|
|
1053
|
+
export function decompose_min(img) {
|
|
1054
|
+
_assertClass(img, PhotonImage);
|
|
1055
|
+
wasm.decompose_min(img.__wbg_ptr);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Desaturate an image by getting the min/max of each pixel's RGB values.
|
|
1060
|
+
*
|
|
1061
|
+
* # Arguments
|
|
1062
|
+
* * `photon_image` - A PhotonImage.
|
|
1063
|
+
* # Example
|
|
1064
|
+
*
|
|
1065
|
+
* ```no_run
|
|
1066
|
+
* // For example, to desaturate an image:
|
|
1067
|
+
* use photon_rs::monochrome::desaturate;
|
|
1068
|
+
* use photon_rs::native::open_image;
|
|
1069
|
+
*
|
|
1070
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1071
|
+
* desaturate(&mut img);
|
|
1072
|
+
* ```
|
|
1073
|
+
* @param {PhotonImage} img
|
|
1074
|
+
*/
|
|
1075
|
+
export function desaturate(img) {
|
|
1076
|
+
_assertClass(img, PhotonImage);
|
|
1077
|
+
wasm.desaturate(img.__wbg_ptr);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Desaturate the image by a specified amount in the HSL colour space.
|
|
1082
|
+
*
|
|
1083
|
+
* # Arguments
|
|
1084
|
+
* * `img` - A PhotonImage.
|
|
1085
|
+
* * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
|
|
1086
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
1087
|
+
* Desaturating by 80% would be represented by a `level` of 0.8
|
|
1088
|
+
*
|
|
1089
|
+
* # Example
|
|
1090
|
+
* ```no_run
|
|
1091
|
+
* // For example to desaturate an image by 10% in the LCh colour space:
|
|
1092
|
+
* use photon_rs::colour_spaces::desaturate_hsl;
|
|
1093
|
+
* use photon_rs::native::open_image;
|
|
1094
|
+
*
|
|
1095
|
+
* // Open the image. A PhotonImage is returned.
|
|
1096
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1097
|
+
* desaturate_hsl(&mut img, 0.1_f32);
|
|
1098
|
+
* ```
|
|
1099
|
+
* @param {PhotonImage} img
|
|
1100
|
+
* @param {number} level
|
|
1101
|
+
*/
|
|
1102
|
+
export function desaturate_hsl(img, level) {
|
|
1103
|
+
_assertClass(img, PhotonImage);
|
|
1104
|
+
wasm.desaturate_hsl(img.__wbg_ptr, level);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Desaturate the image by a specified amount in the HSLuv colour space.
|
|
1109
|
+
*
|
|
1110
|
+
* # Arguments
|
|
1111
|
+
* * `img` - A PhotonImage.
|
|
1112
|
+
* * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
|
|
1113
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
1114
|
+
* Desaturating by 80% would be represented by a `level` of 0.8
|
|
1115
|
+
*
|
|
1116
|
+
* # Example
|
|
1117
|
+
* ```no_run
|
|
1118
|
+
* // For example to desaturate an image by 10% in the HSLuv colour space:
|
|
1119
|
+
* use photon_rs::colour_spaces::desaturate_hsluv;
|
|
1120
|
+
* use photon_rs::native::open_image;
|
|
1121
|
+
*
|
|
1122
|
+
* // Open the image. A PhotonImage is returned.
|
|
1123
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1124
|
+
* desaturate_hsluv(&mut img, 0.1_f32);
|
|
1125
|
+
* ```
|
|
1126
|
+
* @param {PhotonImage} img
|
|
1127
|
+
* @param {number} level
|
|
1128
|
+
*/
|
|
1129
|
+
export function desaturate_hsluv(img, level) {
|
|
1130
|
+
_assertClass(img, PhotonImage);
|
|
1131
|
+
wasm.desaturate_hsluv(img.__wbg_ptr, level);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Desaturate the image by a specified amount in the HSV colour space.
|
|
1136
|
+
*
|
|
1137
|
+
* # Arguments
|
|
1138
|
+
* * `img` - A PhotonImage.
|
|
1139
|
+
* * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
|
|
1140
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
1141
|
+
* Desaturating by 80% would be represented by a `level` of 0.8
|
|
1142
|
+
*
|
|
1143
|
+
* # Example
|
|
1144
|
+
* ```no_run
|
|
1145
|
+
* // For example to desaturate an image by 10% in the HSV colour space:
|
|
1146
|
+
* use photon_rs::colour_spaces::desaturate_hsv;
|
|
1147
|
+
* use photon_rs::native::open_image;
|
|
1148
|
+
*
|
|
1149
|
+
* // Open the image. A PhotonImage is returned.
|
|
1150
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1151
|
+
* desaturate_hsv(&mut img, 0.1_f32);
|
|
1152
|
+
* ```
|
|
1153
|
+
* @param {PhotonImage} img
|
|
1154
|
+
* @param {number} level
|
|
1155
|
+
*/
|
|
1156
|
+
export function desaturate_hsv(img, level) {
|
|
1157
|
+
_assertClass(img, PhotonImage);
|
|
1158
|
+
wasm.desaturate_hsv(img.__wbg_ptr, level);
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Desaturate the image by a specified amount in the LCh colour space.
|
|
1163
|
+
*
|
|
1164
|
+
* # Arguments
|
|
1165
|
+
* * `img` - A PhotonImage.
|
|
1166
|
+
* * `level` - Float value from 0 to 1 representing the level to which to desaturate the image by.
|
|
1167
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
1168
|
+
* Desaturating by 80% would be represented by a `level` of 0.8
|
|
1169
|
+
*
|
|
1170
|
+
* # Example
|
|
1171
|
+
* ```no_run
|
|
1172
|
+
* // For example to desaturate an image by 10% in the LCh colour space:
|
|
1173
|
+
* use photon_rs::colour_spaces::desaturate_lch;
|
|
1174
|
+
* use photon_rs::native::open_image;
|
|
1175
|
+
*
|
|
1176
|
+
* // Open the image. A PhotonImage is returned.
|
|
1177
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1178
|
+
* desaturate_lch(&mut img, 0.1_f32);
|
|
1179
|
+
* ```
|
|
1180
|
+
* @param {PhotonImage} img
|
|
1181
|
+
* @param {number} level
|
|
1182
|
+
*/
|
|
1183
|
+
export function desaturate_lch(img, level) {
|
|
1184
|
+
_assertClass(img, PhotonImage);
|
|
1185
|
+
wasm.desaturate_lch(img.__wbg_ptr, level);
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Detect lines at a 135 degree angle in an image, and highlight these only.
|
|
1190
|
+
*
|
|
1191
|
+
* # Arguments
|
|
1192
|
+
* * `img` - A PhotonImage.
|
|
1193
|
+
*
|
|
1194
|
+
* # Example
|
|
1195
|
+
*
|
|
1196
|
+
* ```no_run
|
|
1197
|
+
* // For example, to display the lines at a 135 degree angle in an image:
|
|
1198
|
+
* use photon_rs::conv::detect_135_deg_lines;
|
|
1199
|
+
* use photon_rs::native::open_image;
|
|
1200
|
+
*
|
|
1201
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1202
|
+
* detect_135_deg_lines(&mut img);
|
|
1203
|
+
* ```
|
|
1204
|
+
* @param {PhotonImage} photon_image
|
|
1205
|
+
*/
|
|
1206
|
+
export function detect_135_deg_lines(photon_image) {
|
|
1207
|
+
_assertClass(photon_image, PhotonImage);
|
|
1208
|
+
wasm.detect_135_deg_lines(photon_image.__wbg_ptr);
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* Detect lines at a forty five degree angle in an image, and highlight these only.
|
|
1213
|
+
*
|
|
1214
|
+
* # Arguments
|
|
1215
|
+
* * `img` - A PhotonImage.
|
|
1216
|
+
*
|
|
1217
|
+
* # Example
|
|
1218
|
+
*
|
|
1219
|
+
* ```no_run
|
|
1220
|
+
* // For example, to display the lines at a forty five degree angle in an image:
|
|
1221
|
+
* use photon_rs::conv::detect_45_deg_lines;
|
|
1222
|
+
* use photon_rs::native::open_image;
|
|
1223
|
+
*
|
|
1224
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1225
|
+
* detect_45_deg_lines(&mut img);
|
|
1226
|
+
* ```
|
|
1227
|
+
* @param {PhotonImage} photon_image
|
|
1228
|
+
*/
|
|
1229
|
+
export function detect_45_deg_lines(photon_image) {
|
|
1230
|
+
_assertClass(photon_image, PhotonImage);
|
|
1231
|
+
wasm.detect_45_deg_lines(photon_image.__wbg_ptr);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
/**
|
|
1235
|
+
* Detect horizontal lines in an image, and highlight these only.
|
|
1236
|
+
*
|
|
1237
|
+
* # Arguments
|
|
1238
|
+
* * `img` - A PhotonImage.
|
|
1239
|
+
*
|
|
1240
|
+
* # Example
|
|
1241
|
+
*
|
|
1242
|
+
* ```no_run
|
|
1243
|
+
* // For example, to display the horizontal lines in an image:
|
|
1244
|
+
* use photon_rs::conv::detect_horizontal_lines;
|
|
1245
|
+
* use photon_rs::native::open_image;
|
|
1246
|
+
*
|
|
1247
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1248
|
+
* detect_horizontal_lines(&mut img);
|
|
1249
|
+
* ```
|
|
1250
|
+
* @param {PhotonImage} photon_image
|
|
1251
|
+
*/
|
|
1252
|
+
export function detect_horizontal_lines(photon_image) {
|
|
1253
|
+
_assertClass(photon_image, PhotonImage);
|
|
1254
|
+
wasm.detect_horizontal_lines(photon_image.__wbg_ptr);
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* Detect vertical lines in an image, and highlight these only.
|
|
1259
|
+
*
|
|
1260
|
+
* # Arguments
|
|
1261
|
+
* * `img` - A PhotonImage.
|
|
1262
|
+
*
|
|
1263
|
+
* # Example
|
|
1264
|
+
*
|
|
1265
|
+
* ```no_run
|
|
1266
|
+
* // For example, to display the vertical lines in an image:
|
|
1267
|
+
* use photon_rs::conv::detect_vertical_lines;
|
|
1268
|
+
* use photon_rs::native::open_image;
|
|
1269
|
+
*
|
|
1270
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1271
|
+
* detect_vertical_lines(&mut img);
|
|
1272
|
+
* ```
|
|
1273
|
+
* @param {PhotonImage} photon_image
|
|
1274
|
+
*/
|
|
1275
|
+
export function detect_vertical_lines(photon_image) {
|
|
1276
|
+
_assertClass(photon_image, PhotonImage);
|
|
1277
|
+
wasm.detect_vertical_lines(photon_image.__wbg_ptr);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Applies Floyd-Steinberg dithering to an image.
|
|
1282
|
+
* Only RGB channels are processed, alpha remains unchanged.
|
|
1283
|
+
* # Arguments
|
|
1284
|
+
* * `photon_image` - A PhotonImage that contains a view into the image.
|
|
1285
|
+
* * `depth` - bits per channel. Clamped between 1 and 8.
|
|
1286
|
+
* # Example
|
|
1287
|
+
*
|
|
1288
|
+
* ```no_run
|
|
1289
|
+
* // For example, to turn an image of type `PhotonImage` into a dithered image:
|
|
1290
|
+
* use photon_rs::effects::dither;
|
|
1291
|
+
* use photon_rs::native::open_image;
|
|
1292
|
+
*
|
|
1293
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1294
|
+
* let depth = 1;
|
|
1295
|
+
* dither(&mut img, depth);
|
|
1296
|
+
* ```
|
|
1297
|
+
* @param {PhotonImage} photon_image
|
|
1298
|
+
* @param {number} depth
|
|
1299
|
+
*/
|
|
1300
|
+
export function dither(photon_image, depth) {
|
|
1301
|
+
_assertClass(photon_image, PhotonImage);
|
|
1302
|
+
wasm.dither(photon_image.__wbg_ptr, depth);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
/**
|
|
1306
|
+
* Greyscale effect with increased contrast.
|
|
1307
|
+
*
|
|
1308
|
+
* # Arguments
|
|
1309
|
+
* * `img` - A PhotonImage.
|
|
1310
|
+
* # Example
|
|
1311
|
+
*
|
|
1312
|
+
* ```no_run
|
|
1313
|
+
* use photon_rs::filters::dramatic;
|
|
1314
|
+
* use photon_rs::native::open_image;
|
|
1315
|
+
*
|
|
1316
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1317
|
+
* dramatic(&mut img);
|
|
1318
|
+
* ```
|
|
1319
|
+
* @param {PhotonImage} img
|
|
1320
|
+
*/
|
|
1321
|
+
export function dramatic(img) {
|
|
1322
|
+
_assertClass(img, PhotonImage);
|
|
1323
|
+
wasm.dramatic(img.__wbg_ptr);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Add text to an image.
|
|
1328
|
+
* The only font available as of now is Roboto.
|
|
1329
|
+
* Note: A graphic design/text-drawing library is currently being developed, so stay tuned.
|
|
1330
|
+
*
|
|
1331
|
+
* # Arguments
|
|
1332
|
+
* * `photon_image` - A PhotonImage.
|
|
1333
|
+
* * `text` - Text string to be drawn to the image.
|
|
1334
|
+
* * `x` - x-coordinate of where first letter's 1st pixel should be drawn.
|
|
1335
|
+
* * `y` - y-coordinate of where first letter's 1st pixel should be drawn.
|
|
1336
|
+
* * `font_size` - Font size in pixels of the text to be drawn.
|
|
1337
|
+
*
|
|
1338
|
+
* # Example
|
|
1339
|
+
*
|
|
1340
|
+
* ```no_run
|
|
1341
|
+
* // For example to draw the string "Welcome to Photon!" at 10, 10:
|
|
1342
|
+
* use photon_rs::native::open_image;
|
|
1343
|
+
* use photon_rs::text::draw_text;
|
|
1344
|
+
*
|
|
1345
|
+
* // Open the image. A PhotonImage is returned.
|
|
1346
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1347
|
+
* draw_text(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32);
|
|
1348
|
+
* ```
|
|
1349
|
+
* @param {PhotonImage} photon_img
|
|
1350
|
+
* @param {string} text
|
|
1351
|
+
* @param {number} x
|
|
1352
|
+
* @param {number} y
|
|
1353
|
+
* @param {number} font_size
|
|
1354
|
+
*/
|
|
1355
|
+
export function draw_text(photon_img, text, x, y, font_size) {
|
|
1356
|
+
_assertClass(photon_img, PhotonImage);
|
|
1357
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1358
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1359
|
+
wasm.draw_text(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Add bordered-text to an image.
|
|
1364
|
+
* The only font available as of now is Roboto.
|
|
1365
|
+
* Note: A graphic design/text-drawing library is currently being developed, so stay tuned.
|
|
1366
|
+
*
|
|
1367
|
+
* # Arguments
|
|
1368
|
+
* * `photon_image` - A PhotonImage.
|
|
1369
|
+
* * `text` - Text string to be drawn to the image.
|
|
1370
|
+
* * `x` - x-coordinate of where first letter's 1st pixel should be drawn.
|
|
1371
|
+
* * `y` - y-coordinate of where first letter's 1st pixel should be drawn.
|
|
1372
|
+
* * `font_size` - Font size in pixels of the text to be drawn.
|
|
1373
|
+
*
|
|
1374
|
+
* # Example
|
|
1375
|
+
*
|
|
1376
|
+
* ```no_run
|
|
1377
|
+
* // For example to draw the string "Welcome to Photon!" at 10, 10:
|
|
1378
|
+
* use photon_rs::native::open_image;
|
|
1379
|
+
* use photon_rs::text::draw_text_with_border;
|
|
1380
|
+
*
|
|
1381
|
+
* // Open the image. A PhotonImage is returned.
|
|
1382
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1383
|
+
* draw_text_with_border(&mut img, "Welcome to Photon!", 10_i32, 10_i32, 90_f32);
|
|
1384
|
+
* ```
|
|
1385
|
+
* @param {PhotonImage} photon_img
|
|
1386
|
+
* @param {string} text
|
|
1387
|
+
* @param {number} x
|
|
1388
|
+
* @param {number} y
|
|
1389
|
+
* @param {number} font_size
|
|
1390
|
+
*/
|
|
1391
|
+
export function draw_text_with_border(photon_img, text, x, y, font_size) {
|
|
1392
|
+
_assertClass(photon_img, PhotonImage);
|
|
1393
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1394
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1395
|
+
wasm.draw_text_with_border(photon_img.__wbg_ptr, ptr0, len0, x, y, font_size);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* @param {PhotonImage} photon_image
|
|
1400
|
+
* @param {Rgb} color_a
|
|
1401
|
+
* @param {Rgb} color_b
|
|
1402
|
+
*/
|
|
1403
|
+
export function duotone(photon_image, color_a, color_b) {
|
|
1404
|
+
_assertClass(photon_image, PhotonImage);
|
|
1405
|
+
_assertClass(color_a, Rgb);
|
|
1406
|
+
var ptr0 = color_a.__destroy_into_raw();
|
|
1407
|
+
_assertClass(color_b, Rgb);
|
|
1408
|
+
var ptr1 = color_b.__destroy_into_raw();
|
|
1409
|
+
wasm.duotone(photon_image.__wbg_ptr, ptr0, ptr1);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Duotone effect with purple tones.
|
|
1414
|
+
*
|
|
1415
|
+
* # Arguments
|
|
1416
|
+
* * `img` - A PhotonImage.
|
|
1417
|
+
* # Example
|
|
1418
|
+
*
|
|
1419
|
+
* ```no_run
|
|
1420
|
+
* use photon_rs::filters::duotone_horizon;
|
|
1421
|
+
* use photon_rs::native::open_image;
|
|
1422
|
+
*
|
|
1423
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1424
|
+
* duotone_horizon(&mut img);
|
|
1425
|
+
* ```
|
|
1426
|
+
* @param {PhotonImage} img
|
|
1427
|
+
*/
|
|
1428
|
+
export function duotone_horizon(img) {
|
|
1429
|
+
_assertClass(img, PhotonImage);
|
|
1430
|
+
wasm.duotone_horizon(img.__wbg_ptr);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Duotone effect with a lilac hue
|
|
1435
|
+
*
|
|
1436
|
+
* # Arguments
|
|
1437
|
+
* * `img` - A PhotonImage.
|
|
1438
|
+
* # Example
|
|
1439
|
+
*
|
|
1440
|
+
* ```no_run
|
|
1441
|
+
* use photon_rs::filters::duotone_lilac;
|
|
1442
|
+
* use photon_rs::native::open_image;
|
|
1443
|
+
*
|
|
1444
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1445
|
+
* duotone_lilac(&mut img);
|
|
1446
|
+
* ```
|
|
1447
|
+
* @param {PhotonImage} img
|
|
1448
|
+
*/
|
|
1449
|
+
export function duotone_lilac(img) {
|
|
1450
|
+
_assertClass(img, PhotonImage);
|
|
1451
|
+
wasm.duotone_lilac(img.__wbg_ptr);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
/**
|
|
1455
|
+
* A duotone ochre tint effect
|
|
1456
|
+
*
|
|
1457
|
+
* # Arguments
|
|
1458
|
+
* * `img` - A PhotonImage.
|
|
1459
|
+
* # Example
|
|
1460
|
+
*
|
|
1461
|
+
* ```no_run
|
|
1462
|
+
* use photon_rs::filters::duotone_ochre;
|
|
1463
|
+
* use photon_rs::native::open_image;
|
|
1464
|
+
*
|
|
1465
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1466
|
+
* duotone_ochre(&mut img);
|
|
1467
|
+
* ```
|
|
1468
|
+
* @param {PhotonImage} img
|
|
1469
|
+
*/
|
|
1470
|
+
export function duotone_ochre(img) {
|
|
1471
|
+
_assertClass(img, PhotonImage);
|
|
1472
|
+
wasm.duotone_ochre(img.__wbg_ptr);
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* A duotone filter with a user-specified color and a gray color
|
|
1477
|
+
*
|
|
1478
|
+
* # Arguments
|
|
1479
|
+
* * `img` - A PhotonImage.
|
|
1480
|
+
* * `rgb_color` - RGB color
|
|
1481
|
+
* # Example
|
|
1482
|
+
*
|
|
1483
|
+
* ```no_run
|
|
1484
|
+
* use photon_rs::filters::duotone_tint;
|
|
1485
|
+
* use photon_rs::native::open_image;
|
|
1486
|
+
* use photon_rs::Rgb;
|
|
1487
|
+
*
|
|
1488
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1489
|
+
* let rgb_color = Rgb::new(12, 12, 10);
|
|
1490
|
+
* duotone_tint(&mut img, rgb_color);
|
|
1491
|
+
* ```
|
|
1492
|
+
* @param {PhotonImage} img
|
|
1493
|
+
* @param {Rgb} rgb_color
|
|
1494
|
+
*/
|
|
1495
|
+
export function duotone_tint(img, rgb_color) {
|
|
1496
|
+
_assertClass(img, PhotonImage);
|
|
1497
|
+
_assertClass(rgb_color, Rgb);
|
|
1498
|
+
var ptr0 = rgb_color.__destroy_into_raw();
|
|
1499
|
+
wasm.duotone_tint(img.__wbg_ptr, ptr0);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Duotone effect with blue and purple tones.
|
|
1504
|
+
*
|
|
1505
|
+
* # Arguments
|
|
1506
|
+
* * `img` - A PhotonImage.
|
|
1507
|
+
* # Example
|
|
1508
|
+
*
|
|
1509
|
+
* ```no_run
|
|
1510
|
+
* use photon_rs::filters::duotone_violette;
|
|
1511
|
+
* use photon_rs::native::open_image;
|
|
1512
|
+
*
|
|
1513
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1514
|
+
* duotone_violette(&mut img);
|
|
1515
|
+
* ```
|
|
1516
|
+
* @param {PhotonImage} img
|
|
1517
|
+
*/
|
|
1518
|
+
export function duotone_violette(img) {
|
|
1519
|
+
_assertClass(img, PhotonImage);
|
|
1520
|
+
wasm.duotone_violette(img.__wbg_ptr);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* Apply edge detection to an image, to create a dark version with its edges highlighted.
|
|
1525
|
+
*
|
|
1526
|
+
* # Arguments
|
|
1527
|
+
* * `img` - A PhotonImage.
|
|
1528
|
+
*
|
|
1529
|
+
* # Example
|
|
1530
|
+
*
|
|
1531
|
+
* ```no_run
|
|
1532
|
+
* // For example, to increase the Red channel for all pixels by 10:
|
|
1533
|
+
* use photon_rs::conv::edge_detection;
|
|
1534
|
+
* use photon_rs::native::open_image;
|
|
1535
|
+
*
|
|
1536
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1537
|
+
* edge_detection(&mut img);
|
|
1538
|
+
* ```
|
|
1539
|
+
* @param {PhotonImage} photon_image
|
|
1540
|
+
*/
|
|
1541
|
+
export function edge_detection(photon_image) {
|
|
1542
|
+
_assertClass(photon_image, PhotonImage);
|
|
1543
|
+
wasm.edge_detection(photon_image.__wbg_ptr);
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* Preset edge effect.
|
|
1548
|
+
*
|
|
1549
|
+
* # Arguments
|
|
1550
|
+
* * `img` - A PhotonImage.
|
|
1551
|
+
*
|
|
1552
|
+
* # Example
|
|
1553
|
+
*
|
|
1554
|
+
* ```no_run
|
|
1555
|
+
* // For example, to apply this effect:
|
|
1556
|
+
* use photon_rs::conv::edge_one;
|
|
1557
|
+
* use photon_rs::native::open_image;
|
|
1558
|
+
*
|
|
1559
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1560
|
+
* edge_one(&mut img);
|
|
1561
|
+
* ```
|
|
1562
|
+
* @param {PhotonImage} photon_image
|
|
1563
|
+
*/
|
|
1564
|
+
export function edge_one(photon_image) {
|
|
1565
|
+
_assertClass(photon_image, PhotonImage);
|
|
1566
|
+
wasm.edge_one(photon_image.__wbg_ptr);
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Apply an emboss effect to an image.
|
|
1571
|
+
*
|
|
1572
|
+
* # Arguments
|
|
1573
|
+
* * `img` - A PhotonImage.
|
|
1574
|
+
*
|
|
1575
|
+
* # Example
|
|
1576
|
+
*
|
|
1577
|
+
* ```no_run
|
|
1578
|
+
* // For example, to apply an emboss effect:
|
|
1579
|
+
* use photon_rs::conv::emboss;
|
|
1580
|
+
* use photon_rs::native::open_image;
|
|
1581
|
+
*
|
|
1582
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1583
|
+
* emboss(&mut img);
|
|
1584
|
+
* ```
|
|
1585
|
+
* @param {PhotonImage} photon_image
|
|
1586
|
+
*/
|
|
1587
|
+
export function emboss(photon_image) {
|
|
1588
|
+
_assertClass(photon_image, PhotonImage);
|
|
1589
|
+
wasm.emboss(photon_image.__wbg_ptr);
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* Apply a filter to an image. Over 20 filters are available.
|
|
1594
|
+
* The filters are as follows:
|
|
1595
|
+
* * **oceanic**: Add an aquamarine-tinted hue to an image.
|
|
1596
|
+
* * **islands**: Aquamarine tint.
|
|
1597
|
+
* * **marine**: Add a green/blue mixed hue to an image.
|
|
1598
|
+
* * **seagreen**: Dark green hue, with tones of blue.
|
|
1599
|
+
* * **flagblue**: Royal blue tint
|
|
1600
|
+
* * **liquid**: Blue-inspired tint.
|
|
1601
|
+
* * **diamante**: Custom filter with a blue/turquoise tint.
|
|
1602
|
+
* * **radio**: Fallout-style radio effect.
|
|
1603
|
+
* * **twenties**: Slight-blue tinted historical effect.
|
|
1604
|
+
* * **rosetint**: Rose-tinted filter.
|
|
1605
|
+
* * **mauve**: Purple-infused filter.
|
|
1606
|
+
* * **bluechrome**: Blue monochrome effect.
|
|
1607
|
+
* * **vintage**: Vintage filter with a red tint.
|
|
1608
|
+
* * **perfume**: Increase the blue channel, with moderate increases in the Red and Green channels.
|
|
1609
|
+
* * **serenity**: Custom filter with an increase in the Blue channel's values.
|
|
1610
|
+
* # Arguments
|
|
1611
|
+
* * `img` - A PhotonImage.
|
|
1612
|
+
* * `filter_name` - The filter's name. Choose from the selection above, eg: "oceanic"
|
|
1613
|
+
* # Example
|
|
1614
|
+
*
|
|
1615
|
+
* ```no_run
|
|
1616
|
+
* // For example, to add a filter called "vintage" to an image:
|
|
1617
|
+
* use photon_rs::filters::filter;
|
|
1618
|
+
* use photon_rs::native::open_image;
|
|
1619
|
+
*
|
|
1620
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1621
|
+
* filter(&mut img, "vintage");
|
|
1622
|
+
* ```
|
|
1623
|
+
* @param {PhotonImage} img
|
|
1624
|
+
* @param {string} filter_name
|
|
1625
|
+
*/
|
|
1626
|
+
export function filter(img, filter_name) {
|
|
1627
|
+
_assertClass(img, PhotonImage);
|
|
1628
|
+
const ptr0 = passStringToWasm0(filter_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1629
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1630
|
+
wasm.filter(img.__wbg_ptr, ptr0, len0);
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Apply a red hue, with increased contrast and brightness.
|
|
1635
|
+
*
|
|
1636
|
+
* # Arguments
|
|
1637
|
+
* * `img` - A PhotonImage.
|
|
1638
|
+
* # Example
|
|
1639
|
+
*
|
|
1640
|
+
* ```no_run
|
|
1641
|
+
* use photon_rs::filters::firenze;
|
|
1642
|
+
* use photon_rs::native::open_image;
|
|
1643
|
+
*
|
|
1644
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1645
|
+
* firenze(&mut img);
|
|
1646
|
+
* ```
|
|
1647
|
+
* @param {PhotonImage} img
|
|
1648
|
+
*/
|
|
1649
|
+
export function firenze(img) {
|
|
1650
|
+
_assertClass(img, PhotonImage);
|
|
1651
|
+
wasm.firenze(img.__wbg_ptr);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
/**
|
|
1655
|
+
* Flip an image horizontally.
|
|
1656
|
+
*
|
|
1657
|
+
* # Arguments
|
|
1658
|
+
* * `img` - A PhotonImage.
|
|
1659
|
+
*
|
|
1660
|
+
* # Example
|
|
1661
|
+
*
|
|
1662
|
+
* ```no_run
|
|
1663
|
+
* // For example, to flip an image horizontally:
|
|
1664
|
+
* use photon_rs::native::open_image;
|
|
1665
|
+
* use photon_rs::transform::fliph;
|
|
1666
|
+
*
|
|
1667
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1668
|
+
* fliph(&mut img);
|
|
1669
|
+
* ```
|
|
1670
|
+
* @param {PhotonImage} photon_image
|
|
1671
|
+
*/
|
|
1672
|
+
export function fliph(photon_image) {
|
|
1673
|
+
_assertClass(photon_image, PhotonImage);
|
|
1674
|
+
wasm.fliph(photon_image.__wbg_ptr);
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
/**
|
|
1678
|
+
* Flip an image vertically.
|
|
1679
|
+
*
|
|
1680
|
+
* # Arguments
|
|
1681
|
+
* * `img` - A PhotonImage.
|
|
1682
|
+
*
|
|
1683
|
+
* # Example
|
|
1684
|
+
*
|
|
1685
|
+
* ```no_run
|
|
1686
|
+
* // For example, to flip an image vertically:
|
|
1687
|
+
* use photon_rs::native::open_image;
|
|
1688
|
+
* use photon_rs::transform::flipv;
|
|
1689
|
+
*
|
|
1690
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1691
|
+
* flipv(&mut img);
|
|
1692
|
+
* ```
|
|
1693
|
+
* @param {PhotonImage} photon_image
|
|
1694
|
+
*/
|
|
1695
|
+
export function flipv(photon_image) {
|
|
1696
|
+
_assertClass(photon_image, PhotonImage);
|
|
1697
|
+
wasm.flipv(photon_image.__wbg_ptr);
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* Turn an image into an frosted glass see through
|
|
1702
|
+
*
|
|
1703
|
+
* # Arguments
|
|
1704
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
1705
|
+
* # Example
|
|
1706
|
+
*
|
|
1707
|
+
* ```no_run
|
|
1708
|
+
* // For example, to turn an image of type `PhotonImage` into frosted glass see through:
|
|
1709
|
+
* use photon_rs::effects::frosted_glass;
|
|
1710
|
+
* use photon_rs::native::open_image;
|
|
1711
|
+
*
|
|
1712
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1713
|
+
* frosted_glass(&mut img);
|
|
1714
|
+
* ```
|
|
1715
|
+
* @param {PhotonImage} photon_image
|
|
1716
|
+
*/
|
|
1717
|
+
export function frosted_glass(photon_image) {
|
|
1718
|
+
_assertClass(photon_image, PhotonImage);
|
|
1719
|
+
wasm.frosted_glass(photon_image.__wbg_ptr);
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Convert an image to grayscale by setting a pixel's 3 RGB values to the Green channel's value.
|
|
1724
|
+
*
|
|
1725
|
+
* # Arguments
|
|
1726
|
+
* * `photon_image` - A PhotonImage.
|
|
1727
|
+
*
|
|
1728
|
+
* # Example
|
|
1729
|
+
*
|
|
1730
|
+
* ```no_run
|
|
1731
|
+
* use photon_rs::monochrome::g_grayscale;
|
|
1732
|
+
* use photon_rs::native::open_image;
|
|
1733
|
+
*
|
|
1734
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1735
|
+
* g_grayscale(&mut img);
|
|
1736
|
+
* ```
|
|
1737
|
+
* @param {PhotonImage} photon_image
|
|
1738
|
+
*/
|
|
1739
|
+
export function g_grayscale(photon_image) {
|
|
1740
|
+
_assertClass(photon_image, PhotonImage);
|
|
1741
|
+
wasm.g_grayscale(photon_image.__wbg_ptr);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* Applies gamma correction to an image.
|
|
1746
|
+
* # Arguments
|
|
1747
|
+
* * `photon_image` - A PhotonImage that contains a view into the image.
|
|
1748
|
+
* * `red` - Gamma value for red channel.
|
|
1749
|
+
* * `green` - Gamma value for green channel.
|
|
1750
|
+
* * `blue` - Gamma value for blue channel.
|
|
1751
|
+
* # Example
|
|
1752
|
+
*
|
|
1753
|
+
* ```no_run
|
|
1754
|
+
* // For example, to turn an image of type `PhotonImage` into a gamma corrected image:
|
|
1755
|
+
* use photon_rs::colour_spaces::gamma_correction;
|
|
1756
|
+
* use photon_rs::native::open_image;
|
|
1757
|
+
*
|
|
1758
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1759
|
+
* gamma_correction(&mut img, 2.2, 2.2, 2.2);
|
|
1760
|
+
* ```
|
|
1761
|
+
* @param {PhotonImage} photon_image
|
|
1762
|
+
* @param {number} red
|
|
1763
|
+
* @param {number} green
|
|
1764
|
+
* @param {number} blue
|
|
1765
|
+
*/
|
|
1766
|
+
export function gamma_correction(photon_image, red, green, blue) {
|
|
1767
|
+
_assertClass(photon_image, PhotonImage);
|
|
1768
|
+
wasm.gamma_correction(photon_image.__wbg_ptr, red, green, blue);
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* Gaussian blur in linear time.
|
|
1773
|
+
*
|
|
1774
|
+
* Reference: http://blog.ivank.net/fastest-gaussian-blur.html
|
|
1775
|
+
*
|
|
1776
|
+
* # Arguments
|
|
1777
|
+
* * `photon_image` - A PhotonImage
|
|
1778
|
+
* * `radius` - blur radius
|
|
1779
|
+
* # Example
|
|
1780
|
+
*
|
|
1781
|
+
* ```no_run
|
|
1782
|
+
* use photon_rs::conv::gaussian_blur;
|
|
1783
|
+
* use photon_rs::native::open_image;
|
|
1784
|
+
*
|
|
1785
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1786
|
+
* gaussian_blur(&mut img, 3_i32);
|
|
1787
|
+
* ```
|
|
1788
|
+
* @param {PhotonImage} photon_image
|
|
1789
|
+
* @param {number} radius
|
|
1790
|
+
*/
|
|
1791
|
+
export function gaussian_blur(photon_image, radius) {
|
|
1792
|
+
_assertClass(photon_image, PhotonImage);
|
|
1793
|
+
wasm.gaussian_blur(photon_image.__wbg_ptr, radius);
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* Get the ImageData from a 2D canvas context
|
|
1798
|
+
* @param {HTMLCanvasElement} canvas
|
|
1799
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
1800
|
+
* @returns {ImageData}
|
|
1801
|
+
*/
|
|
1802
|
+
export function get_image_data(canvas, ctx) {
|
|
1803
|
+
const ret = wasm.get_image_data(canvas, ctx);
|
|
1804
|
+
return ret;
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
/**
|
|
1808
|
+
* Apply a vintage, golden hue to an image.
|
|
1809
|
+
*
|
|
1810
|
+
* # Arguments
|
|
1811
|
+
* * `img` - A PhotonImage.
|
|
1812
|
+
* # Example
|
|
1813
|
+
*
|
|
1814
|
+
* ```no_run
|
|
1815
|
+
* use photon_rs::filters::golden;
|
|
1816
|
+
* use photon_rs::native::open_image;
|
|
1817
|
+
*
|
|
1818
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1819
|
+
* golden(&mut img);
|
|
1820
|
+
* ```
|
|
1821
|
+
* @param {PhotonImage} img
|
|
1822
|
+
*/
|
|
1823
|
+
export function golden(img) {
|
|
1824
|
+
_assertClass(img, PhotonImage);
|
|
1825
|
+
wasm.golden(img.__wbg_ptr);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
/**
|
|
1829
|
+
* Convert an image to grayscale using the conventional averaging algorithm.
|
|
1830
|
+
*
|
|
1831
|
+
* # Arguments
|
|
1832
|
+
* * `photon_image` - A PhotonImage.
|
|
1833
|
+
* # Example
|
|
1834
|
+
*
|
|
1835
|
+
* ```no_run
|
|
1836
|
+
* // For example, to convert an image of type `PhotonImage` to grayscale:
|
|
1837
|
+
* use photon_rs::monochrome::grayscale;
|
|
1838
|
+
* use photon_rs::native::open_image;
|
|
1839
|
+
*
|
|
1840
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1841
|
+
* grayscale(&mut img);
|
|
1842
|
+
* ```
|
|
1843
|
+
* @param {PhotonImage} img
|
|
1844
|
+
*/
|
|
1845
|
+
export function grayscale(img) {
|
|
1846
|
+
_assertClass(img, PhotonImage);
|
|
1847
|
+
wasm.grayscale(img.__wbg_ptr);
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
/**
|
|
1851
|
+
* Convert an image to grayscale with a human corrected factor, to account for human vision.
|
|
1852
|
+
*
|
|
1853
|
+
* # Arguments
|
|
1854
|
+
* * `photon_image` - A PhotonImage.
|
|
1855
|
+
* # Example
|
|
1856
|
+
*
|
|
1857
|
+
* ```no_run
|
|
1858
|
+
* // For example, to convert an image of type `PhotonImage` to grayscale with a human corrected factor:
|
|
1859
|
+
* use photon_rs::monochrome::grayscale_human_corrected;
|
|
1860
|
+
* use photon_rs::native::open_image;
|
|
1861
|
+
*
|
|
1862
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1863
|
+
* grayscale_human_corrected(&mut img);
|
|
1864
|
+
* ```
|
|
1865
|
+
* @param {PhotonImage} img
|
|
1866
|
+
*/
|
|
1867
|
+
export function grayscale_human_corrected(img) {
|
|
1868
|
+
_assertClass(img, PhotonImage);
|
|
1869
|
+
wasm.grayscale_human_corrected(img.__wbg_ptr);
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
/**
|
|
1873
|
+
* Employ only a limited number of gray shades in an image.
|
|
1874
|
+
*
|
|
1875
|
+
* # Arguments
|
|
1876
|
+
* * `photon_image` - A PhotonImage.
|
|
1877
|
+
* * `num_shades` - The number of grayscale shades to be displayed in the image.
|
|
1878
|
+
*
|
|
1879
|
+
* # Example
|
|
1880
|
+
*
|
|
1881
|
+
* ```no_run
|
|
1882
|
+
* // For example, to limit an image to four shades of gray only:
|
|
1883
|
+
* use photon_rs::monochrome::grayscale_shades;
|
|
1884
|
+
* use photon_rs::native::open_image;
|
|
1885
|
+
*
|
|
1886
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1887
|
+
* grayscale_shades(&mut img, 4_u8);
|
|
1888
|
+
* ```
|
|
1889
|
+
* @param {PhotonImage} photon_image
|
|
1890
|
+
* @param {number} num_shades
|
|
1891
|
+
*/
|
|
1892
|
+
export function grayscale_shades(photon_image, num_shades) {
|
|
1893
|
+
_assertClass(photon_image, PhotonImage);
|
|
1894
|
+
wasm.grayscale_shades(photon_image.__wbg_ptr, num_shades);
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* Halftoning effect.
|
|
1899
|
+
*
|
|
1900
|
+
* # Arguments
|
|
1901
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
1902
|
+
* # Example
|
|
1903
|
+
*
|
|
1904
|
+
* ```no_run
|
|
1905
|
+
* // For example:
|
|
1906
|
+
* use photon_rs::effects::halftone;
|
|
1907
|
+
* use photon_rs::native::open_image;
|
|
1908
|
+
*
|
|
1909
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1910
|
+
* halftone(&mut img);
|
|
1911
|
+
* ```
|
|
1912
|
+
* @param {PhotonImage} photon_image
|
|
1913
|
+
*/
|
|
1914
|
+
export function halftone(photon_image) {
|
|
1915
|
+
_assertClass(photon_image, PhotonImage);
|
|
1916
|
+
wasm.halftone(photon_image.__wbg_ptr);
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Horizontal strips. Divide an image into a series of equal-height strips, for an artistic effect.
|
|
1921
|
+
*
|
|
1922
|
+
* # Arguments
|
|
1923
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
1924
|
+
* * `num_strips` - The number of strips
|
|
1925
|
+
* # Example
|
|
1926
|
+
*
|
|
1927
|
+
* ```no_run
|
|
1928
|
+
* // For example, to draw horizontal strips on a `PhotonImage`:
|
|
1929
|
+
* use photon_rs::effects::horizontal_strips;
|
|
1930
|
+
* use photon_rs::native::open_image;
|
|
1931
|
+
*
|
|
1932
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1933
|
+
* horizontal_strips(&mut img, 8u8);
|
|
1934
|
+
* ```
|
|
1935
|
+
* @param {PhotonImage} photon_image
|
|
1936
|
+
* @param {number} num_strips
|
|
1937
|
+
*/
|
|
1938
|
+
export function horizontal_strips(photon_image, num_strips) {
|
|
1939
|
+
_assertClass(photon_image, PhotonImage);
|
|
1940
|
+
wasm.horizontal_strips(photon_image.__wbg_ptr, num_strips);
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
/**
|
|
1944
|
+
* Image manipulation effects in the HSL colour space.
|
|
1945
|
+
*
|
|
1946
|
+
* Effects include:
|
|
1947
|
+
* * **saturate** - Saturation increase.
|
|
1948
|
+
* * **desaturate** - Desaturate the image.
|
|
1949
|
+
* * **shift_hue** - Hue rotation by a specified number of degrees.
|
|
1950
|
+
* * **darken** - Decrease the brightness.
|
|
1951
|
+
* * **lighten** - Increase the brightness.
|
|
1952
|
+
*
|
|
1953
|
+
* # Arguments
|
|
1954
|
+
* * `photon_image` - A PhotonImage.
|
|
1955
|
+
* * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
|
|
1956
|
+
* * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
|
|
1957
|
+
* # Example
|
|
1958
|
+
* ```no_run
|
|
1959
|
+
* // For example to increase the saturation by 10%:
|
|
1960
|
+
* use photon_rs::colour_spaces::hsl;
|
|
1961
|
+
* use photon_rs::native::open_image;
|
|
1962
|
+
*
|
|
1963
|
+
* // Open the image. A PhotonImage is returned.
|
|
1964
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
1965
|
+
* hsl(&mut img, "saturate", 0.1_f32);
|
|
1966
|
+
* ```
|
|
1967
|
+
* @param {PhotonImage} photon_image
|
|
1968
|
+
* @param {string} mode
|
|
1969
|
+
* @param {number} amt
|
|
1970
|
+
*/
|
|
1971
|
+
export function hsl(photon_image, mode, amt) {
|
|
1972
|
+
_assertClass(photon_image, PhotonImage);
|
|
1973
|
+
const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1974
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1975
|
+
wasm.hsl(photon_image.__wbg_ptr, ptr0, len0, amt);
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Image manipulation effects in the HSLuv colour space
|
|
1980
|
+
*
|
|
1981
|
+
* Effects include:
|
|
1982
|
+
* * **saturate** - Saturation increase.
|
|
1983
|
+
* * **desaturate** - Desaturate the image.
|
|
1984
|
+
* * **shift_hue** - Hue rotation by a specified number of degrees.
|
|
1985
|
+
* * **darken** - Decrease the brightness.
|
|
1986
|
+
* * **lighten** - Increase the brightness.
|
|
1987
|
+
*
|
|
1988
|
+
* # Arguments
|
|
1989
|
+
* * `photon_image` - A PhotonImage.
|
|
1990
|
+
* * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
|
|
1991
|
+
* * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
|
|
1992
|
+
* # Example
|
|
1993
|
+
* ```no_run
|
|
1994
|
+
* // For example to increase the saturation by 10%:
|
|
1995
|
+
* use photon_rs::colour_spaces::hsluv;
|
|
1996
|
+
* use photon_rs::native::open_image;
|
|
1997
|
+
*
|
|
1998
|
+
* // Open the image. A PhotonImage is returned.
|
|
1999
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2000
|
+
* hsluv(&mut img, "saturate", 0.1_f32);
|
|
2001
|
+
* ```
|
|
2002
|
+
* @param {PhotonImage} photon_image
|
|
2003
|
+
* @param {string} mode
|
|
2004
|
+
* @param {number} amt
|
|
2005
|
+
*/
|
|
2006
|
+
export function hsluv(photon_image, mode, amt) {
|
|
2007
|
+
_assertClass(photon_image, PhotonImage);
|
|
2008
|
+
const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2009
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2010
|
+
wasm.hsluv(photon_image.__wbg_ptr, ptr0, len0, amt);
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* Image manipulation in the HSV colour space.
|
|
2015
|
+
*
|
|
2016
|
+
* Effects include:
|
|
2017
|
+
* * **saturate** - Saturation increase.
|
|
2018
|
+
* * **desaturate** - Desaturate the image.
|
|
2019
|
+
* * **shift_hue** - Hue rotation by a specified number of degrees.
|
|
2020
|
+
* * **darken** - Decrease the brightness.
|
|
2021
|
+
* * **lighten** - Increase the brightness.
|
|
2022
|
+
*
|
|
2023
|
+
* # Arguments
|
|
2024
|
+
* * `photon_image` - A PhotonImage.
|
|
2025
|
+
* * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
|
|
2026
|
+
* * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
|
|
2027
|
+
*
|
|
2028
|
+
* # Example
|
|
2029
|
+
* ```no_run
|
|
2030
|
+
* // For example to increase the saturation by 10%:
|
|
2031
|
+
* use photon_rs::colour_spaces::hsv;
|
|
2032
|
+
* use photon_rs::native::open_image;
|
|
2033
|
+
*
|
|
2034
|
+
* // Open the image. A PhotonImage is returned.
|
|
2035
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2036
|
+
* hsv(&mut img, "saturate", 0.1_f32);
|
|
2037
|
+
* ```
|
|
2038
|
+
* @param {PhotonImage} photon_image
|
|
2039
|
+
* @param {string} mode
|
|
2040
|
+
* @param {number} amt
|
|
2041
|
+
*/
|
|
2042
|
+
export function hsv(photon_image, mode, amt) {
|
|
2043
|
+
_assertClass(photon_image, PhotonImage);
|
|
2044
|
+
const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2045
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2046
|
+
wasm.hsv(photon_image.__wbg_ptr, ptr0, len0, amt);
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Shift hue by a specified number of degrees in the HSL colour space.
|
|
2051
|
+
* # Arguments
|
|
2052
|
+
* * `img` - A PhotonImage.
|
|
2053
|
+
* * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
|
|
2054
|
+
*
|
|
2055
|
+
* # Example
|
|
2056
|
+
* ```no_run
|
|
2057
|
+
* // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space:
|
|
2058
|
+
* use photon_rs::colour_spaces::hue_rotate_hsl;
|
|
2059
|
+
* use photon_rs::native::open_image;
|
|
2060
|
+
*
|
|
2061
|
+
* // Open the image. A PhotonImage is returned.
|
|
2062
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2063
|
+
* hue_rotate_hsl(&mut img, 120_f32);
|
|
2064
|
+
* ```
|
|
2065
|
+
* @param {PhotonImage} img
|
|
2066
|
+
* @param {number} degrees
|
|
2067
|
+
*/
|
|
2068
|
+
export function hue_rotate_hsl(img, degrees) {
|
|
2069
|
+
_assertClass(img, PhotonImage);
|
|
2070
|
+
wasm.hue_rotate_hsl(img.__wbg_ptr, degrees);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/**
|
|
2074
|
+
* Shift hue by a specified number of degrees in the HSLuv colour space.
|
|
2075
|
+
* # Arguments
|
|
2076
|
+
* * `img` - A PhotonImage.
|
|
2077
|
+
* * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
|
|
2078
|
+
*
|
|
2079
|
+
* # Example
|
|
2080
|
+
* ```no_run
|
|
2081
|
+
* // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space:
|
|
2082
|
+
* use photon_rs::colour_spaces::hue_rotate_hsluv;
|
|
2083
|
+
* use photon_rs::native::open_image;
|
|
2084
|
+
*
|
|
2085
|
+
* // Open the image. A PhotonImage is returned.
|
|
2086
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2087
|
+
* hue_rotate_hsluv(&mut img, 120_f32);
|
|
2088
|
+
* ```
|
|
2089
|
+
* @param {PhotonImage} img
|
|
2090
|
+
* @param {number} degrees
|
|
2091
|
+
*/
|
|
2092
|
+
export function hue_rotate_hsluv(img, degrees) {
|
|
2093
|
+
_assertClass(img, PhotonImage);
|
|
2094
|
+
wasm.hue_rotate_hsluv(img.__wbg_ptr, degrees);
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
* Shift hue by a specified number of degrees in the HSV colour space.
|
|
2099
|
+
* # Arguments
|
|
2100
|
+
* * `img` - A PhotonImage.
|
|
2101
|
+
* * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
|
|
2102
|
+
*
|
|
2103
|
+
* # Example
|
|
2104
|
+
* ```no_run
|
|
2105
|
+
* // For example to hue rotate/shift the hue by 120 degrees in the HSV colour space:
|
|
2106
|
+
* use photon_rs::colour_spaces::hue_rotate_hsv;
|
|
2107
|
+
* use photon_rs::native::open_image;
|
|
2108
|
+
*
|
|
2109
|
+
* // Open the image. A PhotonImage is returned.
|
|
2110
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2111
|
+
* hue_rotate_hsv(&mut img, 120_f32);
|
|
2112
|
+
* ```
|
|
2113
|
+
* @param {PhotonImage} img
|
|
2114
|
+
* @param {number} degrees
|
|
2115
|
+
*/
|
|
2116
|
+
export function hue_rotate_hsv(img, degrees) {
|
|
2117
|
+
_assertClass(img, PhotonImage);
|
|
2118
|
+
wasm.hue_rotate_hsv(img.__wbg_ptr, degrees);
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* Shift hue by a specified number of degrees in the LCh colour space.
|
|
2123
|
+
* # Arguments
|
|
2124
|
+
* * `img` - A PhotonImage.
|
|
2125
|
+
* * `mode` - A float value from 0 to 1 which is the amount to shift the hue by, or hue rotate by.
|
|
2126
|
+
*
|
|
2127
|
+
* # Example
|
|
2128
|
+
* ```no_run
|
|
2129
|
+
* // For example to hue rotate/shift the hue by 120 degrees in the HSL colour space:
|
|
2130
|
+
* use photon_rs::colour_spaces::hue_rotate_lch;
|
|
2131
|
+
* use photon_rs::native::open_image;
|
|
2132
|
+
*
|
|
2133
|
+
* // Open the image. A PhotonImage is returned.
|
|
2134
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2135
|
+
* hue_rotate_lch(&mut img, 120_f32);
|
|
2136
|
+
* ```
|
|
2137
|
+
* @param {PhotonImage} img
|
|
2138
|
+
* @param {number} degrees
|
|
2139
|
+
*/
|
|
2140
|
+
export function hue_rotate_lch(img, degrees) {
|
|
2141
|
+
_assertClass(img, PhotonImage);
|
|
2142
|
+
wasm.hue_rotate_lch(img.__wbg_ptr, degrees);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
/**
|
|
2146
|
+
* Apply an identity kernel convolution to an image.
|
|
2147
|
+
*
|
|
2148
|
+
* # Arguments
|
|
2149
|
+
* * `img` -A PhotonImage.
|
|
2150
|
+
*
|
|
2151
|
+
* # Example
|
|
2152
|
+
*
|
|
2153
|
+
* ```no_run
|
|
2154
|
+
* // For example, to apply an identity kernel convolution:
|
|
2155
|
+
* use photon_rs::conv::identity;
|
|
2156
|
+
* use photon_rs::native::open_image;
|
|
2157
|
+
*
|
|
2158
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2159
|
+
* identity(&mut img);
|
|
2160
|
+
* ```
|
|
2161
|
+
* @param {PhotonImage} photon_image
|
|
2162
|
+
*/
|
|
2163
|
+
export function identity(photon_image) {
|
|
2164
|
+
_assertClass(photon_image, PhotonImage);
|
|
2165
|
+
wasm.identity(photon_image.__wbg_ptr);
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* Increase the brightness of an image by a constant.
|
|
2170
|
+
*
|
|
2171
|
+
* # Arguments
|
|
2172
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
2173
|
+
* * `brightness` - A u8 to add to the brightness.
|
|
2174
|
+
* # Example
|
|
2175
|
+
*
|
|
2176
|
+
* ```no_run
|
|
2177
|
+
* use photon_rs::effects::inc_brightness;
|
|
2178
|
+
* use photon_rs::native::open_image;
|
|
2179
|
+
*
|
|
2180
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2181
|
+
* inc_brightness(&mut img, 10_u8);
|
|
2182
|
+
* ```
|
|
2183
|
+
* @param {PhotonImage} photon_image
|
|
2184
|
+
* @param {number} brightness
|
|
2185
|
+
*/
|
|
2186
|
+
export function inc_brightness(photon_image, brightness) {
|
|
2187
|
+
_assertClass(photon_image, PhotonImage);
|
|
2188
|
+
wasm.inc_brightness(photon_image.__wbg_ptr, brightness);
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
/**
|
|
2192
|
+
* Invert RGB value of an image.
|
|
2193
|
+
*
|
|
2194
|
+
* # Arguments
|
|
2195
|
+
* * `photon_image` - A DynamicImage that contains a view into the image.
|
|
2196
|
+
* # Example
|
|
2197
|
+
*
|
|
2198
|
+
* ```no_run
|
|
2199
|
+
* use photon_rs::channels::invert;
|
|
2200
|
+
* use photon_rs::native::open_image;
|
|
2201
|
+
*
|
|
2202
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2203
|
+
* invert(&mut img);
|
|
2204
|
+
* ```
|
|
2205
|
+
* @param {PhotonImage} photon_image
|
|
2206
|
+
*/
|
|
2207
|
+
export function invert(photon_image) {
|
|
2208
|
+
_assertClass(photon_image, PhotonImage);
|
|
2209
|
+
wasm.invert(photon_image.__wbg_ptr);
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* Apply a standard laplace convolution.
|
|
2214
|
+
*
|
|
2215
|
+
* # Arguments
|
|
2216
|
+
* * `img` - A PhotonImage.
|
|
2217
|
+
*
|
|
2218
|
+
* # Example
|
|
2219
|
+
*
|
|
2220
|
+
* ```no_run
|
|
2221
|
+
* // For example, to apply a laplace effect:
|
|
2222
|
+
* use photon_rs::conv::laplace;
|
|
2223
|
+
* use photon_rs::native::open_image;
|
|
2224
|
+
*
|
|
2225
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2226
|
+
* laplace(&mut img);
|
|
2227
|
+
* ```
|
|
2228
|
+
* @param {PhotonImage} photon_image
|
|
2229
|
+
*/
|
|
2230
|
+
export function laplace(photon_image) {
|
|
2231
|
+
_assertClass(photon_image, PhotonImage);
|
|
2232
|
+
wasm.laplace(photon_image.__wbg_ptr);
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
/**
|
|
2236
|
+
* Image manipulation effects in the LCh colour space
|
|
2237
|
+
*
|
|
2238
|
+
* Effects include:
|
|
2239
|
+
* * **saturate** - Saturation increase.
|
|
2240
|
+
* * **desaturate** - Desaturate the image.
|
|
2241
|
+
* * **shift_hue** - Hue rotation by a specified number of degrees.
|
|
2242
|
+
* * **darken** - Decrease the brightness.
|
|
2243
|
+
* * **lighten** - Increase the brightness.
|
|
2244
|
+
*
|
|
2245
|
+
* # Arguments
|
|
2246
|
+
* * `photon_image` - A PhotonImage.
|
|
2247
|
+
* * `mode` - The effect desired to be applied. Choose from: `saturate`, `desaturate`, `shift_hue`, `darken`, `lighten`
|
|
2248
|
+
* * `amt` - A float value from 0 to 1 which represents the amount the effect should be increased by.
|
|
2249
|
+
* # Example
|
|
2250
|
+
* ```no_run
|
|
2251
|
+
* // For example to increase the saturation by 10%:
|
|
2252
|
+
* use photon_rs::colour_spaces::lch;
|
|
2253
|
+
* use photon_rs::native::open_image;
|
|
2254
|
+
*
|
|
2255
|
+
* // Open the image. A PhotonImage is returned.
|
|
2256
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2257
|
+
* lch(&mut img, "saturate", 0.1_f32);
|
|
2258
|
+
* ```
|
|
2259
|
+
* @param {PhotonImage} photon_image
|
|
2260
|
+
* @param {string} mode
|
|
2261
|
+
* @param {number} amt
|
|
2262
|
+
*/
|
|
2263
|
+
export function lch(photon_image, mode, amt) {
|
|
2264
|
+
_assertClass(photon_image, PhotonImage);
|
|
2265
|
+
const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2266
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2267
|
+
wasm.lch(photon_image.__wbg_ptr, ptr0, len0, amt);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
/**
|
|
2271
|
+
* Lighten an image by a specified amount in the HSL colour space.
|
|
2272
|
+
* # Arguments
|
|
2273
|
+
* * `img` - A PhotonImage.
|
|
2274
|
+
* * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
|
|
2275
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
2276
|
+
* Lightening by 80% would be represented by a `level` of 0.8
|
|
2277
|
+
*
|
|
2278
|
+
* # Example
|
|
2279
|
+
* ```no_run
|
|
2280
|
+
* // For example to lighten an image by 10% in the HSL colour space:
|
|
2281
|
+
* use photon_rs::colour_spaces::lighten_hsl;
|
|
2282
|
+
* use photon_rs::native::open_image;
|
|
2283
|
+
*
|
|
2284
|
+
* // Open the image. A PhotonImage is returned.
|
|
2285
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2286
|
+
* lighten_hsl(&mut img, 0.1_f32);
|
|
2287
|
+
* ```
|
|
2288
|
+
* @param {PhotonImage} img
|
|
2289
|
+
* @param {number} level
|
|
2290
|
+
*/
|
|
2291
|
+
export function lighten_hsl(img, level) {
|
|
2292
|
+
_assertClass(img, PhotonImage);
|
|
2293
|
+
wasm.lighten_hsl(img.__wbg_ptr, level);
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
/**
|
|
2297
|
+
* Lighten an image by a specified amount in the HSLuv colour space.
|
|
2298
|
+
*
|
|
2299
|
+
* # Arguments
|
|
2300
|
+
* * `img` - A PhotonImage.
|
|
2301
|
+
* * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
|
|
2302
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
2303
|
+
* Lightening by 80% would be represented by a `level` of 0.8
|
|
2304
|
+
*
|
|
2305
|
+
* # Example
|
|
2306
|
+
* ```no_run
|
|
2307
|
+
* // For example to lighten an image by 10% in the HSLuv colour space:
|
|
2308
|
+
* use photon_rs::colour_spaces::lighten_hsluv;
|
|
2309
|
+
* use photon_rs::native::open_image;
|
|
2310
|
+
*
|
|
2311
|
+
* // Open the image. A PhotonImage is returned.
|
|
2312
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2313
|
+
* lighten_hsluv(&mut img, 0.1_f32);
|
|
2314
|
+
* ```
|
|
2315
|
+
* @param {PhotonImage} img
|
|
2316
|
+
* @param {number} level
|
|
2317
|
+
*/
|
|
2318
|
+
export function lighten_hsluv(img, level) {
|
|
2319
|
+
_assertClass(img, PhotonImage);
|
|
2320
|
+
wasm.lighten_hsluv(img.__wbg_ptr, level);
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
/**
|
|
2324
|
+
* Lighten an image by a specified amount in the HSV colour space.
|
|
2325
|
+
*
|
|
2326
|
+
* # Arguments
|
|
2327
|
+
* * `img` - A PhotonImage.
|
|
2328
|
+
* * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
|
|
2329
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
2330
|
+
* Lightening by 80% would be represented by a `level` of 0.8
|
|
2331
|
+
*
|
|
2332
|
+
* # Example
|
|
2333
|
+
* ```no_run
|
|
2334
|
+
* // For example to lighten an image by 10% in the HSV colour space:
|
|
2335
|
+
* use photon_rs::colour_spaces::lighten_hsv;
|
|
2336
|
+
* use photon_rs::native::open_image;
|
|
2337
|
+
*
|
|
2338
|
+
* // Open the image. A PhotonImage is returned.
|
|
2339
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2340
|
+
* lighten_hsv(&mut img, 0.1_f32);
|
|
2341
|
+
* ```
|
|
2342
|
+
* @param {PhotonImage} img
|
|
2343
|
+
* @param {number} level
|
|
2344
|
+
*/
|
|
2345
|
+
export function lighten_hsv(img, level) {
|
|
2346
|
+
_assertClass(img, PhotonImage);
|
|
2347
|
+
wasm.lighten_hsv(img.__wbg_ptr, level);
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* Lighten an image by a specified amount in the LCh colour space.
|
|
2352
|
+
*
|
|
2353
|
+
* # Arguments
|
|
2354
|
+
* * `img` - A PhotonImage.
|
|
2355
|
+
* * `level` - Float value from 0 to 1 representing the level to which to lighten the image by.
|
|
2356
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
2357
|
+
* Lightening by 80% would be represented by a `level` of 0.8
|
|
2358
|
+
*
|
|
2359
|
+
* # Example
|
|
2360
|
+
* ```no_run
|
|
2361
|
+
* // For example to lighten an image by 10% in the LCh colour space:
|
|
2362
|
+
* use photon_rs::colour_spaces::lighten_lch;
|
|
2363
|
+
* use photon_rs::native::open_image;
|
|
2364
|
+
*
|
|
2365
|
+
* // Open the image. A PhotonImage is returned.
|
|
2366
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2367
|
+
* lighten_lch(&mut img, 0.1_f32);
|
|
2368
|
+
* ```
|
|
2369
|
+
* @param {PhotonImage} img
|
|
2370
|
+
* @param {number} level
|
|
2371
|
+
*/
|
|
2372
|
+
export function lighten_lch(img, level) {
|
|
2373
|
+
_assertClass(img, PhotonImage);
|
|
2374
|
+
wasm.lighten_lch(img.__wbg_ptr, level);
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
/**
|
|
2378
|
+
* Solarization on the Red and Green channels.
|
|
2379
|
+
*
|
|
2380
|
+
* # Arguments
|
|
2381
|
+
* * `img` - A PhotonImage.
|
|
2382
|
+
* # Example
|
|
2383
|
+
*
|
|
2384
|
+
* ```no_run
|
|
2385
|
+
* use photon_rs::filters::lix;
|
|
2386
|
+
* use photon_rs::native::open_image;
|
|
2387
|
+
*
|
|
2388
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2389
|
+
* lix(&mut img);
|
|
2390
|
+
* ```
|
|
2391
|
+
* @param {PhotonImage} photon_image
|
|
2392
|
+
*/
|
|
2393
|
+
export function lix(photon_image) {
|
|
2394
|
+
_assertClass(photon_image, PhotonImage);
|
|
2395
|
+
wasm.lix(photon_image.__wbg_ptr);
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
/**
|
|
2399
|
+
* Apply a lofi effect to an image.
|
|
2400
|
+
*
|
|
2401
|
+
* # Arguments
|
|
2402
|
+
* * `img` - A PhotonImage.
|
|
2403
|
+
* # Example
|
|
2404
|
+
*
|
|
2405
|
+
* ```no_run
|
|
2406
|
+
* use photon_rs::filters::lofi;
|
|
2407
|
+
* use photon_rs::native::open_image;
|
|
2408
|
+
*
|
|
2409
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2410
|
+
* lofi(&mut img);
|
|
2411
|
+
* ```
|
|
2412
|
+
* @param {PhotonImage} img
|
|
2413
|
+
*/
|
|
2414
|
+
export function lofi(img) {
|
|
2415
|
+
_assertClass(img, PhotonImage);
|
|
2416
|
+
wasm.lofi(img.__wbg_ptr);
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
/**
|
|
2420
|
+
* Mix image with a single color, supporting passing `opacity`.
|
|
2421
|
+
* The algorithm comes from Jimp. See `function mix` and `function colorFn` at following link:
|
|
2422
|
+
* https://github.com/oliver-moran/jimp/blob/29679faa597228ff2f20d34c5758e4d2257065a3/packages/plugin-color/src/index.js
|
|
2423
|
+
* Specifically, result_value = (mix_color_value - origin_value) * opacity + origin_value =
|
|
2424
|
+
* mix_color_value * opacity + (1 - opacity) * origin_value for each
|
|
2425
|
+
* of RGB channel.
|
|
2426
|
+
*
|
|
2427
|
+
* # Arguments
|
|
2428
|
+
* * `photon_image` - A PhotonImage that contains a view into the image.
|
|
2429
|
+
* * `mix_color` - the color to be mixed in, as an RGB value.
|
|
2430
|
+
* * `opacity` - the opacity of color when mixed to image. Float value from 0 to 1.
|
|
2431
|
+
* # Example
|
|
2432
|
+
*
|
|
2433
|
+
* ```no_run
|
|
2434
|
+
* // For example, to mix an image with rgb (50, 255, 254) and opacity 0.4:
|
|
2435
|
+
* use photon_rs::Rgb;
|
|
2436
|
+
* use photon_rs::colour_spaces::mix_with_colour;
|
|
2437
|
+
* use photon_rs::native::open_image;
|
|
2438
|
+
*
|
|
2439
|
+
* let mix_colour = Rgb::new(50_u8, 255_u8, 254_u8);
|
|
2440
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2441
|
+
* mix_with_colour(&mut img, mix_colour, 0.4_f32);
|
|
2442
|
+
* ```
|
|
2443
|
+
* @param {PhotonImage} photon_image
|
|
2444
|
+
* @param {Rgb} mix_colour
|
|
2445
|
+
* @param {number} opacity
|
|
2446
|
+
*/
|
|
2447
|
+
export function mix_with_colour(photon_image, mix_colour, opacity) {
|
|
2448
|
+
_assertClass(photon_image, PhotonImage);
|
|
2449
|
+
_assertClass(mix_colour, Rgb);
|
|
2450
|
+
var ptr0 = mix_colour.__destroy_into_raw();
|
|
2451
|
+
wasm.mix_with_colour(photon_image.__wbg_ptr, ptr0, opacity);
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
/**
|
|
2455
|
+
* Apply a monochrome effect of a certain colour.
|
|
2456
|
+
*
|
|
2457
|
+
* It does so by averaging the R, G, and B values of a pixel, and then adding a
|
|
2458
|
+
* separate value to that averaged value for each channel to produce a tint.
|
|
2459
|
+
* # Arguments
|
|
2460
|
+
* * `photon_image` - A PhotonImage.
|
|
2461
|
+
* * `r_offset` - The value to add to the Red channel per pixel.
|
|
2462
|
+
* * `g_offset` - The value to add to the Green channel per pixel.
|
|
2463
|
+
* * `b_offset` - The value to add to the Blue channel per pixel.
|
|
2464
|
+
*
|
|
2465
|
+
* # Example
|
|
2466
|
+
*
|
|
2467
|
+
* ```no_run
|
|
2468
|
+
* // For example, to apply a monochrome effect to an image:
|
|
2469
|
+
* use photon_rs::monochrome::monochrome;
|
|
2470
|
+
* use photon_rs::native::open_image;
|
|
2471
|
+
*
|
|
2472
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2473
|
+
* monochrome(&mut img, 40_u32, 50_u32, 100_u32);
|
|
2474
|
+
* ```
|
|
2475
|
+
* @param {PhotonImage} img
|
|
2476
|
+
* @param {number} r_offset
|
|
2477
|
+
* @param {number} g_offset
|
|
2478
|
+
* @param {number} b_offset
|
|
2479
|
+
*/
|
|
2480
|
+
export function monochrome(img, r_offset, g_offset, b_offset) {
|
|
2481
|
+
_assertClass(img, PhotonImage);
|
|
2482
|
+
wasm.monochrome(img.__wbg_ptr, r_offset, g_offset, b_offset);
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
/**
|
|
2486
|
+
* Monochrome tint effect with increased contrast
|
|
2487
|
+
*
|
|
2488
|
+
* # Arguments
|
|
2489
|
+
* * `img` - A PhotonImage.
|
|
2490
|
+
* * `rgb_color` - RGB color
|
|
2491
|
+
* # Example
|
|
2492
|
+
*
|
|
2493
|
+
* ```no_run
|
|
2494
|
+
* use photon_rs::filters::monochrome_tint;
|
|
2495
|
+
* use photon_rs::native::open_image;
|
|
2496
|
+
* use photon_rs::Rgb;
|
|
2497
|
+
*
|
|
2498
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2499
|
+
* let rgb_color = Rgb::new(12, 12, 10);
|
|
2500
|
+
* monochrome_tint(&mut img, rgb_color);
|
|
2501
|
+
* ```
|
|
2502
|
+
* @param {PhotonImage} img
|
|
2503
|
+
* @param {Rgb} rgb_color
|
|
2504
|
+
*/
|
|
2505
|
+
export function monochrome_tint(img, rgb_color) {
|
|
2506
|
+
_assertClass(img, PhotonImage);
|
|
2507
|
+
_assertClass(rgb_color, Rgb);
|
|
2508
|
+
var ptr0 = rgb_color.__destroy_into_raw();
|
|
2509
|
+
wasm.monochrome_tint(img.__wbg_ptr, ptr0);
|
|
2510
|
+
}
|
|
2511
|
+
|
|
2512
|
+
/**
|
|
2513
|
+
* Adds multiple offsets to the image by a certain number of pixels (on two channels).
|
|
2514
|
+
*
|
|
2515
|
+
* # Arguments
|
|
2516
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
2517
|
+
* * `offset` - The offset is added to the pixels in the image.
|
|
2518
|
+
* # Example
|
|
2519
|
+
*
|
|
2520
|
+
* ```no_run
|
|
2521
|
+
* // For example, to add a 30-pixel offset to both the red and blue channels:
|
|
2522
|
+
* use photon_rs::effects::multiple_offsets;
|
|
2523
|
+
* use photon_rs::native::open_image;
|
|
2524
|
+
*
|
|
2525
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2526
|
+
* multiple_offsets(&mut img, 30_u32, 0_usize, 2_usize);
|
|
2527
|
+
* ```
|
|
2528
|
+
* @param {PhotonImage} photon_image
|
|
2529
|
+
* @param {number} offset
|
|
2530
|
+
* @param {number} channel_index
|
|
2531
|
+
* @param {number} channel_index2
|
|
2532
|
+
*/
|
|
2533
|
+
export function multiple_offsets(photon_image, offset, channel_index, channel_index2) {
|
|
2534
|
+
_assertClass(photon_image, PhotonImage);
|
|
2535
|
+
wasm.multiple_offsets(photon_image.__wbg_ptr, offset, channel_index, channel_index2);
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
/**
|
|
2539
|
+
* Solarization on the Blue channel.
|
|
2540
|
+
*
|
|
2541
|
+
* # Arguments
|
|
2542
|
+
* * `img` - A PhotonImage.
|
|
2543
|
+
* # Example
|
|
2544
|
+
*
|
|
2545
|
+
* ```no_run
|
|
2546
|
+
* use photon_rs::filters::neue;
|
|
2547
|
+
* use photon_rs::native::open_image;
|
|
2548
|
+
*
|
|
2549
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2550
|
+
* neue(&mut img);
|
|
2551
|
+
* ```
|
|
2552
|
+
* @param {PhotonImage} photon_image
|
|
2553
|
+
*/
|
|
2554
|
+
export function neue(photon_image) {
|
|
2555
|
+
_assertClass(photon_image, PhotonImage);
|
|
2556
|
+
wasm.neue(photon_image.__wbg_ptr);
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
/**
|
|
2560
|
+
* Noise reduction.
|
|
2561
|
+
*
|
|
2562
|
+
* # Arguments
|
|
2563
|
+
* * `img` - A PhotonImage.
|
|
2564
|
+
*
|
|
2565
|
+
* # Example
|
|
2566
|
+
*
|
|
2567
|
+
* ```no_run
|
|
2568
|
+
* // For example, to noise reduct an image:
|
|
2569
|
+
* use photon_rs::conv::noise_reduction;
|
|
2570
|
+
* use photon_rs::native::open_image;
|
|
2571
|
+
*
|
|
2572
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2573
|
+
* noise_reduction(&mut img);
|
|
2574
|
+
* ```
|
|
2575
|
+
* Adds a constant to a select R, G, or B channel's value.
|
|
2576
|
+
* @param {PhotonImage} photon_image
|
|
2577
|
+
*/
|
|
2578
|
+
export function noise_reduction(photon_image) {
|
|
2579
|
+
_assertClass(photon_image, PhotonImage);
|
|
2580
|
+
wasm.noise_reduction(photon_image.__wbg_ptr);
|
|
2581
|
+
}
|
|
2582
|
+
|
|
2583
|
+
/**
|
|
2584
|
+
* Normalizes an image by remapping its range of pixels values. Only RGB
|
|
2585
|
+
* channels are processed and each channel is stretched to \[0, 255\] range
|
|
2586
|
+
* independently. This process is also known as contrast stretching.
|
|
2587
|
+
* # Arguments
|
|
2588
|
+
* * `photon_image` - A PhotonImage that contains a view into the image.
|
|
2589
|
+
* # Example
|
|
2590
|
+
*
|
|
2591
|
+
* ```no_run
|
|
2592
|
+
* // For example, to turn an image of type `PhotonImage` into a normalized image:
|
|
2593
|
+
* use photon_rs::effects::normalize;
|
|
2594
|
+
* use photon_rs::native::open_image;
|
|
2595
|
+
*
|
|
2596
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2597
|
+
* normalize(&mut img);
|
|
2598
|
+
* ```
|
|
2599
|
+
* @param {PhotonImage} photon_image
|
|
2600
|
+
*/
|
|
2601
|
+
export function normalize(photon_image) {
|
|
2602
|
+
_assertClass(photon_image, PhotonImage);
|
|
2603
|
+
wasm.normalize(photon_image.__wbg_ptr);
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
/**
|
|
2607
|
+
* Apply a greyscale effect with increased contrast.
|
|
2608
|
+
*
|
|
2609
|
+
* # Arguments
|
|
2610
|
+
* * `img` - A PhotonImage.
|
|
2611
|
+
* # Example
|
|
2612
|
+
*
|
|
2613
|
+
* ```no_run
|
|
2614
|
+
* use photon_rs::filters::obsidian;
|
|
2615
|
+
* use photon_rs::native::open_image;
|
|
2616
|
+
*
|
|
2617
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2618
|
+
* obsidian(&mut img);
|
|
2619
|
+
* ```
|
|
2620
|
+
* @param {PhotonImage} img
|
|
2621
|
+
*/
|
|
2622
|
+
export function obsidian(img) {
|
|
2623
|
+
_assertClass(img, PhotonImage);
|
|
2624
|
+
wasm.obsidian(img.__wbg_ptr);
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
/**
|
|
2628
|
+
* Adds an offset to the image by a certain number of pixels.
|
|
2629
|
+
*
|
|
2630
|
+
* This creates an RGB shift effect.
|
|
2631
|
+
*
|
|
2632
|
+
* # Arguments
|
|
2633
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
2634
|
+
* * `channel_index`: The index of the channel to increment. 0 for red, 1 for green and 2 for blue.
|
|
2635
|
+
* * `offset` - The offset is added to the pixels in the image.
|
|
2636
|
+
* # Example
|
|
2637
|
+
*
|
|
2638
|
+
* ```no_run
|
|
2639
|
+
* // For example, to offset pixels by 30 pixels on the red channel:
|
|
2640
|
+
* use photon_rs::effects::offset;
|
|
2641
|
+
* use photon_rs::native::open_image;
|
|
2642
|
+
*
|
|
2643
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2644
|
+
* offset(&mut img, 0_usize, 30_u32);
|
|
2645
|
+
* ```
|
|
2646
|
+
* @param {PhotonImage} photon_image
|
|
2647
|
+
* @param {number} channel_index
|
|
2648
|
+
* @param {number} offset
|
|
2649
|
+
*/
|
|
2650
|
+
export function offset(photon_image, channel_index, offset) {
|
|
2651
|
+
_assertClass(photon_image, PhotonImage);
|
|
2652
|
+
wasm.offset(photon_image.__wbg_ptr, channel_index, offset);
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
/**
|
|
2656
|
+
* Adds an offset to the blue channel by a certain number of pixels.
|
|
2657
|
+
*
|
|
2658
|
+
* # Arguments
|
|
2659
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
2660
|
+
* * `offset_amt` - The offset you want to move the blue channel by.
|
|
2661
|
+
* # Example
|
|
2662
|
+
* // For example, to add an offset to the green channel by 40 pixels.
|
|
2663
|
+
*
|
|
2664
|
+
* ```no_run
|
|
2665
|
+
* use photon_rs::effects::offset_blue;
|
|
2666
|
+
* use photon_rs::native::open_image;
|
|
2667
|
+
*
|
|
2668
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2669
|
+
* offset_blue(&mut img, 40_u32);
|
|
2670
|
+
* ```
|
|
2671
|
+
* @param {PhotonImage} img
|
|
2672
|
+
* @param {number} offset_amt
|
|
2673
|
+
*/
|
|
2674
|
+
export function offset_blue(img, offset_amt) {
|
|
2675
|
+
_assertClass(img, PhotonImage);
|
|
2676
|
+
wasm.offset_blue(img.__wbg_ptr, offset_amt);
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
/**
|
|
2680
|
+
* Adds an offset to the green channel by a certain number of pixels.
|
|
2681
|
+
*
|
|
2682
|
+
* # Arguments
|
|
2683
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
2684
|
+
* * `offset` - The offset you want to move the green channel by.
|
|
2685
|
+
* # Example
|
|
2686
|
+
*
|
|
2687
|
+
* ```no_run
|
|
2688
|
+
* // For example, to add an offset to the green channel by 30 pixels.
|
|
2689
|
+
* use photon_rs::effects::offset_green;
|
|
2690
|
+
* use photon_rs::native::open_image;
|
|
2691
|
+
*
|
|
2692
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2693
|
+
* offset_green(&mut img, 30_u32);
|
|
2694
|
+
* ```
|
|
2695
|
+
* @param {PhotonImage} img
|
|
2696
|
+
* @param {number} offset_amt
|
|
2697
|
+
*/
|
|
2698
|
+
export function offset_green(img, offset_amt) {
|
|
2699
|
+
_assertClass(img, PhotonImage);
|
|
2700
|
+
wasm.offset_green(img.__wbg_ptr, offset_amt);
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
/**
|
|
2704
|
+
* Adds an offset to the red channel by a certain number of pixels.
|
|
2705
|
+
*
|
|
2706
|
+
* # Arguments
|
|
2707
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
2708
|
+
* * `offset` - The offset you want to move the red channel by.
|
|
2709
|
+
* # Example
|
|
2710
|
+
*
|
|
2711
|
+
* ```no_run
|
|
2712
|
+
* // For example, to add an offset to the red channel by 30 pixels.
|
|
2713
|
+
* use photon_rs::effects::offset_red;
|
|
2714
|
+
* use photon_rs::native::open_image;
|
|
2715
|
+
*
|
|
2716
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2717
|
+
* offset_red(&mut img, 30_u32);
|
|
2718
|
+
* ```
|
|
2719
|
+
* @param {PhotonImage} img
|
|
2720
|
+
* @param {number} offset_amt
|
|
2721
|
+
*/
|
|
2722
|
+
export function offset_red(img, offset_amt) {
|
|
2723
|
+
_assertClass(img, PhotonImage);
|
|
2724
|
+
wasm.offset_red(img.__wbg_ptr, offset_amt);
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
/**
|
|
2728
|
+
* Turn an image into an oil painting
|
|
2729
|
+
*
|
|
2730
|
+
* # Arguments
|
|
2731
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
2732
|
+
* * `radius` - Radius of each paint particle
|
|
2733
|
+
* * `intesnity` - How artsy an Image should be
|
|
2734
|
+
* # Example
|
|
2735
|
+
*
|
|
2736
|
+
* ```no_run
|
|
2737
|
+
* // For example, to oil an image of type `PhotonImage`:
|
|
2738
|
+
* use photon_rs::effects::oil;
|
|
2739
|
+
* use photon_rs::native::open_image;
|
|
2740
|
+
*
|
|
2741
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2742
|
+
* oil(&mut img, 4i32, 55.0);
|
|
2743
|
+
* ```
|
|
2744
|
+
* @param {PhotonImage} photon_image
|
|
2745
|
+
* @param {number} radius
|
|
2746
|
+
* @param {number} intensity
|
|
2747
|
+
*/
|
|
2748
|
+
export function oil(photon_image, radius, intensity) {
|
|
2749
|
+
_assertClass(photon_image, PhotonImage);
|
|
2750
|
+
wasm.oil(photon_image.__wbg_ptr, radius, intensity);
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
/**
|
|
2754
|
+
* Convert a HTML5 Canvas Element to a PhotonImage.
|
|
2755
|
+
*
|
|
2756
|
+
* This converts the ImageData found in the canvas context to a PhotonImage,
|
|
2757
|
+
* which can then have effects or filters applied to it.
|
|
2758
|
+
* @param {HTMLCanvasElement} canvas
|
|
2759
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
2760
|
+
* @returns {PhotonImage}
|
|
2761
|
+
*/
|
|
2762
|
+
export function open_image(canvas, ctx) {
|
|
2763
|
+
const ret = wasm.open_image(canvas, ctx);
|
|
2764
|
+
return PhotonImage.__wrap(ret);
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
/**
|
|
2768
|
+
* Apply padding on the left side of the PhotonImage
|
|
2769
|
+
* A padded PhotonImage is returned.
|
|
2770
|
+
* # Arguments
|
|
2771
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
2772
|
+
* * `padding` - The amount of padding to be applied to the PhotonImage.
|
|
2773
|
+
* * `padding_rgba` - Tuple containing the RGBA code for padding color.
|
|
2774
|
+
*
|
|
2775
|
+
* # Example
|
|
2776
|
+
*
|
|
2777
|
+
* ```no_run
|
|
2778
|
+
* // For example, to apply a padding of 10 pixels on the bottom of a PhotonImage:
|
|
2779
|
+
* use photon_rs::transform::padding_bottom;
|
|
2780
|
+
* use photon_rs::native::open_image;
|
|
2781
|
+
* use photon_rs::Rgba;
|
|
2782
|
+
*
|
|
2783
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2784
|
+
* let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
|
|
2785
|
+
* padding_bottom(&img, 10_u32, rgba);
|
|
2786
|
+
* ```
|
|
2787
|
+
* @param {PhotonImage} img
|
|
2788
|
+
* @param {number} padding
|
|
2789
|
+
* @param {Rgba} padding_rgba
|
|
2790
|
+
* @returns {PhotonImage}
|
|
2791
|
+
*/
|
|
2792
|
+
export function padding_bottom(img, padding, padding_rgba) {
|
|
2793
|
+
_assertClass(img, PhotonImage);
|
|
2794
|
+
_assertClass(padding_rgba, Rgba);
|
|
2795
|
+
var ptr0 = padding_rgba.__destroy_into_raw();
|
|
2796
|
+
const ret = wasm.padding_bottom(img.__wbg_ptr, padding, ptr0);
|
|
2797
|
+
return PhotonImage.__wrap(ret);
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
/**
|
|
2801
|
+
* Apply padding on the left side of the PhotonImage
|
|
2802
|
+
* A padded PhotonImage is returned.
|
|
2803
|
+
* # Arguments
|
|
2804
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
2805
|
+
* * `padding` - The amount of padding to be applied to the PhotonImage.
|
|
2806
|
+
* * `padding_rgba` - Tuple containing the RGBA code for padding color.
|
|
2807
|
+
*
|
|
2808
|
+
* # Example
|
|
2809
|
+
*
|
|
2810
|
+
* ```no_run
|
|
2811
|
+
* // For example, to apply a padding of 10 pixels on the left side of a PhotonImage:
|
|
2812
|
+
* use photon_rs::transform::padding_left;
|
|
2813
|
+
* use photon_rs::native::open_image;
|
|
2814
|
+
* use photon_rs::Rgba;
|
|
2815
|
+
*
|
|
2816
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2817
|
+
* let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
|
|
2818
|
+
* padding_left(&img, 10_u32, rgba);
|
|
2819
|
+
* ```
|
|
2820
|
+
* @param {PhotonImage} img
|
|
2821
|
+
* @param {number} padding
|
|
2822
|
+
* @param {Rgba} padding_rgba
|
|
2823
|
+
* @returns {PhotonImage}
|
|
2824
|
+
*/
|
|
2825
|
+
export function padding_left(img, padding, padding_rgba) {
|
|
2826
|
+
_assertClass(img, PhotonImage);
|
|
2827
|
+
_assertClass(padding_rgba, Rgba);
|
|
2828
|
+
var ptr0 = padding_rgba.__destroy_into_raw();
|
|
2829
|
+
const ret = wasm.padding_left(img.__wbg_ptr, padding, ptr0);
|
|
2830
|
+
return PhotonImage.__wrap(ret);
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
/**
|
|
2834
|
+
* Apply padding on the left side of the PhotonImage
|
|
2835
|
+
* A padded PhotonImage is returned.
|
|
2836
|
+
* # Arguments
|
|
2837
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
2838
|
+
* * `padding` - The amount of padding to be applied to the PhotonImage.
|
|
2839
|
+
* * `padding_rgba` - Tuple containing the RGBA code for padding color.
|
|
2840
|
+
*
|
|
2841
|
+
* # Example
|
|
2842
|
+
*
|
|
2843
|
+
* ```no_run
|
|
2844
|
+
* // For example, to apply a padding of 10 pixels on the right side of a PhotonImage:
|
|
2845
|
+
* use photon_rs::transform::padding_right;
|
|
2846
|
+
* use photon_rs::native::open_image;
|
|
2847
|
+
* use photon_rs::Rgba;
|
|
2848
|
+
*
|
|
2849
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2850
|
+
* let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
|
|
2851
|
+
* padding_right(&img, 10_u32, rgba);
|
|
2852
|
+
* ```
|
|
2853
|
+
* @param {PhotonImage} img
|
|
2854
|
+
* @param {number} padding
|
|
2855
|
+
* @param {Rgba} padding_rgba
|
|
2856
|
+
* @returns {PhotonImage}
|
|
2857
|
+
*/
|
|
2858
|
+
export function padding_right(img, padding, padding_rgba) {
|
|
2859
|
+
_assertClass(img, PhotonImage);
|
|
2860
|
+
_assertClass(padding_rgba, Rgba);
|
|
2861
|
+
var ptr0 = padding_rgba.__destroy_into_raw();
|
|
2862
|
+
const ret = wasm.padding_right(img.__wbg_ptr, padding, ptr0);
|
|
2863
|
+
return PhotonImage.__wrap(ret);
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
/**
|
|
2867
|
+
* Apply padding on the left side of the PhotonImage
|
|
2868
|
+
* A padded PhotonImage is returned.
|
|
2869
|
+
* # Arguments
|
|
2870
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
2871
|
+
* * `padding` - The amount of padding to be applied to the PhotonImage.
|
|
2872
|
+
* * `padding_rgba` - Tuple containing the RGBA code for padding color.
|
|
2873
|
+
*
|
|
2874
|
+
* # Example
|
|
2875
|
+
*
|
|
2876
|
+
* ```no_run
|
|
2877
|
+
* // For example, to apply a padding of 10 pixels on the top of a PhotonImage:
|
|
2878
|
+
* use photon_rs::transform::padding_top;
|
|
2879
|
+
* use photon_rs::native::open_image;
|
|
2880
|
+
* use photon_rs::Rgba;
|
|
2881
|
+
*
|
|
2882
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2883
|
+
* let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
|
|
2884
|
+
* padding_top(&img, 10_u32, rgba);
|
|
2885
|
+
* ```
|
|
2886
|
+
* @param {PhotonImage} img
|
|
2887
|
+
* @param {number} padding
|
|
2888
|
+
* @param {Rgba} padding_rgba
|
|
2889
|
+
* @returns {PhotonImage}
|
|
2890
|
+
*/
|
|
2891
|
+
export function padding_top(img, padding, padding_rgba) {
|
|
2892
|
+
_assertClass(img, PhotonImage);
|
|
2893
|
+
_assertClass(padding_rgba, Rgba);
|
|
2894
|
+
var ptr0 = padding_rgba.__destroy_into_raw();
|
|
2895
|
+
const ret = wasm.padding_top(img.__wbg_ptr, padding, ptr0);
|
|
2896
|
+
return PhotonImage.__wrap(ret);
|
|
2897
|
+
}
|
|
2898
|
+
|
|
2899
|
+
/**
|
|
2900
|
+
* Apply uniform padding around the PhotonImage
|
|
2901
|
+
* A padded PhotonImage is returned.
|
|
2902
|
+
* # Arguments
|
|
2903
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
2904
|
+
* * `padding` - The amount of padding to be applied to the PhotonImage.
|
|
2905
|
+
* * `padding_rgba` - Tuple containing the RGBA code for padding color.
|
|
2906
|
+
*
|
|
2907
|
+
* # Example
|
|
2908
|
+
*
|
|
2909
|
+
* ```no_run
|
|
2910
|
+
* // For example, to apply a padding of 10 pixels around a PhotonImage:
|
|
2911
|
+
* use photon_rs::transform::padding_uniform;
|
|
2912
|
+
* use photon_rs::native::open_image;
|
|
2913
|
+
* use photon_rs::Rgba;
|
|
2914
|
+
*
|
|
2915
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2916
|
+
* let rgba = Rgba::new(200_u8, 100_u8, 150_u8, 255_u8);
|
|
2917
|
+
* padding_uniform(&img, 10_u32, rgba);
|
|
2918
|
+
* ```
|
|
2919
|
+
* @param {PhotonImage} img
|
|
2920
|
+
* @param {number} padding
|
|
2921
|
+
* @param {Rgba} padding_rgba
|
|
2922
|
+
* @returns {PhotonImage}
|
|
2923
|
+
*/
|
|
2924
|
+
export function padding_uniform(img, padding, padding_rgba) {
|
|
2925
|
+
_assertClass(img, PhotonImage);
|
|
2926
|
+
_assertClass(padding_rgba, Rgba);
|
|
2927
|
+
var ptr0 = padding_rgba.__destroy_into_raw();
|
|
2928
|
+
const ret = wasm.padding_uniform(img.__wbg_ptr, padding, ptr0);
|
|
2929
|
+
return PhotonImage.__wrap(ret);
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
/**
|
|
2933
|
+
* Apply a rose tint to an image.
|
|
2934
|
+
*
|
|
2935
|
+
* # Arguments
|
|
2936
|
+
* * `img` - A PhotonImage.
|
|
2937
|
+
* # Example
|
|
2938
|
+
*
|
|
2939
|
+
* ```no_run
|
|
2940
|
+
* use photon_rs::filters::pastel_pink;
|
|
2941
|
+
* use photon_rs::native::open_image;
|
|
2942
|
+
*
|
|
2943
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2944
|
+
* pastel_pink(&mut img);
|
|
2945
|
+
* ```
|
|
2946
|
+
* @param {PhotonImage} img
|
|
2947
|
+
*/
|
|
2948
|
+
export function pastel_pink(img) {
|
|
2949
|
+
_assertClass(img, PhotonImage);
|
|
2950
|
+
wasm.pastel_pink(img.__wbg_ptr);
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
/**
|
|
2954
|
+
* Add pink-tinted noise to an image.
|
|
2955
|
+
*
|
|
2956
|
+
* **[WASM SUPPORT IS AVAILABLE]**: Randomized thread pools cannot be created with WASM, but
|
|
2957
|
+
* a workaround using js_sys::Math::random works now.
|
|
2958
|
+
* # Arguments
|
|
2959
|
+
* * `name` - A PhotonImage that contains a view into the image.
|
|
2960
|
+
*
|
|
2961
|
+
* # Example
|
|
2962
|
+
*
|
|
2963
|
+
* ```no_run
|
|
2964
|
+
* // For example, to add pink-tinted noise to an image:
|
|
2965
|
+
* use photon_rs::native::open_image;
|
|
2966
|
+
* use photon_rs::noise::pink_noise;
|
|
2967
|
+
*
|
|
2968
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2969
|
+
* pink_noise(&mut img);
|
|
2970
|
+
* ```
|
|
2971
|
+
* @param {PhotonImage} photon_image
|
|
2972
|
+
*/
|
|
2973
|
+
export function pink_noise(photon_image) {
|
|
2974
|
+
_assertClass(photon_image, PhotonImage);
|
|
2975
|
+
wasm.pink_noise(photon_image.__wbg_ptr);
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
/**
|
|
2979
|
+
* Pixelize an image.
|
|
2980
|
+
*
|
|
2981
|
+
* # Arguments
|
|
2982
|
+
* * `photon_image` - A PhotonImage that contains a view into the image.
|
|
2983
|
+
* * `pixel_size` - Targeted pixel size of generated image.
|
|
2984
|
+
* # Example
|
|
2985
|
+
*
|
|
2986
|
+
* ```no_run
|
|
2987
|
+
* // For example, to turn an image of type `PhotonImage` into a pixelized image with 50 pixels blocks:
|
|
2988
|
+
* use photon_rs::effects::pixelize;
|
|
2989
|
+
* use photon_rs::native::open_image;
|
|
2990
|
+
*
|
|
2991
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
2992
|
+
* pixelize(&mut img, 50);
|
|
2993
|
+
* ```
|
|
2994
|
+
* @param {PhotonImage} photon_image
|
|
2995
|
+
* @param {number} pixel_size
|
|
2996
|
+
*/
|
|
2997
|
+
export function pixelize(photon_image, pixel_size) {
|
|
2998
|
+
_assertClass(photon_image, PhotonImage);
|
|
2999
|
+
wasm.pixelize(photon_image.__wbg_ptr, pixel_size);
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
/**
|
|
3003
|
+
* Apply a horizontal Prewitt convolution to an image.
|
|
3004
|
+
*
|
|
3005
|
+
* # Arguments
|
|
3006
|
+
* * `img` - A PhotonImage.
|
|
3007
|
+
*
|
|
3008
|
+
* # Example
|
|
3009
|
+
*
|
|
3010
|
+
* ```no_run
|
|
3011
|
+
* // For example, to apply a horizontal Prewitt convolution effect:
|
|
3012
|
+
* use photon_rs::conv::prewitt_horizontal;
|
|
3013
|
+
* use photon_rs::native::open_image;
|
|
3014
|
+
*
|
|
3015
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3016
|
+
* prewitt_horizontal(&mut img);
|
|
3017
|
+
* ```
|
|
3018
|
+
* @param {PhotonImage} photon_image
|
|
3019
|
+
*/
|
|
3020
|
+
export function prewitt_horizontal(photon_image) {
|
|
3021
|
+
_assertClass(photon_image, PhotonImage);
|
|
3022
|
+
wasm.prewitt_horizontal(photon_image.__wbg_ptr);
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
/**
|
|
3026
|
+
* Reduces an image to the primary colours.
|
|
3027
|
+
*
|
|
3028
|
+
* # Arguments
|
|
3029
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
3030
|
+
* # Example
|
|
3031
|
+
*
|
|
3032
|
+
* ```no_run
|
|
3033
|
+
* // For example, to add a primary colour effect to an image of type `DynamicImage`:
|
|
3034
|
+
* use photon_rs::effects::primary;
|
|
3035
|
+
* use photon_rs::native::open_image;
|
|
3036
|
+
*
|
|
3037
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3038
|
+
* primary(&mut img);
|
|
3039
|
+
* ```
|
|
3040
|
+
* @param {PhotonImage} img
|
|
3041
|
+
*/
|
|
3042
|
+
export function primary(img) {
|
|
3043
|
+
_assertClass(img, PhotonImage);
|
|
3044
|
+
wasm.primary(img.__wbg_ptr);
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
/**
|
|
3048
|
+
* Place a PhotonImage onto a 2D canvas.
|
|
3049
|
+
* @param {HTMLCanvasElement} canvas
|
|
3050
|
+
* @param {CanvasRenderingContext2D} ctx
|
|
3051
|
+
* @param {PhotonImage} new_image
|
|
3052
|
+
*/
|
|
3053
|
+
export function putImageData(canvas, ctx, new_image) {
|
|
3054
|
+
_assertClass(new_image, PhotonImage);
|
|
3055
|
+
var ptr0 = new_image.__destroy_into_raw();
|
|
3056
|
+
wasm.putImageData(canvas, ctx, ptr0);
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
/**
|
|
3060
|
+
* Convert an image to grayscale by setting a pixel's 3 RGB values to the Red channel's value.
|
|
3061
|
+
*
|
|
3062
|
+
* # Arguments
|
|
3063
|
+
* * `photon_image` - A PhotonImage.
|
|
3064
|
+
*
|
|
3065
|
+
* # Example
|
|
3066
|
+
*
|
|
3067
|
+
* ```no_run
|
|
3068
|
+
* use photon_rs::monochrome::r_grayscale;
|
|
3069
|
+
* use photon_rs::native::open_image;
|
|
3070
|
+
*
|
|
3071
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3072
|
+
* r_grayscale(&mut img);
|
|
3073
|
+
* ```
|
|
3074
|
+
* @param {PhotonImage} photon_image
|
|
3075
|
+
*/
|
|
3076
|
+
export function r_grayscale(photon_image) {
|
|
3077
|
+
_assertClass(photon_image, PhotonImage);
|
|
3078
|
+
wasm.r_grayscale(photon_image.__wbg_ptr);
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
/**
|
|
3082
|
+
* Remove the Blue channel's influence in an image.
|
|
3083
|
+
*
|
|
3084
|
+
* # Arguments
|
|
3085
|
+
* * `img` - A PhotonImage.
|
|
3086
|
+
* * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter.
|
|
3087
|
+
*
|
|
3088
|
+
* # Example
|
|
3089
|
+
*
|
|
3090
|
+
* ```no_run
|
|
3091
|
+
* // For example, to remove the blue channel for blue channel pixel values less than 50:
|
|
3092
|
+
* use photon_rs::channels::remove_blue_channel;
|
|
3093
|
+
* use photon_rs::native::open_image;
|
|
3094
|
+
*
|
|
3095
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3096
|
+
* remove_blue_channel(&mut img, 50_u8);
|
|
3097
|
+
* ```
|
|
3098
|
+
* @param {PhotonImage} img
|
|
3099
|
+
* @param {number} min_filter
|
|
3100
|
+
*/
|
|
3101
|
+
export function remove_blue_channel(img, min_filter) {
|
|
3102
|
+
_assertClass(img, PhotonImage);
|
|
3103
|
+
wasm.remove_blue_channel(img.__wbg_ptr, min_filter);
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
/**
|
|
3107
|
+
* Set a certain channel to zero, thus removing the channel's influence in the pixels' final rendered colour.
|
|
3108
|
+
*
|
|
3109
|
+
* # Arguments
|
|
3110
|
+
* * `img` - A PhotonImage.
|
|
3111
|
+
* * `channel` - The channel to be removed; must be a usize from 0 to 2, with 0 representing Red, 1 representing Green, and 2 representing Blue.
|
|
3112
|
+
* * `min_filter` - Minimum filter. Value between 0 and 255. Only remove the channel if the current pixel's channel value is less than this minimum filter. To completely
|
|
3113
|
+
* remove the channel, set this value to 255, to leave the channel as is, set to 0, and to set a channel to zero for a pixel whose red value is greater than 50,
|
|
3114
|
+
* then channel would be 0 and min_filter would be 50.
|
|
3115
|
+
*
|
|
3116
|
+
* # Example
|
|
3117
|
+
*
|
|
3118
|
+
* ```no_run
|
|
3119
|
+
* // For example, to remove the Red channel with a min_filter of 100:
|
|
3120
|
+
* use photon_rs::channels::remove_channel;
|
|
3121
|
+
* use photon_rs::native::open_image;
|
|
3122
|
+
*
|
|
3123
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3124
|
+
* remove_channel(&mut img, 0_usize, 100_u8);
|
|
3125
|
+
* ```
|
|
3126
|
+
* @param {PhotonImage} img
|
|
3127
|
+
* @param {number} channel
|
|
3128
|
+
* @param {number} min_filter
|
|
3129
|
+
*/
|
|
3130
|
+
export function remove_channel(img, channel, min_filter) {
|
|
3131
|
+
_assertClass(img, PhotonImage);
|
|
3132
|
+
wasm.remove_channel(img.__wbg_ptr, channel, min_filter);
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
/**
|
|
3136
|
+
* Remove the Green channel's influence in an image.
|
|
3137
|
+
*
|
|
3138
|
+
* # Arguments
|
|
3139
|
+
* * `img` - A PhotonImage.
|
|
3140
|
+
* * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter.
|
|
3141
|
+
*
|
|
3142
|
+
* # Example
|
|
3143
|
+
*
|
|
3144
|
+
* ```no_run
|
|
3145
|
+
* // For example, to remove the green channel for green channel pixel values less than 50:
|
|
3146
|
+
* use photon_rs::channels::remove_green_channel;
|
|
3147
|
+
* use photon_rs::native::open_image;
|
|
3148
|
+
*
|
|
3149
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3150
|
+
* remove_green_channel(&mut img, 50_u8);
|
|
3151
|
+
* ```
|
|
3152
|
+
* @param {PhotonImage} img
|
|
3153
|
+
* @param {number} min_filter
|
|
3154
|
+
*/
|
|
3155
|
+
export function remove_green_channel(img, min_filter) {
|
|
3156
|
+
_assertClass(img, PhotonImage);
|
|
3157
|
+
wasm.remove_green_channel(img.__wbg_ptr, min_filter);
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3160
|
+
/**
|
|
3161
|
+
* Remove the Red channel's influence in an image.
|
|
3162
|
+
*
|
|
3163
|
+
* # Arguments
|
|
3164
|
+
* * `img` - A PhotonImage.
|
|
3165
|
+
* * `min_filter` - Only remove the channel if the current pixel's channel value is less than this minimum filter.
|
|
3166
|
+
*
|
|
3167
|
+
* # Example
|
|
3168
|
+
*
|
|
3169
|
+
* ```no_run
|
|
3170
|
+
* // For example, to remove the red channel for red channel pixel values less than 50:
|
|
3171
|
+
* use photon_rs::channels::remove_red_channel;
|
|
3172
|
+
* use photon_rs::native::open_image;
|
|
3173
|
+
*
|
|
3174
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3175
|
+
* remove_red_channel(&mut img, 50_u8);
|
|
3176
|
+
* ```
|
|
3177
|
+
* @param {PhotonImage} img
|
|
3178
|
+
* @param {number} min_filter
|
|
3179
|
+
*/
|
|
3180
|
+
export function remove_red_channel(img, min_filter) {
|
|
3181
|
+
_assertClass(img, PhotonImage);
|
|
3182
|
+
wasm.remove_red_channel(img.__wbg_ptr, min_filter);
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
/**
|
|
3186
|
+
* Resample the PhotonImage.
|
|
3187
|
+
*
|
|
3188
|
+
* # Arguments
|
|
3189
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
3190
|
+
* * `dst_width` - Target width.
|
|
3191
|
+
* * `dst_height` - Target height.
|
|
3192
|
+
*
|
|
3193
|
+
* # Example
|
|
3194
|
+
*
|
|
3195
|
+
* ```no_run
|
|
3196
|
+
* // For example, to resample a PhotonImage to 1920x1080 size:
|
|
3197
|
+
* use photon_rs::native::open_image;
|
|
3198
|
+
* use photon_rs::transform::resample;
|
|
3199
|
+
*
|
|
3200
|
+
* let img = open_image("img.jpg").expect("File should open");
|
|
3201
|
+
* let rotated_img = resample(&img, 1920, 1080);
|
|
3202
|
+
* ```
|
|
3203
|
+
* @param {PhotonImage} img
|
|
3204
|
+
* @param {number} dst_width
|
|
3205
|
+
* @param {number} dst_height
|
|
3206
|
+
* @returns {PhotonImage}
|
|
3207
|
+
*/
|
|
3208
|
+
export function resample(img, dst_width, dst_height) {
|
|
3209
|
+
_assertClass(img, PhotonImage);
|
|
3210
|
+
const ret = wasm.resample(img.__wbg_ptr, dst_width, dst_height);
|
|
3211
|
+
return PhotonImage.__wrap(ret);
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
/**
|
|
3215
|
+
* Resize an image.
|
|
3216
|
+
*
|
|
3217
|
+
* # Arguments
|
|
3218
|
+
* * `img` - A PhotonImage.
|
|
3219
|
+
* * `width` - New width.
|
|
3220
|
+
* * `height` - New height.
|
|
3221
|
+
* * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5
|
|
3222
|
+
* @param {PhotonImage} photon_img
|
|
3223
|
+
* @param {number} width
|
|
3224
|
+
* @param {number} height
|
|
3225
|
+
* @param {SamplingFilter} sampling_filter
|
|
3226
|
+
* @returns {PhotonImage}
|
|
3227
|
+
*/
|
|
3228
|
+
export function resize(photon_img, width, height, sampling_filter) {
|
|
3229
|
+
_assertClass(photon_img, PhotonImage);
|
|
3230
|
+
const ret = wasm.resize(photon_img.__wbg_ptr, width, height, sampling_filter);
|
|
3231
|
+
return PhotonImage.__wrap(ret);
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
/**
|
|
3235
|
+
* Resize an image on the web.
|
|
3236
|
+
*
|
|
3237
|
+
* # Arguments
|
|
3238
|
+
* * `img` - A PhotonImage.
|
|
3239
|
+
* * `width` - New width.
|
|
3240
|
+
* * `height` - New height.
|
|
3241
|
+
* * `sampling_filter` - Nearest = 1, Triangle = 2, CatmullRom = 3, Gaussian = 4, Lanczos3 = 5
|
|
3242
|
+
* @param {PhotonImage} photon_img
|
|
3243
|
+
* @param {number} width
|
|
3244
|
+
* @param {number} height
|
|
3245
|
+
* @param {SamplingFilter} sampling_filter
|
|
3246
|
+
* @returns {HTMLCanvasElement}
|
|
3247
|
+
*/
|
|
3248
|
+
export function resize_img_browser(photon_img, width, height, sampling_filter) {
|
|
3249
|
+
_assertClass(photon_img, PhotonImage);
|
|
3250
|
+
const ret = wasm.resize_img_browser(photon_img.__wbg_ptr, width, height, sampling_filter);
|
|
3251
|
+
return ret;
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
/**
|
|
3255
|
+
* Rotate the PhotonImage on an arbitrary angle
|
|
3256
|
+
* A rotated PhotonImage is returned.
|
|
3257
|
+
*
|
|
3258
|
+
* # Arguments
|
|
3259
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
3260
|
+
* * `angle` - Rotation angle in degrees.
|
|
3261
|
+
*
|
|
3262
|
+
* # Example
|
|
3263
|
+
*
|
|
3264
|
+
* ```no_run
|
|
3265
|
+
* // For example, to rotate a PhotonImage by 30 degrees:
|
|
3266
|
+
* use photon_rs::native::open_image;
|
|
3267
|
+
* use photon_rs::transform::rotate;
|
|
3268
|
+
*
|
|
3269
|
+
* let img = open_image("img.jpg").expect("File should open");
|
|
3270
|
+
* let rotated_img = rotate(&img, 30.0);
|
|
3271
|
+
* ```
|
|
3272
|
+
* @param {PhotonImage} photon_img
|
|
3273
|
+
* @param {number} angle
|
|
3274
|
+
* @returns {PhotonImage}
|
|
3275
|
+
*/
|
|
3276
|
+
export function rotate(photon_img, angle) {
|
|
3277
|
+
_assertClass(photon_img, PhotonImage);
|
|
3278
|
+
const ret = wasm.rotate(photon_img.__wbg_ptr, angle);
|
|
3279
|
+
return PhotonImage.__wrap(ret);
|
|
3280
|
+
}
|
|
3281
|
+
|
|
3282
|
+
/**
|
|
3283
|
+
* ! [temp] Check if WASM is supported.
|
|
3284
|
+
*/
|
|
3285
|
+
export function run() {
|
|
3286
|
+
const ret = wasm.run();
|
|
3287
|
+
if (ret[1]) {
|
|
3288
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
/**
|
|
3293
|
+
* Solarization on the Red and Blue channels.
|
|
3294
|
+
*
|
|
3295
|
+
* # Arguments
|
|
3296
|
+
* * `img` - A PhotonImage.
|
|
3297
|
+
* # Example
|
|
3298
|
+
*
|
|
3299
|
+
* ```no_run
|
|
3300
|
+
* use photon_rs::filters::ryo;
|
|
3301
|
+
* use photon_rs::native::open_image;
|
|
3302
|
+
*
|
|
3303
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3304
|
+
* ryo(&mut img);
|
|
3305
|
+
* ```
|
|
3306
|
+
* @param {PhotonImage} photon_image
|
|
3307
|
+
*/
|
|
3308
|
+
export function ryo(photon_image) {
|
|
3309
|
+
_assertClass(photon_image, PhotonImage);
|
|
3310
|
+
wasm.ryo(photon_image.__wbg_ptr);
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
/**
|
|
3314
|
+
* Increase the image's saturation by converting each pixel's colour to the HSL colour space
|
|
3315
|
+
* and increasing the colour's saturation.
|
|
3316
|
+
* # Arguments
|
|
3317
|
+
* * `img` - A PhotonImage.
|
|
3318
|
+
* * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by.
|
|
3319
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
3320
|
+
* Increasing saturation by 80% would be represented by a `level` of 0.8
|
|
3321
|
+
*
|
|
3322
|
+
* # Example
|
|
3323
|
+
* ```no_run
|
|
3324
|
+
* // For example to increase saturation by 10% in the HSL colour space:
|
|
3325
|
+
* use photon_rs::colour_spaces::saturate_hsl;
|
|
3326
|
+
* use photon_rs::native::open_image;
|
|
3327
|
+
*
|
|
3328
|
+
* // Open the image. A PhotonImage is returned.
|
|
3329
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3330
|
+
* saturate_hsl(&mut img, 0.1_f32);
|
|
3331
|
+
* ```
|
|
3332
|
+
* @param {PhotonImage} img
|
|
3333
|
+
* @param {number} level
|
|
3334
|
+
*/
|
|
3335
|
+
export function saturate_hsl(img, level) {
|
|
3336
|
+
_assertClass(img, PhotonImage);
|
|
3337
|
+
wasm.saturate_hsl(img.__wbg_ptr, level);
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* Increase the image's saturation in the HSLuv colour space.
|
|
3342
|
+
* # Arguments
|
|
3343
|
+
* * `img` - A PhotonImage.
|
|
3344
|
+
* * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by.
|
|
3345
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
3346
|
+
* Increasing saturation by 80% would be represented by a `level` of 0.8
|
|
3347
|
+
*
|
|
3348
|
+
* # Example
|
|
3349
|
+
* ```no_run
|
|
3350
|
+
* // For example to increase saturation by 40% in the HSLuv colour space:
|
|
3351
|
+
* use photon_rs::colour_spaces::saturate_hsluv;
|
|
3352
|
+
* use photon_rs::native::open_image;
|
|
3353
|
+
*
|
|
3354
|
+
* // Open the image. A PhotonImage is returned.
|
|
3355
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3356
|
+
* saturate_hsluv(&mut img, 0.4_f32);
|
|
3357
|
+
* ```
|
|
3358
|
+
* @param {PhotonImage} img
|
|
3359
|
+
* @param {number} level
|
|
3360
|
+
*/
|
|
3361
|
+
export function saturate_hsluv(img, level) {
|
|
3362
|
+
_assertClass(img, PhotonImage);
|
|
3363
|
+
wasm.saturate_hsluv(img.__wbg_ptr, level);
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
/**
|
|
3367
|
+
* Increase the image's saturation in the HSV colour space.
|
|
3368
|
+
* # Arguments
|
|
3369
|
+
* * `img` - A PhotonImage.
|
|
3370
|
+
* * `level` - Float value from 0 to 1 representing the level by which to increase the saturation by.
|
|
3371
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
3372
|
+
* Increasing saturation by 80% would be represented by a `level` of 0.8
|
|
3373
|
+
*
|
|
3374
|
+
* # Example
|
|
3375
|
+
* ```no_run
|
|
3376
|
+
* // For example to increase saturation by 30% in the HSV colour space:
|
|
3377
|
+
* use photon_rs::colour_spaces::saturate_hsv;
|
|
3378
|
+
* use photon_rs::native::open_image;
|
|
3379
|
+
*
|
|
3380
|
+
* // Open the image. A PhotonImage is returned.
|
|
3381
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3382
|
+
* saturate_hsv(&mut img, 0.3_f32);
|
|
3383
|
+
* ```
|
|
3384
|
+
* @param {PhotonImage} img
|
|
3385
|
+
* @param {number} level
|
|
3386
|
+
*/
|
|
3387
|
+
export function saturate_hsv(img, level) {
|
|
3388
|
+
_assertClass(img, PhotonImage);
|
|
3389
|
+
wasm.saturate_hsv(img.__wbg_ptr, level);
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
/**
|
|
3393
|
+
* Increase the image's saturation in the LCh colour space.
|
|
3394
|
+
* # Arguments
|
|
3395
|
+
* * `img` - A PhotonImage.
|
|
3396
|
+
* * `level` - Float value from 0 to 1 representing the level to which to increase the saturation by.
|
|
3397
|
+
* The `level` must be from 0 to 1 in floating-point, `f32` format.
|
|
3398
|
+
* Increasing saturation by 80% would be represented by a `level` of 0.8
|
|
3399
|
+
*
|
|
3400
|
+
* # Example
|
|
3401
|
+
* ```no_run
|
|
3402
|
+
* // For example to increase saturation by 40% in the Lch colour space:
|
|
3403
|
+
* use photon_rs::colour_spaces::saturate_lch;
|
|
3404
|
+
* use photon_rs::native::open_image;
|
|
3405
|
+
*
|
|
3406
|
+
* // Open the image. A PhotonImage is returned.
|
|
3407
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3408
|
+
* saturate_lch(&mut img, 0.4_f32);
|
|
3409
|
+
* ```
|
|
3410
|
+
* @param {PhotonImage} img
|
|
3411
|
+
* @param {number} level
|
|
3412
|
+
*/
|
|
3413
|
+
export function saturate_lch(img, level) {
|
|
3414
|
+
_assertClass(img, PhotonImage);
|
|
3415
|
+
wasm.saturate_lch(img.__wbg_ptr, level);
|
|
3416
|
+
}
|
|
3417
|
+
|
|
3418
|
+
/**
|
|
3419
|
+
* Resize image using seam carver.
|
|
3420
|
+
* Resize only if new dimensions are smaller, than original image.
|
|
3421
|
+
* # NOTE: This is still experimental feature, and pretty slow.
|
|
3422
|
+
*
|
|
3423
|
+
* # Arguments
|
|
3424
|
+
* * `img` - A PhotonImage.
|
|
3425
|
+
* * `width` - New width.
|
|
3426
|
+
* * `height` - New height.
|
|
3427
|
+
*
|
|
3428
|
+
* # Example
|
|
3429
|
+
*
|
|
3430
|
+
* ```no_run
|
|
3431
|
+
* // For example, resize image using seam carver:
|
|
3432
|
+
* use photon_rs::native::open_image;
|
|
3433
|
+
* use photon_rs::transform::seam_carve;
|
|
3434
|
+
* use photon_rs::PhotonImage;
|
|
3435
|
+
*
|
|
3436
|
+
* let img = open_image("img.jpg").expect("File should open");
|
|
3437
|
+
* let result: PhotonImage = seam_carve(&img, 100_u32, 100_u32);
|
|
3438
|
+
* ```
|
|
3439
|
+
* @param {PhotonImage} img
|
|
3440
|
+
* @param {number} width
|
|
3441
|
+
* @param {number} height
|
|
3442
|
+
* @returns {PhotonImage}
|
|
3443
|
+
*/
|
|
3444
|
+
export function seam_carve(img, width, height) {
|
|
3445
|
+
_assertClass(img, PhotonImage);
|
|
3446
|
+
const ret = wasm.seam_carve(img.__wbg_ptr, width, height);
|
|
3447
|
+
return PhotonImage.__wrap(ret);
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
/**
|
|
3451
|
+
* Selectively change pixel colours which are similar to the reference colour provided.
|
|
3452
|
+
*
|
|
3453
|
+
* Similarity between two colours is calculated via the CIE76 formula.
|
|
3454
|
+
* Only changes the color of a pixel if its similarity to the reference colour is within the range in the algorithm.
|
|
3455
|
+
* For example, with this function, a user can change the color of all blue pixels by mixing them with red by 10%.
|
|
3456
|
+
* # Arguments
|
|
3457
|
+
* * `photon_image` - A PhotonImage.
|
|
3458
|
+
* * `ref_color` - The `RGB` value of the reference color (to be compared to)
|
|
3459
|
+
* * `new_color` - The `RGB` value of the new color (to be mixed with the matched pixels)
|
|
3460
|
+
* * `fraction` - The amount of mixing the new colour with the matched pixels
|
|
3461
|
+
*
|
|
3462
|
+
* # Example
|
|
3463
|
+
*
|
|
3464
|
+
* ```no_run
|
|
3465
|
+
* // For example, to only change the color of pixels that are similar to the RGB value RGB{200, 120, 30} by mixing RGB{30, 120, 200} with 25%:
|
|
3466
|
+
* use photon_rs::Rgb;
|
|
3467
|
+
* use photon_rs::channels::selective_color_convert;
|
|
3468
|
+
* use photon_rs::native::open_image;
|
|
3469
|
+
*
|
|
3470
|
+
* let ref_color = Rgb::new(200, 120, 30);
|
|
3471
|
+
* let new_color = Rgb::new(30, 120, 200);
|
|
3472
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3473
|
+
* selective_color_convert(&mut img, ref_color, new_color, 0.25);
|
|
3474
|
+
* ```
|
|
3475
|
+
* @param {PhotonImage} photon_image
|
|
3476
|
+
* @param {Rgb} ref_color
|
|
3477
|
+
* @param {Rgb} new_color
|
|
3478
|
+
* @param {number} fraction
|
|
3479
|
+
*/
|
|
3480
|
+
export function selective_color_convert(photon_image, ref_color, new_color, fraction) {
|
|
3481
|
+
_assertClass(photon_image, PhotonImage);
|
|
3482
|
+
_assertClass(ref_color, Rgb);
|
|
3483
|
+
var ptr0 = ref_color.__destroy_into_raw();
|
|
3484
|
+
_assertClass(new_color, Rgb);
|
|
3485
|
+
var ptr1 = new_color.__destroy_into_raw();
|
|
3486
|
+
wasm.selective_color_convert(photon_image.__wbg_ptr, ptr0, ptr1, fraction);
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3489
|
+
/**
|
|
3490
|
+
* Selectively desaturate pixel colours which are similar to the reference colour provided.
|
|
3491
|
+
*
|
|
3492
|
+
* Similarity between two colours is calculated via the CIE76 formula.
|
|
3493
|
+
* Only desaturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm.
|
|
3494
|
+
* For example, if a user wishes all pixels that are blue to be desaturated by 0.1, they can selectively specify only the blue pixels to be changed.
|
|
3495
|
+
* # Arguments
|
|
3496
|
+
* * `img` - A PhotonImage.
|
|
3497
|
+
* * `ref_color` - The `RGB` value of the reference color (to be compared to)
|
|
3498
|
+
* * `amt` - The amount of desaturate the colour by.
|
|
3499
|
+
*
|
|
3500
|
+
* # Example
|
|
3501
|
+
*
|
|
3502
|
+
* ```no_run
|
|
3503
|
+
* // For example, to only desaturate the pixels that are similar to the RGB value RGB{20, 40, 60}:
|
|
3504
|
+
* use photon_rs::Rgb;
|
|
3505
|
+
* use photon_rs::channels::selective_desaturate;
|
|
3506
|
+
* use photon_rs::native::open_image;
|
|
3507
|
+
*
|
|
3508
|
+
* let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
|
|
3509
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3510
|
+
* selective_desaturate(&mut img, ref_color, 0.1_f32);
|
|
3511
|
+
* ```
|
|
3512
|
+
* @param {PhotonImage} img
|
|
3513
|
+
* @param {Rgb} ref_color
|
|
3514
|
+
* @param {number} amt
|
|
3515
|
+
*/
|
|
3516
|
+
export function selective_desaturate(img, ref_color, amt) {
|
|
3517
|
+
_assertClass(img, PhotonImage);
|
|
3518
|
+
_assertClass(ref_color, Rgb);
|
|
3519
|
+
var ptr0 = ref_color.__destroy_into_raw();
|
|
3520
|
+
wasm.selective_desaturate(img.__wbg_ptr, ptr0, amt);
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
/**
|
|
3524
|
+
* Selectively changes a pixel to greyscale if it is *not* visually similar or close to the colour specified.
|
|
3525
|
+
* Only changes the colour of a pixel if its RGB values are within a specified range.
|
|
3526
|
+
*
|
|
3527
|
+
* (Similarity between two colours is calculated via the CIE76 formula.)
|
|
3528
|
+
* For example, if a user wishes all pixels that are *NOT* blue to be displayed in greyscale, they can selectively specify only the blue pixels to be
|
|
3529
|
+
* kept in the photo.
|
|
3530
|
+
* # Arguments
|
|
3531
|
+
* * `img` - A PhotonImage.
|
|
3532
|
+
* * `ref_color` - The `RGB` value of the reference color (to be compared to)
|
|
3533
|
+
*
|
|
3534
|
+
* # Example
|
|
3535
|
+
*
|
|
3536
|
+
* ```no_run
|
|
3537
|
+
* // For example, to greyscale all pixels that are *not* visually similar to the RGB colour RGB{20, 40, 60}:
|
|
3538
|
+
* use photon_rs::Rgb;
|
|
3539
|
+
* use photon_rs::channels::selective_greyscale;
|
|
3540
|
+
* use photon_rs::native::open_image;
|
|
3541
|
+
*
|
|
3542
|
+
* let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
|
|
3543
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3544
|
+
* selective_greyscale(img, ref_color);
|
|
3545
|
+
* ```
|
|
3546
|
+
* @param {PhotonImage} photon_image
|
|
3547
|
+
* @param {Rgb} ref_color
|
|
3548
|
+
*/
|
|
3549
|
+
export function selective_greyscale(photon_image, ref_color) {
|
|
3550
|
+
_assertClass(photon_image, PhotonImage);
|
|
3551
|
+
var ptr0 = photon_image.__destroy_into_raw();
|
|
3552
|
+
_assertClass(ref_color, Rgb);
|
|
3553
|
+
var ptr1 = ref_color.__destroy_into_raw();
|
|
3554
|
+
wasm.selective_greyscale(ptr0, ptr1);
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
/**
|
|
3558
|
+
* Selective hue rotation.
|
|
3559
|
+
*
|
|
3560
|
+
* Only rotate the hue of a pixel if its RGB values are within a specified range.
|
|
3561
|
+
* This function only rotates a pixel's hue to another if it is visually similar to the colour specified.
|
|
3562
|
+
* For example, if a user wishes all pixels that are blue to be changed to red, they can selectively specify only the blue pixels to be changed.
|
|
3563
|
+
* # Arguments
|
|
3564
|
+
* * `img` - A PhotonImage.
|
|
3565
|
+
* * `ref_color` - The `RGB` value of the reference color (to be compared to)
|
|
3566
|
+
* * `degrees` - The amount of degrees to hue rotate by.
|
|
3567
|
+
*
|
|
3568
|
+
* # Example
|
|
3569
|
+
*
|
|
3570
|
+
* ```no_run
|
|
3571
|
+
* // For example, to only rotate the pixels that are of RGB value RGB{20, 40, 60}:
|
|
3572
|
+
* use photon_rs::Rgb;
|
|
3573
|
+
* use photon_rs::channels::selective_hue_rotate;
|
|
3574
|
+
* use photon_rs::native::open_image;
|
|
3575
|
+
*
|
|
3576
|
+
* let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
|
|
3577
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3578
|
+
* selective_hue_rotate(&mut img, ref_color, 180_f32);
|
|
3579
|
+
* ```
|
|
3580
|
+
* @param {PhotonImage} photon_image
|
|
3581
|
+
* @param {Rgb} ref_color
|
|
3582
|
+
* @param {number} degrees
|
|
3583
|
+
*/
|
|
3584
|
+
export function selective_hue_rotate(photon_image, ref_color, degrees) {
|
|
3585
|
+
_assertClass(photon_image, PhotonImage);
|
|
3586
|
+
_assertClass(ref_color, Rgb);
|
|
3587
|
+
var ptr0 = ref_color.__destroy_into_raw();
|
|
3588
|
+
wasm.selective_hue_rotate(photon_image.__wbg_ptr, ptr0, degrees);
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
/**
|
|
3592
|
+
* Selectively lighten an image.
|
|
3593
|
+
*
|
|
3594
|
+
* Only lighten the hue of a pixel if its colour matches or is similar to the RGB colour specified.
|
|
3595
|
+
* For example, if a user wishes all pixels that are blue to be lightened, they can selectively specify only the blue pixels to be changed.
|
|
3596
|
+
* # Arguments
|
|
3597
|
+
* * `img` - A PhotonImage.
|
|
3598
|
+
* * `ref_color` - The `RGB` value of the reference color (to be compared to)
|
|
3599
|
+
* * `amt` - The level from 0 to 1 to lighten the hue by. Increasing by 10% would have an `amt` of 0.1
|
|
3600
|
+
*
|
|
3601
|
+
* # Example
|
|
3602
|
+
*
|
|
3603
|
+
* ```no_run
|
|
3604
|
+
* // For example, to only lighten the pixels that are of or similar to RGB value RGB{20, 40, 60}:
|
|
3605
|
+
* use photon_rs::Rgb;
|
|
3606
|
+
* use photon_rs::channels::selective_lighten;
|
|
3607
|
+
* use photon_rs::native::open_image;
|
|
3608
|
+
*
|
|
3609
|
+
* let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
|
|
3610
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3611
|
+
* selective_lighten(&mut img, ref_color, 0.2_f32);
|
|
3612
|
+
* ```
|
|
3613
|
+
* @param {PhotonImage} img
|
|
3614
|
+
* @param {Rgb} ref_color
|
|
3615
|
+
* @param {number} amt
|
|
3616
|
+
*/
|
|
3617
|
+
export function selective_lighten(img, ref_color, amt) {
|
|
3618
|
+
_assertClass(img, PhotonImage);
|
|
3619
|
+
_assertClass(ref_color, Rgb);
|
|
3620
|
+
var ptr0 = ref_color.__destroy_into_raw();
|
|
3621
|
+
wasm.selective_lighten(img.__wbg_ptr, ptr0, amt);
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
/**
|
|
3625
|
+
* Selectively saturate pixel colours which are similar to the reference colour provided.
|
|
3626
|
+
*
|
|
3627
|
+
* Similarity between two colours is calculated via the CIE76 formula.
|
|
3628
|
+
* Only saturates the hue of a pixel if its similarity to the reference colour is within the range in the algorithm.
|
|
3629
|
+
* For example, if a user wishes all pixels that are blue to have an increase in saturation by 10%, they can selectively specify only the blue pixels to be changed.
|
|
3630
|
+
* # Arguments
|
|
3631
|
+
* * `img` - A PhotonImage.
|
|
3632
|
+
* * `ref_color` - The `RGB` value of the reference color (to be compared to)
|
|
3633
|
+
* * `amt` - The amount of saturate the colour by.
|
|
3634
|
+
*
|
|
3635
|
+
* # Example
|
|
3636
|
+
*
|
|
3637
|
+
* ```no_run
|
|
3638
|
+
* // For example, to only increase the saturation of pixels that are similar to the RGB value RGB{20, 40, 60}:
|
|
3639
|
+
* use photon_rs::Rgb;
|
|
3640
|
+
* use photon_rs::channels::selective_saturate;
|
|
3641
|
+
* use photon_rs::native::open_image;
|
|
3642
|
+
*
|
|
3643
|
+
* let ref_color = Rgb::new(20_u8, 40_u8, 60_u8);
|
|
3644
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3645
|
+
* selective_saturate(&mut img, ref_color, 0.1_f32);
|
|
3646
|
+
* ```
|
|
3647
|
+
* @param {PhotonImage} img
|
|
3648
|
+
* @param {Rgb} ref_color
|
|
3649
|
+
* @param {number} amt
|
|
3650
|
+
*/
|
|
3651
|
+
export function selective_saturate(img, ref_color, amt) {
|
|
3652
|
+
_assertClass(img, PhotonImage);
|
|
3653
|
+
_assertClass(ref_color, Rgb);
|
|
3654
|
+
var ptr0 = ref_color.__destroy_into_raw();
|
|
3655
|
+
wasm.selective_saturate(img.__wbg_ptr, ptr0, amt);
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
/**
|
|
3659
|
+
* Convert an image to sepia.
|
|
3660
|
+
*
|
|
3661
|
+
* # Arguments
|
|
3662
|
+
* * `photon_image` - A PhotonImage.
|
|
3663
|
+
* # Example
|
|
3664
|
+
*
|
|
3665
|
+
* ```no_run
|
|
3666
|
+
* // For example, to sepia an image of type `PhotonImage`:
|
|
3667
|
+
* use photon_rs::monochrome::sepia;
|
|
3668
|
+
* use photon_rs::native::open_image;
|
|
3669
|
+
*
|
|
3670
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3671
|
+
* sepia(&mut img);
|
|
3672
|
+
* ```
|
|
3673
|
+
* @param {PhotonImage} img
|
|
3674
|
+
*/
|
|
3675
|
+
export function sepia(img) {
|
|
3676
|
+
_assertClass(img, PhotonImage);
|
|
3677
|
+
wasm.sepia(img.__wbg_ptr);
|
|
3678
|
+
}
|
|
3679
|
+
|
|
3680
|
+
/**
|
|
3681
|
+
* Sharpen an image.
|
|
3682
|
+
*
|
|
3683
|
+
* # Arguments
|
|
3684
|
+
* * `img` - A PhotonImage.
|
|
3685
|
+
*
|
|
3686
|
+
* # Example
|
|
3687
|
+
*
|
|
3688
|
+
* ```no_run
|
|
3689
|
+
* // For example, to sharpen an image:
|
|
3690
|
+
* use photon_rs::conv::sharpen;
|
|
3691
|
+
* use photon_rs::native::open_image;
|
|
3692
|
+
*
|
|
3693
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3694
|
+
* sharpen(&mut img);
|
|
3695
|
+
* ```
|
|
3696
|
+
* Adds a constant to a select R, G, or B channel's value.
|
|
3697
|
+
* @param {PhotonImage} photon_image
|
|
3698
|
+
*/
|
|
3699
|
+
export function sharpen(photon_image) {
|
|
3700
|
+
_assertClass(photon_image, PhotonImage);
|
|
3701
|
+
wasm.sharpen(photon_image.__wbg_ptr);
|
|
3702
|
+
}
|
|
3703
|
+
|
|
3704
|
+
/**
|
|
3705
|
+
* Shear the image along the X axis.
|
|
3706
|
+
* A sheared PhotonImage is returned.
|
|
3707
|
+
*
|
|
3708
|
+
* # Arguments
|
|
3709
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
3710
|
+
* * `shear` - Amount to shear.
|
|
3711
|
+
*
|
|
3712
|
+
* # Example
|
|
3713
|
+
*
|
|
3714
|
+
* ```no_run
|
|
3715
|
+
* // For example, to shear an image by 0.5:
|
|
3716
|
+
* use photon_rs::native::open_image;
|
|
3717
|
+
* use photon_rs::transform::shearx;
|
|
3718
|
+
*
|
|
3719
|
+
* let img = open_image("img.jpg").expect("File should open");
|
|
3720
|
+
* let sheared_img = shearx(&img, 0.5);
|
|
3721
|
+
* ```
|
|
3722
|
+
* @param {PhotonImage} photon_img
|
|
3723
|
+
* @param {number} shear
|
|
3724
|
+
* @returns {PhotonImage}
|
|
3725
|
+
*/
|
|
3726
|
+
export function shearx(photon_img, shear) {
|
|
3727
|
+
_assertClass(photon_img, PhotonImage);
|
|
3728
|
+
const ret = wasm.shearx(photon_img.__wbg_ptr, shear);
|
|
3729
|
+
return PhotonImage.__wrap(ret);
|
|
3730
|
+
}
|
|
3731
|
+
|
|
3732
|
+
/**
|
|
3733
|
+
* Shear the image along the Y axis.
|
|
3734
|
+
* A sheared PhotonImage is returned.
|
|
3735
|
+
*
|
|
3736
|
+
* # Arguments
|
|
3737
|
+
* * `img` - A PhotonImage. See the PhotonImage struct for details.
|
|
3738
|
+
* * `shear` - Amount to shear.
|
|
3739
|
+
*
|
|
3740
|
+
* # Example
|
|
3741
|
+
*
|
|
3742
|
+
* ```no_run
|
|
3743
|
+
* // For example, to shear an image by 0.5:
|
|
3744
|
+
* use photon_rs::native::open_image;
|
|
3745
|
+
* use photon_rs::transform::sheary;
|
|
3746
|
+
*
|
|
3747
|
+
* let img = open_image("img.jpg").expect("File should open");
|
|
3748
|
+
* let sheared_img = sheary(&img, 0.5);
|
|
3749
|
+
* ```
|
|
3750
|
+
* @param {PhotonImage} photon_img
|
|
3751
|
+
* @param {number} shear
|
|
3752
|
+
* @returns {PhotonImage}
|
|
3753
|
+
*/
|
|
3754
|
+
export function sheary(photon_img, shear) {
|
|
3755
|
+
_assertClass(photon_img, PhotonImage);
|
|
3756
|
+
const ret = wasm.sheary(photon_img.__wbg_ptr, shear);
|
|
3757
|
+
return PhotonImage.__wrap(ret);
|
|
3758
|
+
}
|
|
3759
|
+
|
|
3760
|
+
/**
|
|
3761
|
+
* Convert an image to grayscale by setting a pixel's 3 RGB values to a chosen channel's value.
|
|
3762
|
+
*
|
|
3763
|
+
* # Arguments
|
|
3764
|
+
* * `photon_image` - A PhotonImage.
|
|
3765
|
+
* * `channel` - A usize representing the channel from 0 to 2. O represents the Red channel, 1 the Green channel, and 2 the Blue channel.
|
|
3766
|
+
*
|
|
3767
|
+
* # Example
|
|
3768
|
+
* To grayscale using only values from the Red channel:
|
|
3769
|
+
* ```no_run
|
|
3770
|
+
* use photon_rs::monochrome::single_channel_grayscale;
|
|
3771
|
+
* use photon_rs::native::open_image;
|
|
3772
|
+
*
|
|
3773
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3774
|
+
* single_channel_grayscale(&mut img, 0_usize);
|
|
3775
|
+
* ```
|
|
3776
|
+
* @param {PhotonImage} photon_image
|
|
3777
|
+
* @param {number} channel
|
|
3778
|
+
*/
|
|
3779
|
+
export function single_channel_grayscale(photon_image, channel) {
|
|
3780
|
+
_assertClass(photon_image, PhotonImage);
|
|
3781
|
+
wasm.single_channel_grayscale(photon_image.__wbg_ptr, channel);
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
/**
|
|
3785
|
+
* Apply a global Sobel filter to an image
|
|
3786
|
+
*
|
|
3787
|
+
* Each pixel is calculated as the magnitude of the horizontal and vertical components of the Sobel filter,
|
|
3788
|
+
* ie if X is the horizontal sobel and Y is the vertical, for each pixel, we calculate sqrt(X^2 + Y^2)
|
|
3789
|
+
*
|
|
3790
|
+
* # Arguments
|
|
3791
|
+
* * `img` - A PhotonImage.
|
|
3792
|
+
*
|
|
3793
|
+
* # Example
|
|
3794
|
+
*
|
|
3795
|
+
* ```no_run
|
|
3796
|
+
* // For example, to apply a global Sobel filter:
|
|
3797
|
+
* use photon_rs::conv::sobel_global;
|
|
3798
|
+
* use photon_rs::native::open_image;
|
|
3799
|
+
*
|
|
3800
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3801
|
+
* sobel_global(&mut img);
|
|
3802
|
+
* ```
|
|
3803
|
+
* @param {PhotonImage} photon_image
|
|
3804
|
+
*/
|
|
3805
|
+
export function sobel_global(photon_image) {
|
|
3806
|
+
_assertClass(photon_image, PhotonImage);
|
|
3807
|
+
wasm.sobel_global(photon_image.__wbg_ptr);
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
/**
|
|
3811
|
+
* Apply a horizontal Sobel filter to an image.
|
|
3812
|
+
*
|
|
3813
|
+
* # Arguments
|
|
3814
|
+
* * `img` - A PhotonImage.
|
|
3815
|
+
*
|
|
3816
|
+
* # Example
|
|
3817
|
+
*
|
|
3818
|
+
* ```no_run
|
|
3819
|
+
* // For example, to apply a horizontal Sobel filter:
|
|
3820
|
+
* use photon_rs::conv::sobel_horizontal;
|
|
3821
|
+
* use photon_rs::native::open_image;
|
|
3822
|
+
*
|
|
3823
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3824
|
+
* sobel_horizontal(&mut img);
|
|
3825
|
+
* ```
|
|
3826
|
+
* @param {PhotonImage} photon_image
|
|
3827
|
+
*/
|
|
3828
|
+
export function sobel_horizontal(photon_image) {
|
|
3829
|
+
_assertClass(photon_image, PhotonImage);
|
|
3830
|
+
wasm.sobel_horizontal(photon_image.__wbg_ptr);
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
/**
|
|
3834
|
+
* Apply a vertical Sobel filter to an image.
|
|
3835
|
+
*
|
|
3836
|
+
* # Arguments
|
|
3837
|
+
* * `img` - A PhotonImage.
|
|
3838
|
+
*
|
|
3839
|
+
* # Example
|
|
3840
|
+
*
|
|
3841
|
+
* ```no_run
|
|
3842
|
+
* // For example, to apply a vertical Sobel filter:
|
|
3843
|
+
* use photon_rs::conv::sobel_vertical;
|
|
3844
|
+
* use photon_rs::native::open_image;
|
|
3845
|
+
*
|
|
3846
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3847
|
+
* sobel_vertical(&mut img);
|
|
3848
|
+
* ```
|
|
3849
|
+
* @param {PhotonImage} photon_image
|
|
3850
|
+
*/
|
|
3851
|
+
export function sobel_vertical(photon_image) {
|
|
3852
|
+
_assertClass(photon_image, PhotonImage);
|
|
3853
|
+
wasm.sobel_vertical(photon_image.__wbg_ptr);
|
|
3854
|
+
}
|
|
3855
|
+
|
|
3856
|
+
/**
|
|
3857
|
+
* Applies a solarizing effect to an image.
|
|
3858
|
+
*
|
|
3859
|
+
* # Arguments
|
|
3860
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
3861
|
+
* # Example
|
|
3862
|
+
*
|
|
3863
|
+
* ```no_run
|
|
3864
|
+
* // For example, to colorize an image of type `PhotonImage`:
|
|
3865
|
+
* use photon_rs::effects::solarize;
|
|
3866
|
+
* use photon_rs::native::open_image;
|
|
3867
|
+
*
|
|
3868
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3869
|
+
* solarize(&mut img);
|
|
3870
|
+
* ```
|
|
3871
|
+
* @param {PhotonImage} photon_image
|
|
3872
|
+
*/
|
|
3873
|
+
export function solarize(photon_image) {
|
|
3874
|
+
_assertClass(photon_image, PhotonImage);
|
|
3875
|
+
wasm.solarize(photon_image.__wbg_ptr);
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
/**
|
|
3879
|
+
* Applies a solarizing effect to an image and returns the resulting PhotonImage.
|
|
3880
|
+
*
|
|
3881
|
+
* # Arguments
|
|
3882
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
3883
|
+
* # Example
|
|
3884
|
+
*
|
|
3885
|
+
* ```no_run
|
|
3886
|
+
* // For example, to solarize "retimg" an image of type `PhotonImage`:
|
|
3887
|
+
* use photon_rs::effects::solarize_retimg;
|
|
3888
|
+
* use photon_rs::native::open_image;
|
|
3889
|
+
* use photon_rs::PhotonImage;
|
|
3890
|
+
*
|
|
3891
|
+
* let img = open_image("img.jpg").expect("File should open");
|
|
3892
|
+
* let result: PhotonImage = solarize_retimg(&img);
|
|
3893
|
+
* ```
|
|
3894
|
+
* @param {PhotonImage} photon_image
|
|
3895
|
+
* @returns {PhotonImage}
|
|
3896
|
+
*/
|
|
3897
|
+
export function solarize_retimg(photon_image) {
|
|
3898
|
+
_assertClass(photon_image, PhotonImage);
|
|
3899
|
+
const ret = wasm.solarize_retimg(photon_image.__wbg_ptr);
|
|
3900
|
+
return PhotonImage.__wrap(ret);
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
/**
|
|
3904
|
+
* Swap two channels.
|
|
3905
|
+
*
|
|
3906
|
+
* # Arguments
|
|
3907
|
+
* * `img` - A PhotonImage.
|
|
3908
|
+
* * `channel1` - An index from 0 to 2, representing the Red, Green or Blue channels respectively. Red would be represented by 0, Green by 1, and Blue by 2.
|
|
3909
|
+
* * `channel2` - An index from 0 to 2, representing the Red, Green or Blue channels respectively. Same as above.
|
|
3910
|
+
*
|
|
3911
|
+
* # Example
|
|
3912
|
+
*
|
|
3913
|
+
* ```no_run
|
|
3914
|
+
* // For example, to swap the values of the Red channel with the values of the Blue channel:
|
|
3915
|
+
* use photon_rs::channels::swap_channels;
|
|
3916
|
+
* use photon_rs::native::open_image;
|
|
3917
|
+
*
|
|
3918
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3919
|
+
* swap_channels(&mut img, 0_usize, 2_usize);
|
|
3920
|
+
* ```
|
|
3921
|
+
* @param {PhotonImage} img
|
|
3922
|
+
* @param {number} channel1
|
|
3923
|
+
* @param {number} channel2
|
|
3924
|
+
*/
|
|
3925
|
+
export function swap_channels(img, channel1, channel2) {
|
|
3926
|
+
_assertClass(img, PhotonImage);
|
|
3927
|
+
wasm.swap_channels(img.__wbg_ptr, channel1, channel2);
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
/**
|
|
3931
|
+
* Threshold an image using a standard thresholding algorithm.
|
|
3932
|
+
*
|
|
3933
|
+
* # Arguments
|
|
3934
|
+
* * `photon_image` - A PhotonImage.
|
|
3935
|
+
* * `threshold` - The amount the image should be thresholded by from 0 to 255.
|
|
3936
|
+
* # Example
|
|
3937
|
+
*
|
|
3938
|
+
* ```no_run
|
|
3939
|
+
* // For example, to threshold an image of type `PhotonImage`:
|
|
3940
|
+
* use photon_rs::monochrome::threshold;
|
|
3941
|
+
* use photon_rs::native::open_image;
|
|
3942
|
+
*
|
|
3943
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3944
|
+
* threshold(&mut img, 30_u32);
|
|
3945
|
+
* ```
|
|
3946
|
+
* @param {PhotonImage} img
|
|
3947
|
+
* @param {number} threshold
|
|
3948
|
+
*/
|
|
3949
|
+
export function threshold(img, threshold) {
|
|
3950
|
+
_assertClass(img, PhotonImage);
|
|
3951
|
+
wasm.threshold(img.__wbg_ptr, threshold);
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
/**
|
|
3955
|
+
* Tint an image by adding an offset to averaged RGB channel values.
|
|
3956
|
+
*
|
|
3957
|
+
* # Arguments
|
|
3958
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
3959
|
+
* * `r_offset` - The amount the R channel should be incremented by.
|
|
3960
|
+
* * `g_offset` - The amount the G channel should be incremented by.
|
|
3961
|
+
* * `b_offset` - The amount the B channel should be incremented by.
|
|
3962
|
+
* # Example
|
|
3963
|
+
*
|
|
3964
|
+
* ```no_run
|
|
3965
|
+
* // For example, to tint an image of type `PhotonImage`:
|
|
3966
|
+
* use photon_rs::effects::tint;
|
|
3967
|
+
* use photon_rs::native::open_image;
|
|
3968
|
+
*
|
|
3969
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
3970
|
+
* tint(&mut img, 10_u32, 20_u32, 15_u32);
|
|
3971
|
+
* ```
|
|
3972
|
+
* @param {PhotonImage} photon_image
|
|
3973
|
+
* @param {number} r_offset
|
|
3974
|
+
* @param {number} g_offset
|
|
3975
|
+
* @param {number} b_offset
|
|
3976
|
+
*/
|
|
3977
|
+
export function tint(photon_image, r_offset, g_offset, b_offset) {
|
|
3978
|
+
_assertClass(photon_image, PhotonImage);
|
|
3979
|
+
wasm.tint(photon_image.__wbg_ptr, r_offset, g_offset, b_offset);
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
/**
|
|
3983
|
+
* Convert a PhotonImage to JS-compatible ImageData.
|
|
3984
|
+
* @param {PhotonImage} photon_image
|
|
3985
|
+
* @returns {ImageData}
|
|
3986
|
+
*/
|
|
3987
|
+
export function to_image_data(photon_image) {
|
|
3988
|
+
_assertClass(photon_image, PhotonImage);
|
|
3989
|
+
var ptr0 = photon_image.__destroy_into_raw();
|
|
3990
|
+
const ret = wasm.to_image_data(ptr0);
|
|
3991
|
+
return ret;
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
/**
|
|
3995
|
+
* Convert ImageData to a raw pixel vec of u8s.
|
|
3996
|
+
* @param {ImageData} imgdata
|
|
3997
|
+
* @returns {Uint8Array}
|
|
3998
|
+
*/
|
|
3999
|
+
export function to_raw_pixels(imgdata) {
|
|
4000
|
+
const ret = wasm.to_raw_pixels(imgdata);
|
|
4001
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
4002
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
4003
|
+
return v1;
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
/**
|
|
4007
|
+
* Vertical strips. Divide an image into a series of equal-width strips, for an artistic effect.
|
|
4008
|
+
*
|
|
4009
|
+
* # Arguments
|
|
4010
|
+
* * `img` - A PhotonImage that contains a view into the image.
|
|
4011
|
+
* * `num_strips` - The numbder of strips
|
|
4012
|
+
* # Example
|
|
4013
|
+
*
|
|
4014
|
+
* ```no_run
|
|
4015
|
+
* // For example, to draw vertical strips on a `PhotonImage`:
|
|
4016
|
+
* use photon_rs::effects::vertical_strips;
|
|
4017
|
+
* use photon_rs::native::open_image;
|
|
4018
|
+
*
|
|
4019
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
4020
|
+
* vertical_strips(&mut img, 8u8);
|
|
4021
|
+
* ```
|
|
4022
|
+
* @param {PhotonImage} photon_image
|
|
4023
|
+
* @param {number} num_strips
|
|
4024
|
+
*/
|
|
4025
|
+
export function vertical_strips(photon_image, num_strips) {
|
|
4026
|
+
_assertClass(photon_image, PhotonImage);
|
|
4027
|
+
wasm.vertical_strips(photon_image.__wbg_ptr, num_strips);
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
/**
|
|
4031
|
+
* Add a watermark to an image.
|
|
4032
|
+
*
|
|
4033
|
+
* # Arguments
|
|
4034
|
+
* * `img` - A DynamicImage that contains a view into the image.
|
|
4035
|
+
* * `watermark` - The watermark to be placed onto the `img` image.
|
|
4036
|
+
* * `x` - The x coordinate where the watermark's top corner should be positioned.
|
|
4037
|
+
* * `y` - The y coordinate where the watermark's top corner should be positioned.
|
|
4038
|
+
* # Example
|
|
4039
|
+
*
|
|
4040
|
+
* ```no_run
|
|
4041
|
+
* // For example, to add a watermark to an image at x: 30, y: 40:
|
|
4042
|
+
* use photon_rs::multiple::watermark;
|
|
4043
|
+
* use photon_rs::native::open_image;
|
|
4044
|
+
*
|
|
4045
|
+
* let mut img = open_image("img.jpg").expect("File should open");
|
|
4046
|
+
* let water_mark = open_image("watermark.jpg").expect("File should open");
|
|
4047
|
+
* watermark(&mut img, &water_mark, 30_i64, 40_i64);
|
|
4048
|
+
* ```
|
|
4049
|
+
* @param {PhotonImage} img
|
|
4050
|
+
* @param {PhotonImage} watermark
|
|
4051
|
+
* @param {bigint} x
|
|
4052
|
+
* @param {bigint} y
|
|
4053
|
+
*/
|
|
4054
|
+
export function watermark(img, watermark, x, y) {
|
|
4055
|
+
_assertClass(img, PhotonImage);
|
|
4056
|
+
_assertClass(watermark, PhotonImage);
|
|
4057
|
+
wasm.watermark(img.__wbg_ptr, watermark.__wbg_ptr, x, y);
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
function __wbg_get_imports() {
|
|
4061
|
+
const import0 = {
|
|
4062
|
+
__proto__: null,
|
|
4063
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
4064
|
+
const ret = debugString(arg1);
|
|
4065
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
4066
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4067
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
4068
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
4069
|
+
},
|
|
4070
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
4071
|
+
const ret = arg0 === undefined;
|
|
4072
|
+
return ret;
|
|
4073
|
+
},
|
|
4074
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
4075
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
4076
|
+
},
|
|
4077
|
+
__wbg_appendChild_dea38765a26d346d: function() { return handleError(function (arg0, arg1) {
|
|
4078
|
+
const ret = arg0.appendChild(arg1);
|
|
4079
|
+
return ret;
|
|
4080
|
+
}, arguments); },
|
|
4081
|
+
__wbg_body_f67922363a220026: function(arg0) {
|
|
4082
|
+
const ret = arg0.body;
|
|
4083
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
4084
|
+
},
|
|
4085
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
4086
|
+
const ret = arg0.call(arg1);
|
|
4087
|
+
return ret;
|
|
4088
|
+
}, arguments); },
|
|
4089
|
+
__wbg_createElement_49f60fdcaae809c8: function() { return handleError(function (arg0, arg1, arg2) {
|
|
4090
|
+
const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
|
|
4091
|
+
return ret;
|
|
4092
|
+
}, arguments); },
|
|
4093
|
+
__wbg_data_d52fd40cc1d7d4e8: function(arg0, arg1) {
|
|
4094
|
+
const ret = arg1.data;
|
|
4095
|
+
const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
|
|
4096
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4097
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
4098
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
4099
|
+
},
|
|
4100
|
+
__wbg_document_ee35a3d3ae34ef6c: function(arg0) {
|
|
4101
|
+
const ret = arg0.document;
|
|
4102
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
4103
|
+
},
|
|
4104
|
+
__wbg_drawImage_00302fc1908197cc: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
|
4105
|
+
arg0.drawImage(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
|
|
4106
|
+
}, arguments); },
|
|
4107
|
+
__wbg_drawImage_51b6a9d03c34c5cc: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
4108
|
+
arg0.drawImage(arg1, arg2, arg3);
|
|
4109
|
+
}, arguments); },
|
|
4110
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
4111
|
+
let deferred0_0;
|
|
4112
|
+
let deferred0_1;
|
|
4113
|
+
try {
|
|
4114
|
+
deferred0_0 = arg0;
|
|
4115
|
+
deferred0_1 = arg1;
|
|
4116
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
4117
|
+
} finally {
|
|
4118
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
4119
|
+
}
|
|
4120
|
+
},
|
|
4121
|
+
__wbg_getContext_2a5764d48600bc43: function() { return handleError(function (arg0, arg1, arg2) {
|
|
4122
|
+
const ret = arg0.getContext(getStringFromWasm0(arg1, arg2));
|
|
4123
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
4124
|
+
}, arguments); },
|
|
4125
|
+
__wbg_getImageData_24d72830c218154d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
4126
|
+
const ret = arg0.getImageData(arg1, arg2, arg3, arg4);
|
|
4127
|
+
return ret;
|
|
4128
|
+
}, arguments); },
|
|
4129
|
+
__wbg_height_38750dc6de41ee75: function(arg0) {
|
|
4130
|
+
const ret = arg0.height;
|
|
4131
|
+
return ret;
|
|
4132
|
+
},
|
|
4133
|
+
__wbg_height_408f385de046f7e5: function(arg0) {
|
|
4134
|
+
const ret = arg0.height;
|
|
4135
|
+
return ret;
|
|
4136
|
+
},
|
|
4137
|
+
__wbg_height_87250db2be5164b9: function(arg0) {
|
|
4138
|
+
const ret = arg0.height;
|
|
4139
|
+
return ret;
|
|
4140
|
+
},
|
|
4141
|
+
__wbg_instanceof_CanvasRenderingContext2d_4bb052fd1c3d134d: function(arg0) {
|
|
4142
|
+
let result;
|
|
4143
|
+
try {
|
|
4144
|
+
result = arg0 instanceof CanvasRenderingContext2D;
|
|
4145
|
+
} catch (_) {
|
|
4146
|
+
result = false;
|
|
4147
|
+
}
|
|
4148
|
+
const ret = result;
|
|
4149
|
+
return ret;
|
|
4150
|
+
},
|
|
4151
|
+
__wbg_instanceof_HtmlCanvasElement_3f2f6e1edb1c9792: function(arg0) {
|
|
4152
|
+
let result;
|
|
4153
|
+
try {
|
|
4154
|
+
result = arg0 instanceof HTMLCanvasElement;
|
|
4155
|
+
} catch (_) {
|
|
4156
|
+
result = false;
|
|
4157
|
+
}
|
|
4158
|
+
const ret = result;
|
|
4159
|
+
return ret;
|
|
4160
|
+
},
|
|
4161
|
+
__wbg_instanceof_Window_ed49b2db8df90359: function(arg0) {
|
|
4162
|
+
let result;
|
|
4163
|
+
try {
|
|
4164
|
+
result = arg0 instanceof Window;
|
|
4165
|
+
} catch (_) {
|
|
4166
|
+
result = false;
|
|
4167
|
+
}
|
|
4168
|
+
const ret = result;
|
|
4169
|
+
return ret;
|
|
4170
|
+
},
|
|
4171
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
4172
|
+
const ret = arg0.length;
|
|
4173
|
+
return ret;
|
|
4174
|
+
},
|
|
4175
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
4176
|
+
const ret = new Error();
|
|
4177
|
+
return ret;
|
|
4178
|
+
},
|
|
4179
|
+
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
4180
|
+
const ret = new Uint8Array(arg0);
|
|
4181
|
+
return ret;
|
|
4182
|
+
},
|
|
4183
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
4184
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
4185
|
+
return ret;
|
|
4186
|
+
},
|
|
4187
|
+
__wbg_new_with_u8_clamped_array_and_sh_0c0b789ceb2eab31: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
4188
|
+
const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
|
|
4189
|
+
return ret;
|
|
4190
|
+
}, arguments); },
|
|
4191
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
4192
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
4193
|
+
},
|
|
4194
|
+
__wbg_putImageData_78318465ad96c2c3: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
4195
|
+
arg0.putImageData(arg1, arg2, arg3);
|
|
4196
|
+
}, arguments); },
|
|
4197
|
+
__wbg_set_height_f21f985387070100: function(arg0, arg1) {
|
|
4198
|
+
arg0.height = arg1 >>> 0;
|
|
4199
|
+
},
|
|
4200
|
+
__wbg_set_textContent_3e87dba095d9cdbc: function(arg0, arg1, arg2) {
|
|
4201
|
+
arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
|
|
4202
|
+
},
|
|
4203
|
+
__wbg_set_width_d60bc4f2f20c56a4: function(arg0, arg1) {
|
|
4204
|
+
arg0.width = arg1 >>> 0;
|
|
4205
|
+
},
|
|
4206
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
4207
|
+
const ret = arg1.stack;
|
|
4208
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
4209
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4210
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
4211
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
4212
|
+
},
|
|
4213
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
4214
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
4215
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
4216
|
+
},
|
|
4217
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
4218
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
4219
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
4220
|
+
},
|
|
4221
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
4222
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
4223
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
4224
|
+
},
|
|
4225
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
4226
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
4227
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
4228
|
+
},
|
|
4229
|
+
__wbg_width_5901d980713eb80b: function(arg0) {
|
|
4230
|
+
const ret = arg0.width;
|
|
4231
|
+
return ret;
|
|
4232
|
+
},
|
|
4233
|
+
__wbg_width_5f66bde2e810fbde: function(arg0) {
|
|
4234
|
+
const ret = arg0.width;
|
|
4235
|
+
return ret;
|
|
4236
|
+
},
|
|
4237
|
+
__wbg_width_be8f36d66d37751f: function(arg0) {
|
|
4238
|
+
const ret = arg0.width;
|
|
4239
|
+
return ret;
|
|
4240
|
+
},
|
|
4241
|
+
__wbindgen_init_externref_table: function() {
|
|
4242
|
+
const table = wasm.__wbindgen_externrefs;
|
|
4243
|
+
const offset = table.grow(4);
|
|
4244
|
+
table.set(0, undefined);
|
|
4245
|
+
table.set(offset + 0, undefined);
|
|
4246
|
+
table.set(offset + 1, null);
|
|
4247
|
+
table.set(offset + 2, true);
|
|
4248
|
+
table.set(offset + 3, false);
|
|
4249
|
+
},
|
|
4250
|
+
};
|
|
4251
|
+
return {
|
|
4252
|
+
__proto__: null,
|
|
4253
|
+
"./photon_rs_bg.js": import0,
|
|
4254
|
+
};
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
const PhotonImageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4258
|
+
? { register: () => {}, unregister: () => {} }
|
|
4259
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_photonimage_free(ptr >>> 0, 1));
|
|
4260
|
+
const RgbFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4261
|
+
? { register: () => {}, unregister: () => {} }
|
|
4262
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rgb_free(ptr >>> 0, 1));
|
|
4263
|
+
const RgbaFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4264
|
+
? { register: () => {}, unregister: () => {} }
|
|
4265
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rgba_free(ptr >>> 0, 1));
|
|
4266
|
+
|
|
4267
|
+
function addToExternrefTable0(obj) {
|
|
4268
|
+
const idx = wasm.__externref_table_alloc();
|
|
4269
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
4270
|
+
return idx;
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
function _assertClass(instance, klass) {
|
|
4274
|
+
if (!(instance instanceof klass)) {
|
|
4275
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
function debugString(val) {
|
|
4280
|
+
// primitive types
|
|
4281
|
+
const type = typeof val;
|
|
4282
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
4283
|
+
return `${val}`;
|
|
4284
|
+
}
|
|
4285
|
+
if (type == 'string') {
|
|
4286
|
+
return `"${val}"`;
|
|
4287
|
+
}
|
|
4288
|
+
if (type == 'symbol') {
|
|
4289
|
+
const description = val.description;
|
|
4290
|
+
if (description == null) {
|
|
4291
|
+
return 'Symbol';
|
|
4292
|
+
} else {
|
|
4293
|
+
return `Symbol(${description})`;
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
if (type == 'function') {
|
|
4297
|
+
const name = val.name;
|
|
4298
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
4299
|
+
return `Function(${name})`;
|
|
4300
|
+
} else {
|
|
4301
|
+
return 'Function';
|
|
4302
|
+
}
|
|
4303
|
+
}
|
|
4304
|
+
// objects
|
|
4305
|
+
if (Array.isArray(val)) {
|
|
4306
|
+
const length = val.length;
|
|
4307
|
+
let debug = '[';
|
|
4308
|
+
if (length > 0) {
|
|
4309
|
+
debug += debugString(val[0]);
|
|
4310
|
+
}
|
|
4311
|
+
for(let i = 1; i < length; i++) {
|
|
4312
|
+
debug += ', ' + debugString(val[i]);
|
|
4313
|
+
}
|
|
4314
|
+
debug += ']';
|
|
4315
|
+
return debug;
|
|
4316
|
+
}
|
|
4317
|
+
// Test for built-in
|
|
4318
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
4319
|
+
let className;
|
|
4320
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
4321
|
+
className = builtInMatches[1];
|
|
4322
|
+
} else {
|
|
4323
|
+
// Failed to match the standard '[object ClassName]'
|
|
4324
|
+
return toString.call(val);
|
|
4325
|
+
}
|
|
4326
|
+
if (className == 'Object') {
|
|
4327
|
+
// we're a user defined class or Object
|
|
4328
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
4329
|
+
// easier than looping through ownProperties of `val`.
|
|
4330
|
+
try {
|
|
4331
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
4332
|
+
} catch (_) {
|
|
4333
|
+
return 'Object';
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
// errors
|
|
4337
|
+
if (val instanceof Error) {
|
|
4338
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
4339
|
+
}
|
|
4340
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
4341
|
+
return className;
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
4345
|
+
ptr = ptr >>> 0;
|
|
4346
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
4347
|
+
}
|
|
4348
|
+
|
|
4349
|
+
function getClampedArrayU8FromWasm0(ptr, len) {
|
|
4350
|
+
ptr = ptr >>> 0;
|
|
4351
|
+
return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
4352
|
+
}
|
|
4353
|
+
|
|
4354
|
+
let cachedDataViewMemory0 = null;
|
|
4355
|
+
function getDataViewMemory0() {
|
|
4356
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
4357
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
4358
|
+
}
|
|
4359
|
+
return cachedDataViewMemory0;
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4362
|
+
function getStringFromWasm0(ptr, len) {
|
|
4363
|
+
ptr = ptr >>> 0;
|
|
4364
|
+
return decodeText(ptr, len);
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
let cachedUint8ArrayMemory0 = null;
|
|
4368
|
+
function getUint8ArrayMemory0() {
|
|
4369
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
4370
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
4371
|
+
}
|
|
4372
|
+
return cachedUint8ArrayMemory0;
|
|
4373
|
+
}
|
|
4374
|
+
|
|
4375
|
+
let cachedUint8ClampedArrayMemory0 = null;
|
|
4376
|
+
function getUint8ClampedArrayMemory0() {
|
|
4377
|
+
if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
|
|
4378
|
+
cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
|
|
4379
|
+
}
|
|
4380
|
+
return cachedUint8ClampedArrayMemory0;
|
|
4381
|
+
}
|
|
4382
|
+
|
|
4383
|
+
function handleError(f, args) {
|
|
4384
|
+
try {
|
|
4385
|
+
return f.apply(this, args);
|
|
4386
|
+
} catch (e) {
|
|
4387
|
+
const idx = addToExternrefTable0(e);
|
|
4388
|
+
wasm.__wbindgen_exn_store(idx);
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
|
|
4392
|
+
function isLikeNone(x) {
|
|
4393
|
+
return x === undefined || x === null;
|
|
4394
|
+
}
|
|
4395
|
+
|
|
4396
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
4397
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
4398
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
4399
|
+
WASM_VECTOR_LEN = arg.length;
|
|
4400
|
+
return ptr;
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4403
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
4404
|
+
if (realloc === undefined) {
|
|
4405
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
4406
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
4407
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
4408
|
+
WASM_VECTOR_LEN = buf.length;
|
|
4409
|
+
return ptr;
|
|
4410
|
+
}
|
|
4411
|
+
|
|
4412
|
+
let len = arg.length;
|
|
4413
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
4414
|
+
|
|
4415
|
+
const mem = getUint8ArrayMemory0();
|
|
4416
|
+
|
|
4417
|
+
let offset = 0;
|
|
4418
|
+
|
|
4419
|
+
for (; offset < len; offset++) {
|
|
4420
|
+
const code = arg.charCodeAt(offset);
|
|
4421
|
+
if (code > 0x7F) break;
|
|
4422
|
+
mem[ptr + offset] = code;
|
|
4423
|
+
}
|
|
4424
|
+
if (offset !== len) {
|
|
4425
|
+
if (offset !== 0) {
|
|
4426
|
+
arg = arg.slice(offset);
|
|
4427
|
+
}
|
|
4428
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
4429
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
4430
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
4431
|
+
|
|
4432
|
+
offset += ret.written;
|
|
4433
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
4434
|
+
}
|
|
4435
|
+
|
|
4436
|
+
WASM_VECTOR_LEN = offset;
|
|
4437
|
+
return ptr;
|
|
4438
|
+
}
|
|
4439
|
+
|
|
4440
|
+
function takeFromExternrefTable0(idx) {
|
|
4441
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
4442
|
+
wasm.__externref_table_dealloc(idx);
|
|
4443
|
+
return value;
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
4447
|
+
cachedTextDecoder.decode();
|
|
4448
|
+
function decodeText(ptr, len) {
|
|
4449
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
const cachedTextEncoder = new TextEncoder();
|
|
4453
|
+
|
|
4454
|
+
let WASM_VECTOR_LEN = 0;
|
|
4455
|
+
|
|
4456
|
+
const wasmUrl = new URL('photon_rs_bg.wasm', import.meta.url);
|
|
4457
|
+
const wasmInstantiated = await WebAssembly.instantiateStreaming(fetch(wasmUrl), __wbg_get_imports());
|
|
4458
|
+
const wasm = wasmInstantiated.instance.exports;
|
|
4459
|
+
wasm.__wbindgen_start();
|