pub struct Graph {
pub expressions: Vec<AnalyzedExpr>,
pub points: Vec<Point<f64>>,
pub options: GraphOptions,
}
Expand description
A graph containing expressions and points to draw.
See the module-level documentation for more information.
Fields§
§expressions: Vec<AnalyzedExpr>
The expressions to draw.
points: Vec<Point<f64>>
The points to draw.
options: GraphOptions
The rendering options for the graph.
Implementations§
Source§impl Graph
impl Graph
Sourcepub fn with_opts(options: GraphOptions) -> Graph
pub fn with_opts(options: GraphOptions) -> Graph
Create a new graph with the given options.
Sourcepub fn add_expr(&mut self, expr: Expr) -> &mut Self
pub fn add_expr(&mut self, expr: Expr) -> &mut Self
Add an expression to the graph.
Returns a mutable reference to the graph to allow chaining.
Sourcepub fn try_add_expr(&mut self, expr: &str) -> Result<&mut Self, Vec<Error>>
pub fn try_add_expr(&mut self, expr: &str) -> Result<&mut Self, Vec<Error>>
Tries to parse the given expression and add it to the graph.
Returns a mutable reference to the graph to allow chaining.
Sourcepub fn add_analyzed_expr(&mut self, expr: AnalyzedExpr) -> &mut Self
pub fn add_analyzed_expr(&mut self, expr: AnalyzedExpr) -> &mut Self
Adds an expression that has already been analyzed to the graph.
Returns a mutable reference to the graph to allow chaining.
Sourcepub fn add_point(&mut self, point: impl Into<Point<f64>>) -> &mut Self
pub fn add_point(&mut self, point: impl Into<Point<f64>>) -> &mut Self
Add a point to the graph.
Returns a mutable reference to the graph to allow chaining.
Sourcepub fn center_on_points(&mut self) -> &mut Self
pub fn center_on_points(&mut self) -> &mut Self
Center the graph on the points in the graph and scale it so that all points are visible.
Returns a mutable reference to the graph to allow chaining.
Sourcepub fn draw(&self) -> Result<ImageSurface, Error>
pub fn draw(&self) -> Result<ImageSurface, Error>
Creates an ImageSurface
with the graph’s canvas size and draws the graph to it.
The resulting ImageSurface
can be written to a file or manipulated further.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnwindSafe for Graph
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more