splines/examples/serialization.rs

32 lines
516 B
Rust
Raw Normal View History

2020-03-18 11:59:22 +01:00
#[macro_use]
extern crate serde_json;
2018-08-08 00:23:53 +02:00
extern crate splines;
2019-04-17 14:16:42 +02:00
use serde_json::from_value;
2018-08-08 00:23:53 +02:00
use splines::Spline;
fn main() {
2020-03-19 01:22:26 +01:00
let value = json! {
[
{
"t": 0,
"interpolation": "linear",
"value": 0
},
{
"t": 1,
"interpolation": { "step": 0.5 },
"value": 1
},
{
"t": 5,
"interpolation": "cosine",
"value": 10
},
]
};
2018-08-08 00:23:53 +02:00
2020-03-19 01:22:26 +01:00
let spline = from_value::<Spline<f32, f32>>(value);
println!("{:?}", spline);
2018-08-08 00:23:53 +02:00
}