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