index/
wasm_interface.rs

1use js_sys::{Array, Function};
2use wasm_bindgen::prelude::*;
3use crate::{colors::Color, objects::{three_d::wasm_interface::WasmThreeDObject, wasm_interface::{WasmColor, WasmVectorObject}}, utils::{add_n_more_subobjects, add_n_more_subobjects_3d, align_data, align_data_3d, align_points, align_points_3d, align_subobjects, align_subobjects_3d, bezier, bezier_3d, bezier_f64, center, center_3d, choose, consider_points_equals, consider_points_equals_3d, distance_squared, distance_squared_3d, double_smooth, ease_in_back, ease_in_circ, ease_in_cubic, ease_in_elastic, ease_in_expo, ease_in_out_back, ease_in_out_bounce, ease_in_out_circ, ease_in_out_cubic, ease_in_out_elastic, ease_in_out_expo, ease_in_out_quad, ease_in_out_quart, ease_in_out_quint, ease_in_out_sine, ease_in_quad, ease_in_quart, ease_in_quint, ease_in_sine, ease_out_bounce, ease_out_circ, ease_out_cubic, ease_out_elastic, ease_out_expo, ease_out_quad, ease_out_quart, ease_out_quint, ease_out_sine, elliptical_arc_path, exponential_decay, factorial, get_bbox, get_nth_subpath, get_nth_subpath_3d, has_new_path_begun, has_new_path_begun_3d, hex_to_color, insert_n_curves_to_point_list, insert_n_curves_to_point_list_3d, integer_interpolate, interp, interpolate, interpolate_color, interpolate_tuple, interpolate_tuple_3d, line_as_cubic_bezier, linear, lingering, not_quite_there, null_point_align, null_point_align_3d, permutation, points_from_anchors_and_handles, quadratic_bezier_as_cubic_bezier, radian, running_start, rush_from, rush_into, sigmoid, sleep, slow_into, smooth, smoothererstep, smootherstep, smoothstep, squish_rate_func, start_new_path, start_new_path_3d, there_and_back, there_and_back_with_pause, wiggle}};
4
5#[wasm_bindgen(js_name = radian)]
6pub fn radian_js(ux: f64, uy: f64, vx: f64, vy: f64) -> f64 {
7    return radian(ux, uy, vx, vy);
8}
9
10
11#[wasm_bindgen(js_name = bezier3D)]
12pub fn bezier_3d_js(points: Array, t: f64) -> Array {
13    let points = points.iter().map(|point| {
14        let point = point.dyn_into::<Array>().unwrap();
15        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
16    }).collect();
17    let result = bezier_3d(&points, t);
18    return Array::of3(&JsValue::from_f64(result.0), &JsValue::from_f64(result.1), &JsValue::from_f64(result.2));
19}
20
21
22#[wasm_bindgen(js_name = interp)]
23pub fn interp_js(x: f64, xp: &Array, fp: &Array) -> f64 {
24    return interp(x, &xp.iter().map(|x| x.as_f64().unwrap()).collect::<Vec<f64>>(), &fp.iter().map(|x| x.as_f64().unwrap()).collect::<Vec<f64>>());
25}
26
27
28#[wasm_bindgen(js_name = sleep)]
29pub async fn sleep_js(ms: i32) {
30    sleep(ms).await;
31}
32
33
34#[wasm_bindgen(js_name = ellipticalArcPath)]
35pub fn elliptical_arc_path_js(
36    last_move: Array,
37    rx: f64,
38    ry: f64,
39    rotation: f64,
40    large_arc: bool,
41    sweep: bool,
42    x: f64,
43    y: f64
44) -> Array {
45    let result = elliptical_arc_path(
46        (last_move.get(0).as_f64().unwrap(), last_move.get(1).as_f64().unwrap()),
47        rx,
48        ry,
49        rotation,
50        large_arc,
51        sweep,
52        x,
53        y
54    );
55    return Array::from(
56        &JsValue::from(result.iter().map(|point| {
57            return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
58        }).collect::<Array>()),
59    );
60}
61
62
63#[wasm_bindgen(js_name = getBbox)]
64pub fn get_bbox_js(points: Array) -> Array {
65    let points = points.iter().map(|point| {
66        let point = point.dyn_into::<Array>().unwrap();
67        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
68    }).collect();
69    let result = get_bbox(&points);
70    return Array::from(
71        &JsValue::from(Array::of2(
72            &Array::of2(&JsValue::from_f64(result.0.0), &JsValue::from_f64(result.0.1)),
73            &Array::of2(&JsValue::from_f64(result.1.0), &JsValue::from_f64(result.1.1)),
74        )),
75    );
76}
77
78
79#[wasm_bindgen(js_name = center)]
80pub fn center_js(points: Array, center_if_no_points: Array) -> Array {
81    let points = points.iter().map(|point| {
82        let point = point.dyn_into::<Array>().unwrap();
83        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
84    }).collect();
85    let result = center(&points, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap()));
86    return Array::of2(&JsValue::from_f64(result.0), &JsValue::from_f64(result.1));
87}
88
89
90#[wasm_bindgen(js_name = center3D)]
91pub fn center_3d_js(points: Array, center_if_no_points: Array) -> Array {
92    let points = points.iter().map(|point| {
93        let point = point.dyn_into::<Array>().unwrap();
94        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
95    }).collect();
96    let result = center_3d(&points, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap(), center_if_no_points.get(2).as_f64().unwrap()));
97    return Array::of3(&JsValue::from_f64(result.0), &JsValue::from_f64(result.1), &JsValue::from_f64(result.2));
98}
99
100
101#[wasm_bindgen(js_name = factorial)]
102pub fn factorial_js(n: u64) -> u64 {
103    return factorial(n);
104}
105
106
107#[wasm_bindgen(js_name = hexToColor)]
108pub fn hex_to_color_js(hex: String, a: f64) -> WasmColor {
109    return WasmColor { color: hex_to_color(hex.as_str(), a) }
110}
111
112
113#[wasm_bindgen(js_name = bezier)]
114pub fn bezier_js(points: Array, t: f64) -> Array {
115    let points = points.iter().map(|point| {
116        let point = point.dyn_into::<Array>().unwrap();
117        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
118    }).collect();
119    let result = bezier(&points, t);
120    return Array::of2(&JsValue::from_f64(result.0), &JsValue::from_f64(result.1));
121}
122
123
124#[wasm_bindgen(js_name = bezierNumber)]
125pub fn bezier_number_js(numbers: Array, t: f64) -> f64 {
126    let numbers = numbers.iter().map(|number| {
127        return number.as_f64().unwrap();
128    }).collect();
129    let result = bezier_f64(numbers, t);
130    return result;
131}
132
133
134#[wasm_bindgen(js_name = permutation)]
135pub fn permutation_js(n: u64, r: u64) -> u64 {
136    return permutation(n, r);
137}
138
139
140#[wasm_bindgen(js_name = choose)]
141pub fn choose_js(n: u64, r: u64) -> u64 {
142    return choose(n, r);
143}
144
145
146#[wasm_bindgen(js_name = distanceSquared)]
147pub fn distance_squared_js(x1: f64, y1: f64, x2: f64, y2: f64) -> f64 {
148    return distance_squared((x1, y1), (x2, y2));
149}
150
151
152#[wasm_bindgen(js_name = distanceSquared3D)]
153pub fn distance_squared_3d_js(x1: f64, y1: f64, z1: f64, x2: f64, y2: f64, z2: f64) -> f64 {
154    return distance_squared_3d((x1, y1, z1), (x2, y2, z2));
155}
156
157
158#[wasm_bindgen(js_name = interpolate)]
159pub fn interpolate_js(x: f64, y: f64, t: f64) -> f64 {
160    return interpolate(x, y, t);
161}
162
163
164#[wasm_bindgen(js_name = interpolateTuple)]
165pub fn interpolate_tuple_js(x: Array, y: Array, t: f64) -> Array {
166    let x = (x.get(0).as_f64().unwrap(), x.get(1).as_f64().unwrap());
167    let y = (y.get(0).as_f64().unwrap(), y.get(1).as_f64().unwrap());
168    let result = interpolate_tuple(x, y, t);
169    return Array::of2(&JsValue::from_f64(result.0), &JsValue::from_f64(result.1));
170}
171
172
173#[wasm_bindgen(js_name = interpolateTuple3D)]
174pub fn interpolate_tuple_3d_js(x: Array, y: Array, t: f64) -> Array {
175    let x = (x.get(0).as_f64().unwrap(), x.get(1).as_f64().unwrap(), x.get(2).as_f64().unwrap());
176    let y = (y.get(0).as_f64().unwrap(), y.get(1).as_f64().unwrap(), y.get(2).as_f64().unwrap());
177    let result = interpolate_tuple_3d(x, y, t);
178    return Array::of3(&JsValue::from_f64(result.0), &JsValue::from_f64(result.1), &JsValue::from_f64(result.2));
179}
180
181
182#[wasm_bindgen(js_name = interpolateColor)]
183pub fn interpolate_color_js(x: WasmColor, y: WasmColor, t: f64) -> WasmColor {
184    let result = interpolate_color(
185        (x.get_r(), x.get_g(), x.get_b(), x.get_a()),
186        (y.get_r(), y.get_g(), y.get_b(), y.get_a()),
187        t
188    );
189    return WasmColor { color: Color { red: result.0, blue: result.1, green: result.2, alpha: result.3 } };
190}
191
192
193#[wasm_bindgen(js_name = pointsFromAnchorsAndHandles)]
194pub fn points_from_anchors_and_handles_js(
195    anchors1: Array,
196    handles1: Array,
197    handles2: Array,
198    anchors2: Array,
199) -> Array {
200    let anchors1 = anchors1.iter().map(|point| {
201        let point = point.dyn_into::<Array>().unwrap();
202        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
203    }).collect();
204    let handles1 = handles1.iter().map(|point| {
205        let point = point.dyn_into::<Array>().unwrap();
206        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
207    }).collect();
208    let handles2 = handles2.iter().map(|point| {
209        let point = point.dyn_into::<Array>().unwrap();
210        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
211    }).collect();
212    let anchors2 = anchors2.iter().map(|point| {
213        let point = point.dyn_into::<Array>().unwrap();
214        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
215    }).collect();
216    let result = points_from_anchors_and_handles(anchors1, handles1, handles2, anchors2);
217    return result.iter().map(|point| {
218        return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
219    }).collect();
220}
221
222
223#[wasm_bindgen(js_name = startNewPath)]
224pub fn start_new_path_js(points: Array, point: Array) -> Array {
225    let points = points.iter().map(|point| {
226        let point = point.dyn_into::<Array>().unwrap();
227        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
228    }).collect::<Vec<(f64, f64)>>();
229    let point = (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
230    let result = start_new_path(&points, point);
231    return result.iter().map(|point| {
232        return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
233    }).collect();
234}
235
236
237#[wasm_bindgen(js_name = startNewPath3D)]
238pub fn start_new_path_3d_js(points: Array, point: Array) -> Array {
239    let points = points.iter().map(|point| {
240        let point = point.dyn_into::<Array>().unwrap();
241        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
242    }).collect::<Vec<(f64, f64, f64)>>();
243    let point = (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
244    let result = start_new_path_3d(&points, point);
245    return result.iter().map(|point| {
246        return Array::of3(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1), &JsValue::from_f64(point.2));
247    }).collect();
248}
249
250
251#[wasm_bindgen(js_name = hasNewPathBegun)]
252pub fn has_new_path_begun_js(points: Array) -> bool {
253    let points = points.iter().map(|point| {
254        let point = point.dyn_into::<Array>().unwrap();
255        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
256    }).collect();
257    return has_new_path_begun(&points);
258}
259
260
261#[wasm_bindgen(js_name = hasNewPathBegun3D)]
262pub fn has_new_path_begun_3d_js(points: Array) -> bool {
263    let points = points.iter().map(|point| {
264        let point = point.dyn_into::<Array>().unwrap();
265        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
266    }).collect();
267    return has_new_path_begun_3d(&points);
268}
269
270
271#[wasm_bindgen(js_name = considerPointsEquals3D)]
272pub fn consider_points_equals_3d_js(
273    x1: f64,
274    y1: f64,
275    z1: f64,
276    x2: f64,
277    y2: f64,
278    z2: f64
279) -> bool {
280    let point1 = (x1, y1, z1);
281    let point2 = (x2, y2, z2);
282    return consider_points_equals_3d(point1, point2);
283}
284
285
286#[wasm_bindgen(js_name = getNthSubpath)]
287pub fn get_nth_subpath_js(points: Array, n: usize) -> Array {
288    let points = points.iter().map(|points| {
289        let points = points.dyn_into::<Array>().unwrap();
290        let points = points.iter().collect::<Vec<JsValue>>();
291        let points = points.iter().map(|point| {
292            let point = point.clone().dyn_into::<Array>().unwrap();
293            return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
294        }).collect();
295        return points;
296    }).collect();
297    let result = get_nth_subpath(&points, n);
298    return result.iter().map(|point| {
299        return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
300    }).collect();
301}
302
303
304#[wasm_bindgen(js_name = getNthSubpath3D)]
305pub fn get_nth_subpath_3d_js(points: Array, n: usize) -> Array {
306    let points = points.iter().map(|points| {
307        let points = points.dyn_into::<Array>().unwrap();
308        let points = points.iter().collect::<Vec<JsValue>>();
309        let points = points.iter().map(|point| {
310            let point = point.clone().dyn_into::<Array>().unwrap();
311            return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
312        }).collect();
313        return points;
314    }).collect();
315    let result = get_nth_subpath_3d(&points, n);
316    return result.iter().map(|point| {
317        return Array::of3(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1), &JsValue::from_f64(point.2));
318    }).collect();
319}
320
321
322#[wasm_bindgen(js_name = insertNCurvesToPointList3D)]
323pub fn insert_n_curves_to_point_list_3d_js(n: usize, points: Array) -> Array {
324    let points = points.iter().map(|point| {
325        let point = point.dyn_into::<Array>().unwrap();
326        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
327    }).collect();
328    let result = insert_n_curves_to_point_list_3d(n, &points);
329    return result.iter().map(|point| {
330        return Array::of3(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1), &JsValue::from_f64(point.2));
331    }).collect();
332}
333
334
335#[wasm_bindgen(js_name = alignPoints3D)]
336pub fn align_points_3d_js(
337    points1: Array,
338    points2: Array,
339    center_if_no_points: Array
340) -> Array {
341    let points1 = points1.iter().map(|point| {
342        let point = point.dyn_into::<Array>().unwrap();
343        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
344    }).collect();
345    let points2 = points2.iter().map(|point| {
346        let point = point.dyn_into::<Array>().unwrap();
347        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap(), point.get(2).as_f64().unwrap());
348    }).collect();
349    let center_if_no_points = (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap(), center_if_no_points.get(2).as_f64().unwrap());
350    let result = align_points_3d(&points1, &points2, center_if_no_points);
351    return Array::of2(
352        &JsValue::from(result.0.iter().map(|point| {
353            return Array::of3(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1), &JsValue::from_f64(point.2));
354        }).collect::<Array>()),
355        &JsValue::from(result.1.iter().map(|point| {
356            return Array::of3(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1), &JsValue::from_f64(point.2));
357        }).collect::<Array>())
358    );
359}
360
361
362#[wasm_bindgen(js_name = insertNCurvesToPointList)]
363pub fn insert_n_curves_to_point_list_js(n: usize, points: Array) -> Array {
364    let points = points.iter().map(|point| {
365        let point = point.dyn_into::<Array>().unwrap();
366        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
367    }).collect();
368    let result = insert_n_curves_to_point_list(n, &points);
369    return result.iter().map(|point| {
370        return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
371    }).collect();
372}
373
374
375#[wasm_bindgen(js_name = nullPointAlign3D)]
376pub fn null_point_align_3d_js(
377    obj1: WasmThreeDObject,
378    obj2: WasmThreeDObject
379) -> Array {
380    let obj1 = obj1.three_d_object;
381    let obj2 = obj2.three_d_object;
382    let result = null_point_align_3d(obj1, obj2);
383    return Array::of2(
384        &JsValue::from(WasmThreeDObject { three_d_object: result.0 }),
385        &JsValue::from(WasmThreeDObject { three_d_object: result.1 })
386    );
387}
388
389
390#[wasm_bindgen(js_name = nullPointAlign)]
391pub fn null_point_align_js(
392    vec_obj1: WasmVectorObject,
393    vec_obj2: WasmVectorObject
394) -> Array {
395    let vec_obj1 = vec_obj1.native_vec_features;
396    let vec_obj2 = vec_obj2.native_vec_features;
397    let result = null_point_align(vec_obj1, vec_obj2);
398    return Array::of2(
399        &JsValue::from(WasmVectorObject { native_vec_features: result.0 }),
400        &JsValue::from(WasmVectorObject { native_vec_features: result.1 })
401    )
402}
403
404
405#[wasm_bindgen(js_name = alignPoints)]
406pub fn align_points_js(points1: Array, points2: Array, center_if_no_points: Array) -> Array {
407    let points1 = points1.iter().map(|point| {
408        let point = point.dyn_into::<Array>().unwrap();
409        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
410    }).collect();
411    let points2 = points2.iter().map(|point| {
412        let point = point.dyn_into::<Array>().unwrap();
413        return (point.get(0).as_f64().unwrap(), point.get(1).as_f64().unwrap());
414    }).collect();
415    let center_if_no_points = (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap());
416    let result = align_points(&points1, &points2, center_if_no_points);
417    return Array::of2(
418        &JsValue::from(result.0.iter().map(|point| {
419            return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
420        }).collect::<Array>()),
421        &JsValue::from(result.1.iter().map(|point| {
422            return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
423        }).collect::<Array>())
424    )
425}
426
427
428#[wasm_bindgen(js_name = addNMoreSubobjects)]
429pub fn add_n_more_subobjects_js(
430    vec_obj: WasmVectorObject,
431    n: usize,
432    center_if_no_points: Array
433) -> WasmVectorObject {
434    let result = add_n_more_subobjects(vec_obj.native_vec_features, n, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap()));
435    return WasmVectorObject { native_vec_features: result };
436}
437
438
439#[wasm_bindgen(js_name = addNMoreSubobjects3D)]
440pub fn add_n_more_subobjects_3d_js(
441    obj_3d: WasmThreeDObject,
442    n: usize,
443    center_if_no_points: Array
444) -> WasmThreeDObject {
445    let result = add_n_more_subobjects_3d(obj_3d.three_d_object, n, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap(), center_if_no_points.get(2).as_f64().unwrap()));
446    return WasmThreeDObject { three_d_object: result };
447}
448
449
450#[wasm_bindgen(js_name = alignSubobjects3D)]
451pub fn align_subobjects_3d_js(
452    obj_3d1: WasmThreeDObject,
453    obj_3d2: WasmThreeDObject,
454    center_if_no_points: Array
455) -> Array {
456    let obj_3d1 = obj_3d1.three_d_object;
457    let obj_3d2 = obj_3d2.three_d_object;
458    let result = align_subobjects_3d(obj_3d1, obj_3d2, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap(), center_if_no_points.get(2).as_f64().unwrap()));
459    return Array::of2(
460        &JsValue::from(WasmThreeDObject { three_d_object: result.0 }),
461        &JsValue::from(WasmThreeDObject { three_d_object: result.1 })
462    );
463}
464
465
466#[wasm_bindgen(js_name = alignData3D)]
467pub fn align_data_3d_js(
468    obj_3d1: WasmThreeDObject,
469    obj_3d2: WasmThreeDObject,
470    skip_point_align: bool,
471    center_if_no_points: Array
472) -> Array {
473    let obj_3d1 = obj_3d1.three_d_object;
474    let obj_3d2 = obj_3d2.three_d_object;
475    let result = align_data_3d(obj_3d1, obj_3d2, skip_point_align, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap(), center_if_no_points.get(2).as_f64().unwrap()));
476    return Array::of2(
477        &JsValue::from(WasmThreeDObject { three_d_object: result.0 }),
478        &JsValue::from(WasmThreeDObject { three_d_object: result.1 })
479    );
480}
481
482
483#[wasm_bindgen(js_name = alignSubobjects)]
484pub fn align_subobjects_js(
485    vec_obj1: WasmVectorObject,
486    vec_obj2: WasmVectorObject,
487    center_if_no_points: Array
488) -> Vec<WasmVectorObject> {
489    let result = align_subobjects(vec_obj1.native_vec_features, vec_obj2.native_vec_features, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap()));
490    return vec![
491        WasmVectorObject { native_vec_features: result.0 },
492        WasmVectorObject { native_vec_features: result.1 }
493    ];
494}
495
496
497#[wasm_bindgen(js_name = alignData)]
498pub fn align_data_js(
499    vec_obj1: WasmVectorObject,
500    vec_obj2: WasmVectorObject,
501    skip_point_align: bool,
502    center_if_no_points: Array
503) -> Array {
504    let vec_obj1 = vec_obj1.native_vec_features;
505    let vec_obj2 = vec_obj2.native_vec_features;
506    let result = align_data(vec_obj1, vec_obj2, skip_point_align, (center_if_no_points.get(0).as_f64().unwrap(), center_if_no_points.get(1).as_f64().unwrap()));
507    return Array::of2(
508        &JsValue::from(WasmVectorObject { native_vec_features: result.0 }),
509        &JsValue::from(WasmVectorObject { native_vec_features: result.1 })
510    )
511}
512
513
514#[wasm_bindgen(js_name = integerInterpolate)]
515pub fn integer_interpolate_js(x: f64, y: f64, t: f64) -> Array {
516    let result = integer_interpolate(x, y, t);
517    return Array::of2(&JsValue::from_f64(result.0 as f64), &JsValue::from_f64(result.1));
518}
519
520
521#[wasm_bindgen(js_name = lineAsCubicBezier)]
522pub fn line_as_cubic_bezier_js(
523    x1: f64,
524    y1: f64,
525    x2: f64,
526    y2: f64
527) -> Array {
528    let result = line_as_cubic_bezier((x1, y1), (x2, y2));
529    return Array::from(
530        &JsValue::from(result.iter().map(|point| {
531            return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
532        }).collect::<Array>()),
533    );
534}
535
536
537#[wasm_bindgen(js_name = quadraticBezierAsCubicBezier)]
538pub fn quadratic_bezier_as_cubic_bezier_js(
539    x1: f64,
540    y1: f64,
541    x2: f64,
542    y2: f64,
543    x3: f64,
544    y3: f64
545) -> Array {
546    let result = quadratic_bezier_as_cubic_bezier((x1, y1), (x2, y2), (x3, y3));
547    return Array::from(
548        &JsValue::from(result.iter().map(|point| {
549            return Array::of2(&JsValue::from_f64(point.0), &JsValue::from_f64(point.1));
550        }).collect::<Array>()),
551    );
552}
553
554
555#[wasm_bindgen(js_name = considerPointsEquals)]
556pub fn consider_points_equals_js(
557    x1: f64,
558    y1: f64,
559    x2: f64,
560    y2: f64
561) -> bool {
562    return consider_points_equals((x1, y1), (x2, y2))
563}
564
565
566#[wasm_bindgen(js_name = sigmoid)]
567pub fn sigmoid_js(t: f64) -> f64 {
568    return sigmoid(t);
569}
570
571
572#[wasm_bindgen(js_name = linear)]
573pub fn linear_js(t: f64) -> f64 {
574    return linear(t);
575}
576
577
578#[wasm_bindgen(js_name = smooth)]
579pub fn smooth_js(t: f64, inflection: f64) -> f64 {
580    return smooth(t, inflection);
581}
582
583
584#[wasm_bindgen(js_name = smoothstep)]
585pub fn smoothstep_js(t: f64) -> f64 {
586    return smoothstep(t);
587}
588
589
590#[wasm_bindgen(js_name = smootherstep)]
591pub fn smootherstep_js(t: f64) -> f64 {
592    return smootherstep(t);
593}
594
595
596#[wasm_bindgen(js_name = smoothererstep)]
597pub fn smoothererstep_js(t: f64) -> f64 {
598    return smoothererstep(t);
599}
600
601
602#[wasm_bindgen(js_name = rushInto)]
603pub fn rush_into_js(t: f64, inflection: f64) -> f64 {
604    return rush_into(t, inflection);
605}
606
607
608#[wasm_bindgen(js_name = rushFrom)]
609pub fn rush_from_js(t: f64, inflection: f64) -> f64 {
610    return rush_from(t, inflection);
611}
612
613
614#[wasm_bindgen(js_name = slowInto)]
615pub fn slow_into_js(t: f64) -> f64 {
616    return slow_into(t);
617}
618
619
620#[wasm_bindgen(js_name = doubleSmooth)]
621pub fn double_smooth_js(t: f64) -> f64 {
622    return double_smooth(t);
623}
624
625
626#[wasm_bindgen(js_name = thereAndBack)]
627pub fn there_and_back_js(t: f64, inflection: f64) -> f64 {
628    return there_and_back(t, inflection);
629}
630
631
632#[wasm_bindgen(js_name = thereAndBackWithPause)]
633pub fn there_and_back_with_pause_js(t: f64, pause_ratio: f64) -> f64 {
634    return there_and_back_with_pause(t, pause_ratio);
635}
636
637
638#[wasm_bindgen(js_name = runningStart)]
639pub fn running_start_js(t: f64, pull_factor: f64) -> f64 {
640    return running_start(t, pull_factor);
641}
642
643
644#[wasm_bindgen(js_name = notQuiteThere)]
645pub fn not_quite_there_js(
646    func: Function,
647    t: f64,
648    proportion: f64
649) -> f64 {
650    let function = |t: f64| -> f64 {
651        let this = JsValue::NULL;
652        let args = Array::of1(&JsValue::from_f64(t));
653        return func.call1(&this, &args).unwrap().as_f64().unwrap();
654    };
655    return not_quite_there(function, t, proportion);
656}
657
658
659#[wasm_bindgen(js_name = wiggle)]
660pub fn wiggle_js(
661    t: f64,
662    wiggles: f64
663) -> f64 {
664    return wiggle(t, wiggles);
665}
666
667
668#[wasm_bindgen(js_name = squishRateFunc)]
669pub fn squish_rate_func_js(
670    func: Function,
671    t: f64,
672    a: f64,
673    b: f64
674) -> f64 {
675    let function = |t: f64| -> f64 {
676        let this = JsValue::NULL;
677        let args = Array::of1(&JsValue::from_f64(t));
678        return func.call1(&this, &args).unwrap().as_f64().unwrap();
679    };
680    return squish_rate_func(function, t, a, b);
681}
682
683
684#[wasm_bindgen(js_name = lingering)]
685pub fn lingering_js(t: f64) -> f64 {
686    return lingering(t);
687}
688
689
690#[wasm_bindgen(js_name = exponentialDecay)]
691pub fn exponential_decay_js(
692    t: f64,
693    half_life: f64
694) -> f64 {
695    return exponential_decay(t, half_life);
696}
697
698
699#[wasm_bindgen(js_name = easeInSine)]
700pub fn ease_in_sine_js(t: f64) -> f64 {
701    return ease_in_sine(t);
702}
703
704
705#[wasm_bindgen(js_name = easeOutSine)]
706pub fn ease_out_sine_js(t: f64) -> f64 {
707    return ease_out_sine(t);
708}
709
710
711#[wasm_bindgen(js_name = easeInOutSine)]
712pub fn ease_in_out_sine_js(t: f64) -> f64 {
713    return ease_in_out_sine(t);
714}
715
716
717#[wasm_bindgen(js_name = easeInQuad)]
718pub fn ease_in_quad_js(t: f64) -> f64 {
719    return ease_in_quad(t);
720}
721
722
723#[wasm_bindgen(js_name = easeOutQuad)]
724pub fn ease_out_quad_js(t: f64) -> f64 {
725    return ease_out_quad(t);
726}
727
728
729#[wasm_bindgen(js_name = easeInOutQuad)]
730pub fn ease_in_out_quad_js(t: f64) -> f64 {
731    return ease_in_out_quad(t);
732}
733
734
735#[wasm_bindgen(js_name = easeInCubic)]
736pub fn ease_in_cubic_js(t: f64) -> f64 {
737    return ease_in_cubic(t);
738}
739
740
741#[wasm_bindgen(js_name = easeOutCubic)]
742pub fn ease_out_cubic_js(t: f64) -> f64 {
743    return ease_out_cubic(t);
744}
745
746
747#[wasm_bindgen(js_name = easeInOutCubic)]
748pub fn ease_in_out_cubic_js(t: f64) -> f64 {
749    return ease_in_out_cubic(t);
750}
751
752
753#[wasm_bindgen(js_name = easeInQuart)]
754pub fn ease_in_quart_js(t: f64) -> f64 {
755    return ease_in_quart(t);
756}
757
758
759#[wasm_bindgen(js_name = easeOutQuart)]
760pub fn ease_out_quart_js(t: f64) -> f64 {
761    return ease_out_quart(t);
762}
763
764
765#[wasm_bindgen(js_name = easeInOutQuart)]
766pub fn ease_in_out_quart_js(t: f64) -> f64 {
767    return ease_in_out_quart(t);
768}
769
770
771#[wasm_bindgen(js_name = easeInQuint)]
772pub fn ease_in_quint_js(t: f64) -> f64 {
773    return ease_in_quint(t);
774}
775
776
777#[wasm_bindgen(js_name = easeOutQuint)]
778pub fn ease_out_quint_js(t: f64) -> f64 {
779    return ease_out_quint(t);
780}
781
782
783#[wasm_bindgen(js_name = easeInOutQuint)]
784pub fn ease_in_out_quint_js(t: f64) -> f64 {
785    return ease_in_out_quint(t);
786}
787
788
789#[wasm_bindgen(js_name = easeInExpo)]
790pub fn ease_in_expo_js(t: f64) -> f64 {
791    return ease_in_expo(t);
792}
793
794
795#[wasm_bindgen(js_name = easeOutExpo)]
796pub fn ease_out_expo_js(t: f64) -> f64 {
797    return ease_out_expo(t);
798}
799
800
801#[wasm_bindgen(js_name = easeInOutExpo)]
802pub fn ease_in_out_expo_js(t: f64) -> f64 {
803    return ease_in_out_expo(t);
804}
805
806
807#[wasm_bindgen(js_name = easeInCirc)]
808pub fn ease_in_circ_js(t: f64) -> f64 {
809    return ease_in_circ(t);
810}
811
812
813#[wasm_bindgen(js_name = easeOutCirc)]
814pub fn ease_out_circ_js(t: f64) -> f64 {
815    return ease_out_circ(t);
816}
817
818
819#[wasm_bindgen(js_name = easeInOutCirc)]
820pub fn ease_in_out_circ_js(t: f64) -> f64 {
821    return ease_in_out_circ(t);
822}
823
824
825#[wasm_bindgen(js_name = easeInBack)]
826pub fn ease_in_back_js(t: f64) -> f64 {
827    return ease_in_back(t);
828}
829
830
831#[wasm_bindgen(js_name = easeOutBack)]
832pub fn ease_out_back_js(t: f64) -> f64 {
833    return ease_in_back(t);
834}
835
836
837#[wasm_bindgen(js_name = easeInOutBack)]
838pub fn ease_in_out_back_js(t: f64) -> f64 {
839    return ease_in_out_back(t);
840}
841
842
843#[wasm_bindgen(js_name = easeInElastic)]
844pub fn ease_in_elastic_js(t: f64) -> f64 {
845    return ease_in_elastic(t);
846}
847
848
849#[wasm_bindgen(js_name = easeOutElastic)]
850pub fn ease_out_elastic_js(t: f64) -> f64 {
851    return ease_out_elastic(t);
852}
853
854
855#[wasm_bindgen(js_name = easeInOutElastic)]
856pub fn ease_in_out_elastic_js(t: f64) -> f64 {
857    return ease_in_out_elastic(t);
858}
859
860
861#[wasm_bindgen(js_name = easeOutBounce)]
862pub fn ease_out_bounce_js(t: f64) -> f64 {
863    return ease_out_bounce(t);
864}
865
866
867#[wasm_bindgen(js_name = easeInBounce)]
868pub fn ease_in_bounce_js(t: f64) -> f64 {
869    return ease_out_bounce(t);
870}
871
872
873#[wasm_bindgen(js_name = easeInOutBounce)]
874pub fn ease_in_out_bounce_js(t: f64) -> f64 {
875    return ease_in_out_bounce(t);
876}