splines/examples/serialization.rs

31 lines
515 B
Rust
Raw Normal View History

2018-08-08 00:23:53 +02:00
#[macro_use] extern crate serde_json;
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() {
let value = json!{
[
{
"t": 0,
"interpolation": "linear",
"value": 0
},
{
"t": 1,
"interpolation": { "step": 0.5 },
"value": 1
},
{
"t": 5,
"interpolation": "cosine",
"value": 10
},
]
};
2019-04-17 14:16:42 +02:00
let spline = from_value::<Spline<f32, f32>>(value);
2018-08-08 00:23:53 +02:00
println!("{:?}", spline);
}