@unity-china/codely-cli 1.0.0-rc.4 → 1.0.0-rc.43

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