Components / CurveEditor
CurveEditor
Points you drag over a smooth curve, with an optional histogram behind.
Example
The component itself, running in WebAssembly, beside its code in a playground. Try it.
Code
use ravenrs::prelude::*;
fn curve_editor() -> impl View {
let points = State::new(vec![
Point::new(0.0, 0.0),
Point::new(0.3, 0.2),
Point::new(0.7, 0.85),
Point::new(1.0, 1.0),
]);
let hill: Vec<f32> = (0..128).map(|i| 50.0 * (-((i as f32 - 60.0) / 30.0).powi(2)).exp()).collect();
CurveEditor::new(points.binding())
.height(190.0)
.histogram([HistogramChannel::new("Light", Color::rgb(0.6, 0.6, 0.6), hill)], HistogramScale::Linear)
.label("Tone curve")
}