pub struct CurveEditor { /* private fields */ }Expand description
Editable points over a smooth curve that never swings past them. A press on empty space adds a point and a drag moves it; a double click or Delete removes one, except the two ends. From the keyboard, the arrows move the chosen point (with Shift, further), Page Up and Page Down choose another, and Enter adds one on the curve halfway to the next.
Points go from 0 to 1 on both axes, with the input in x. They are kept in order of x.
use ravenrs_core::Point;
use ravenrs_reactive::State;
use ravenrs_widgets::CurveEditor;
let tones = State::new(vec![Point::ZERO, Point::new(0.4, 0.55), Point::new(1.0, 1.0)]);
let editor = CurveEditor::new(tones.binding()).height(220.0).label("Tone curve");
let middle = CurveEditor::value_at(&tones.get(), 0.5);
assert!(middle > 0.55 && middle < 1.0);Implementations§
Source§impl CurveEditor
impl CurveEditor
Sourcepub fn new(points: Binding<Vec<Point>>) -> Self
pub fn new(points: Binding<Vec<Point>>) -> Self
An editor of points, across its parent, 200 logical pixels tall.
Sourcepub fn value_at(points: &[Point], x: f32) -> f32
pub fn value_at(points: &[Point], x: f32) -> f32
What the curve through points gives for the input x, for applying it. It uses the
same curve the editor draws.
Sourcepub fn color(self, color: Color) -> Self
pub fn color(self, color: Color) -> Self
The color of the curve and its handles, as data, such as a channel’s (ink by default).
Sourcepub fn baseline(self, baseline: bool) -> Self
pub fn baseline(self, baseline: bool) -> Self
Shows the straight line of no change behind the curve (on by default).
Sourcepub fn grid(self, parts: u32) -> Self
pub fn grid(self, parts: u32) -> Self
Divides the plot in this many parts each way, with light lines (4 by default).
Sourcepub fn histogram(
self,
channels: impl IntoIterator<Item = HistogramChannel>,
scale: HistogramScale,
) -> Self
pub fn histogram( self, channels: impl IntoIterator<Item = HistogramChannel>, scale: HistogramScale, ) -> Self
Shows these channels behind the curve, as a Histogram does, faintly.
Trait Implementations§
Source§impl Debug for CurveEditor
impl Debug for CurveEditor
Auto Trait Implementations§
impl !RefUnwindSafe for CurveEditor
impl !Send for CurveEditor
impl !Sync for CurveEditor
impl !UnwindSafe for CurveEditor
impl Freeze for CurveEditor
impl Unpin for CurveEditor
impl UnsafeUnpin for CurveEditor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.