@midscene/harmony-mcp 1.8.11 → 1.9.0

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