Thanks to visit codestin.com
Credit goes to docs.rs

Window

Struct Window 

Source
pub struct Window { /* private fields */ }
Expand description

Used to render Array objects

The renderings can be either plots, histograms or simply just image displays. A single window can also display multiple of the above renderings at the same time, which is known as multiview mode. An example of that is given below.

§Examples

use arrayfire::{histogram, load_image, Window};
let mut wnd = Window::new(1280, 720, String::from("Image Histogram"));
let img = load_image::<f32>("Path to image".to_string(), true/*If color image, 'false' otherwise*/);
let hst = histogram(&img, 256, 0 as f64, 255 as f64);

loop {
    wnd.grid(2, 1);

    wnd.set_view(0, 0);
    wnd.draw_image(&img, Some("Input Image".to_string()));

    wnd.set_view(1, 0);
    wnd.draw_hist(&hst, 0.0, 255.0, Some("Input Image Histogram".to_string()));

    wnd.show();

    if wnd.is_closed() == true { break; }
}

Implementations§

Source§

impl Window

Source

pub fn new(width: i32, height: i32, title: String) -> Self

Creates new Window object

§Parameters
  • width is width of the window
  • height is the height of window
  • title is the string displayed on window title bar
§Return Values

Window Object

Source

pub fn set_position(&self, x: u32, y: u32)

Set window starting position on the screen

§Parameters
  • x is the horiontal coordinate where window is to be placed
  • y is the vertical coordinate where window is to be placed
Source

pub fn set_title(&self, title: String)

Set window title

§Parameters
  • title is the string to be displayed on window title bar
Source

pub fn set_visibility(&self, is_visible: bool)

Set window visibility

§Parameters
  • is_visible is a boolean indicating whether window is to be hidden or brought into focus
§Return Values

None

Source

pub fn set_size(&self, w: u32, h: u32)

Set window size

§Parameters
  • w is the target width of window
  • h is the target height of window
Source

pub fn set_colormap(&mut self, cmap: ColorMap)

Set color map to be used for rendering image, it can take one of the values of enum ColorMap

Source

pub fn is_closed(&self) -> bool

Returns true if the window close is triggered by the user

Source

pub fn grid(&self, rows: i32, cols: i32)

Setup display layout in multiview mode

§Parameters
  • rows is the number of rows into which whole window is split into in multiple view mode
  • cols is the number of cols into which whole window is split into in multiple view mode
Source

pub fn show(&mut self)

Used in multiview mode to swap back buffer with front buffer to show the recently rendered frame

Source

pub fn set_view(&mut self, r: i32, c: i32)

Set the current sub-region to render

This function is only to be used into multiview mode

§Parameters
  • r is the target row id
  • c is the target row id
Source

pub fn set_axes_titles( &mut self, xlabel: String, ylabel: String, zlabel: String, )

Set chart axes titles

§Parameters
  • xlabel is x axis title
  • ylabel is y axis title
  • zlabel is z axis title
Source

pub fn set_axes_label_format( &mut self, xlabel_format: String, ylabel_format: String, zlabel_format: String, )

Set chart axes labels format

§Parameters
  • xlabel_format is x axis label format. format specific is identical to C’s printf format
  • ylabel_format is y axis label format. format specific is identical to C’s printf format
  • zlabel_format is z axis label format. format specific is identical to C’s printf format
Source

pub fn set_axes_label_formats( &mut self, xformat: String, yformat: String, zformat: String, )

Set chart axes labels formats

Axes labels use printf style format specifiers. Default specifier for the data displayed as labels is %4.1f. This function lets the user change this label formatting to whichever format that fits their data range and precision.

§Parameters
  • xlabel is printf style format specifier for x axis
  • ylabel is printf style format specifier for y axis
  • zlabel is printf style format specifier for z axis
Source

pub fn set_axes_limits_compute<T>( &mut self, xrange: &Array<T>, yrange: &Array<T>, zrange: Option<&Array<T>>, exact: bool, )
where T: HasAfEnum,

Set chart axes limits by computing limits from data

In multiple view (grid) mode, setting limits will effect the chart that is currently active via set_view call

§Parameters
  • xrange is set of all x values to compute min/max for x axis
  • yrange is set of all y values to compute min/max for y axis
  • zrange is set of all z values to compute min/max for z axis. If None is passed to this paramter, 2d chart limits are set.
  • exact indicates if the exact min/max values from xrange, yrange and zrange are to extracted. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.
Source

pub fn set_axes_limits_2d( &mut self, xmin: f32, xmax: f32, ymin: f32, ymax: f32, exact: bool, )

Set 2d chart axes limits

In multiple view (grid) mode, setting limits will effect the chart that is currently active via set_view call

§Parameters
  • xmin is minimum value on x axis
  • xmax is maximum value on x axis
  • ymin is minimum value on y axis
  • ymax is maximum value on y axis
  • exact indicates if the exact min/max values from xrange, yrange and zrange are to extracted. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.
Source

pub fn set_axes_limits_3d( &mut self, xmin: f32, xmax: f32, ymin: f32, ymax: f32, zmin: f32, zmax: f32, exact: bool, )

Set 3d chart axes limits

In multiple view (grid) mode, setting limits will effect the chart that is currently active via set_view call

§Parameters
  • xmin is minimum value on x axis
  • xmax is maximum value on x axis
  • ymin is minimum value on y axis
  • ymax is maximum value on y axis
  • zmin is minimum value on z axis
  • zmax is maximum value on z axis
  • exact indicates if the exact min/max values from xrange, yrange and zrange are to extracted. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.
Source

pub fn draw_image<T>(&self, input: &Array<T>, title: Option<String>)
where T: HasAfEnum,

Render given Array as an image

§Parameters
  • input image
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_plot2<T>(&self, x: &Array<T>, y: &Array<T>, title: Option<String>)
where T: HasAfEnum,

Render given two Array’s x and y as a 2d line plot

§Parameters
  • x is the x coordinates of the plot
  • y is the y coordinates of the plot
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_plot3<T>( &self, x: &Array<T>, y: &Array<T>, z: &Array<T>, title: Option<String>, )
where T: HasAfEnum,

Render given Array’s x, y and z as a 3d line plot

§Parameters
  • x is the x coordinates of the plot
  • y is the y coordinates of the plot
  • z is the z coordinates of the plot
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_plot<T>(&self, points: &Array<T>, title: Option<String>)
where T: HasAfEnum,

Render give Arrays of points as a 3d line plot

§Parameters
  • points is an Array containing list of points of plot
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_hist<T>( &self, hst: &Array<T>, minval: f64, maxval: f64, title: Option<String>, )
where T: HasAfEnum,

Render given Array as a histogram

§Parameters
  • hst is an Array containing histogram data
  • minval is the minimum bin value of histogram
  • maxval is the maximum bin value of histogram
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_surface<T>( &self, xvals: &Array<T>, yvals: &Array<T>, zvals: &Array<T>, title: Option<String>, )
where T: HasAfEnum,

Render give Arrays as 3d surface

§Parameters
  • x is the x coordinates of the surface plot
  • y is the y coordinates of the surface plot
  • z is the z coordinates of the surface plot
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_scatter2<T>( &self, xvals: &Array<T>, yvals: &Array<T>, marker: MarkerType, title: Option<String>, )
where T: HasAfEnum,

Render given Arrays as 2d scatter plot

§Parameters
  • xvals is the x coordinates of the scatter plot
  • yvals is the y coordinates of the scatter plot
  • marker is of enum type MarkerType
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_scatter3<T>( &self, xvals: &Array<T>, yvals: &Array<T>, zvals: &Array<T>, marker: MarkerType, title: Option<String>, )
where T: HasAfEnum,

Render given Arrays as 3d scatter plot

§Parameters
  • xvals is the x coordinates of the scatter plot
  • yvals is the y coordinates of the scatter plot
  • zvals is the z coordinates of the scatter plot
  • marker is of enum type MarkerType
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_scatter<T>( &self, vals: &Array<T>, marker: MarkerType, title: Option<String>, )
where T: HasAfEnum,

Render give Array as 3d scatter plot

§Parameters
  • points is an Array containing list of points of plot
  • marker is of enum type MarkerType
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_vector_field2<T>( &self, xpnts: &Array<T>, ypnts: &Array<T>, xdirs: &Array<T>, ydirs: &Array<T>, title: Option<String>, )
where T: HasAfEnum,

Render given Arrays as 2d vector field

§Parameters
  • xpnts is an Array containing list of x coordinates
  • xdirs is an Array containing direction component of x coord
  • ypnts is an Array containing list of y coordinates
  • ydirs is an Array containing direction component of y coord
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_vector_field3<T>( &self, xpnts: &Array<T>, ypnts: &Array<T>, zpnts: &Array<T>, xdirs: &Array<T>, ydirs: &Array<T>, zdirs: &Array<T>, title: Option<String>, )
where T: HasAfEnum,

Render given Arrays as 3d vector field

§Parameters
  • xpnts is an Array containing list of x coordinates
  • xdirs is an Array containing direction component of x coord
  • ypnts is an Array containing list of y coordinates
  • ydirs is an Array containing direction component of y coord
  • zpnts is an Array containing list of z coordinates
  • zdirs is an Array containing direction component of z coord
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Source

pub fn draw_vector_field<T>( &self, points: &Array<T>, directions: &Array<T>, title: Option<String>, )
where T: HasAfEnum,

Render given Array as vector field

§Parameters
  • points is an Array containing list of coordinates of vector field
  • directions is an Array containing directions at the coordinates specified in points Array.
  • title parameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.

Trait Implementations§

Source§

impl Clone for Window

Source§

fn clone(&self) -> Window

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

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

Performs copy-assignment from source. Read more
Source§

impl Drop for Window

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Window

§

impl RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl Unpin for Window

§

impl UnwindSafe for Window

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<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.