@oh-my-pi/pi-coding-agent 8.12.2 → 8.12.5

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