Struct TriangleArrow

Source
pub struct TriangleArrow<Coord, Size: SizeDesc> { /* private fields */ }

Implementations§

Source§

impl<Coord> TriangleArrow<Coord, i32>

Source

pub fn new(nock: Coord, tip: Coord, style: impl Into<ShapeStyle>) -> Self

Examples found in repository?
examples/triangle-arrows.rs (line 31)
7fn main() -> Result<(), DrawingAreaErrorKind<<BitMapBackend<'static> as DrawingBackend>::ErrorType>>
8{
9    let target = Path::new("example.png");
10    let graph_root = BitMapBackend::new(target, (256, 256)).into_drawing_area();
11    graph_root.fill(&WHITE)?;
12    let mut chart = ChartBuilder::on(&graph_root)
13        .margin(8)
14        .x_label_area_size(24)
15        .y_label_area_size(24)
16        .build_cartesian_2d(0f64..1f64, 0f64..1f64)?;
17
18    chart.configure_mesh().draw()?;
19
20    let x_count = 16;
21    let y_count = 16;
22    let arrow_size = 0.05;
23    chart.draw_series(
24        (0..=x_count)
25            .flat_map(|xi| (0..=y_count).map(move |yi| (xi, yi)))
26            .map(|(xi, yi)| {
27                let x = xi as f64 / x_count as f64;
28                let y = yi as f64 / y_count as f64;
29                let dx = arrow_size * f64::cos(y * TAU);
30                let dy = arrow_size * f64::cos(x * TAU);
31                TriangleArrow::new((x, y), (x + dx, y + dy), &RED)
32            }),
33    )?;
34
35    graph_root.present()?;
36
37    Ok(())
38}
Source§

impl<Coord, Size: SizeDesc> TriangleArrow<Coord, Size>

Source

pub fn new_detail( nock: Coord, tip: Coord, head: Size, width: Size, style: impl Into<ShapeStyle>, ) -> Self

Source

pub fn head(self, head: Size) -> Self

Source

pub fn width(self, width: Size) -> Self

Trait Implementations§

Source§

impl<Coord: Clone, Size: Clone + SizeDesc> Clone for TriangleArrow<Coord, Size>

Source§

fn clone(&self) -> TriangleArrow<Coord, Size>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<DB: DrawingBackend, Coord, Size: SizeDesc> Drawable<DB> for TriangleArrow<Coord, Size>

Source§

fn draw<I: Iterator<Item = BackendCoord>>( &self, pos: I, backend: &mut DB, parent_dim: (u32, u32), ) -> Result<(), DrawingErrorKind<DB::ErrorType>>

Actually draws the element. The key points is already translated into the image coordinate and can be used by DC directly
Source§

impl<'a, Coord: 'a, Size: SizeDesc> PointCollection<'a, Coord> for &'a TriangleArrow<Coord, Size>

Source§

type Point = &'a Coord

The item in point iterator
Source§

type IntoIter = &'a [Coord]

The point iterator
Source§

fn point_iter(self) -> Self::IntoIter

framework to do the coordinate mapping

Auto Trait Implementations§

§

impl<Coord, Size> Freeze for TriangleArrow<Coord, Size>
where Size: Freeze, Coord: Freeze,

§

impl<Coord, Size> RefUnwindSafe for TriangleArrow<Coord, Size>
where Size: RefUnwindSafe, Coord: RefUnwindSafe,

§

impl<Coord, Size> Send for TriangleArrow<Coord, Size>
where Size: Send, Coord: Send,

§

impl<Coord, Size> Sync for TriangleArrow<Coord, Size>
where Size: Sync, Coord: Sync,

§

impl<Coord, Size> Unpin for TriangleArrow<Coord, Size>
where Size: Unpin, Coord: Unpin,

§

impl<Coord, Size> UnwindSafe for TriangleArrow<Coord, Size>
where Size: UnwindSafe, Coord: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'b, T, DB, Coord> IntoDynElement<'b, DB, Coord> for T
where T: Drawable<DB> + 'b, &'a T: for<'a> PointCollection<'a, Coord>, Coord: Clone, DB: DrawingBackend,

Source§

fn into_dyn(self) -> DynElement<'b, DB, Coord>

Make the conversion
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.