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
impl Window
Sourcepub fn set_position(&self, x: u32, y: u32)
pub fn set_position(&self, x: u32, y: u32)
Set window starting position on the screen
§Parameters
xis the horiontal coordinate where window is to be placedyis the vertical coordinate where window is to be placed
Sourcepub fn set_visibility(&self, is_visible: bool)
pub fn set_visibility(&self, is_visible: bool)
Sourcepub fn set_colormap(&mut self, cmap: ColorMap)
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
Sourcepub fn grid(&self, rows: i32, cols: i32)
pub fn grid(&self, rows: i32, cols: i32)
Setup display layout in multiview mode
§Parameters
rowsis the number of rows into which whole window is split into in multiple view modecolsis the number of cols into which whole window is split into in multiple view mode
Sourcepub fn show(&mut self)
pub fn show(&mut self)
Used in multiview mode to swap back buffer with front buffer to show the recently rendered frame
Sourcepub fn set_view(&mut self, r: i32, c: i32)
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
ris the target row idcis the target row id
Sourcepub fn set_axes_titles(
&mut self,
xlabel: String,
ylabel: String,
zlabel: String,
)
pub fn set_axes_titles( &mut self, xlabel: String, ylabel: String, zlabel: String, )
Set chart axes titles
§Parameters
xlabelis x axis titleylabelis y axis titlezlabelis z axis title
Sourcepub fn set_axes_label_format(
&mut self,
xlabel_format: String,
ylabel_format: String,
zlabel_format: String,
)
pub fn set_axes_label_format( &mut self, xlabel_format: String, ylabel_format: String, zlabel_format: String, )
Set chart axes labels format
§Parameters
xlabel_formatis x axis label format. format specific is identical to C’s printf formatylabel_formatis y axis label format. format specific is identical to C’s printf formatzlabel_formatis z axis label format. format specific is identical to C’s printf format
Sourcepub fn set_axes_label_formats(
&mut self,
xformat: String,
yformat: String,
zformat: String,
)
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
xlabelis printf style format specifier for x axisylabelis printf style format specifier for y axiszlabelis printf style format specifier for z axis
Sourcepub fn set_axes_limits_compute<T>(
&mut self,
xrange: &Array<T>,
yrange: &Array<T>,
zrange: Option<&Array<T>>,
exact: bool,
)where
T: HasAfEnum,
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
xrangeis set of all x values to compute min/max for x axisyrangeis set of all y values to compute min/max for y axiszrangeis set of all z values to compute min/max for z axis. If None is passed to this paramter, 2d chart limits are set.exactindicates if the exact min/max values fromxrange,yrangeandzrangeare 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.
Sourcepub fn set_axes_limits_2d(
&mut self,
xmin: f32,
xmax: f32,
ymin: f32,
ymax: f32,
exact: bool,
)
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
xminis minimum value on x axisxmaxis maximum value on x axisyminis minimum value on y axisymaxis maximum value on y axisexactindicates if the exact min/max values fromxrange,yrangeandzrangeare 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.
Sourcepub fn set_axes_limits_3d(
&mut self,
xmin: f32,
xmax: f32,
ymin: f32,
ymax: f32,
zmin: f32,
zmax: f32,
exact: bool,
)
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
xminis minimum value on x axisxmaxis maximum value on x axisyminis minimum value on y axisymaxis maximum value on y axiszminis minimum value on z axiszmaxis maximum value on z axisexactindicates if the exact min/max values fromxrange,yrangeandzrangeare 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.
Sourcepub fn draw_image<T>(&self, input: &Array<T>, title: Option<String>)where
T: HasAfEnum,
pub fn draw_image<T>(&self, input: &Array<T>, title: Option<String>)where
T: HasAfEnum,
Render given Array as an image
§Parameters
inputimagetitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_plot2<T>(&self, x: &Array<T>, y: &Array<T>, title: Option<String>)where
T: HasAfEnum,
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
xis the x coordinates of the plotyis the y coordinates of the plottitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_plot3<T>(
&self,
x: &Array<T>,
y: &Array<T>,
z: &Array<T>,
title: Option<String>,
)where
T: HasAfEnum,
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
xis the x coordinates of the plotyis the y coordinates of the plotzis the z coordinates of the plottitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_plot<T>(&self, points: &Array<T>, title: Option<String>)where
T: HasAfEnum,
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
pointsis an Array containing list of points of plottitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_hist<T>(
&self,
hst: &Array<T>,
minval: f64,
maxval: f64,
title: Option<String>,
)where
T: HasAfEnum,
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
hstis an Array containing histogram dataminvalis the minimum bin value of histogrammaxvalis the maximum bin value of histogramtitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_surface<T>(
&self,
xvals: &Array<T>,
yvals: &Array<T>,
zvals: &Array<T>,
title: Option<String>,
)where
T: HasAfEnum,
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
xis the x coordinates of the surface plotyis the y coordinates of the surface plotzis the z coordinates of the surface plottitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_scatter2<T>(
&self,
xvals: &Array<T>,
yvals: &Array<T>,
marker: MarkerType,
title: Option<String>,
)where
T: HasAfEnum,
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
xvalsis the x coordinates of the scatter plotyvalsis the y coordinates of the scatter plotmarkeris of enum type MarkerTypetitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_scatter3<T>(
&self,
xvals: &Array<T>,
yvals: &Array<T>,
zvals: &Array<T>,
marker: MarkerType,
title: Option<String>,
)where
T: HasAfEnum,
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
xvalsis the x coordinates of the scatter plotyvalsis the y coordinates of the scatter plotzvalsis the z coordinates of the scatter plotmarkeris of enum type MarkerTypetitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_scatter<T>(
&self,
vals: &Array<T>,
marker: MarkerType,
title: Option<String>,
)where
T: HasAfEnum,
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
pointsis an Array containing list of points of plotmarkeris of enum type MarkerTypetitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_vector_field2<T>(
&self,
xpnts: &Array<T>,
ypnts: &Array<T>,
xdirs: &Array<T>,
ydirs: &Array<T>,
title: Option<String>,
)where
T: HasAfEnum,
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
xpntsis an Array containing list of x coordinatesxdirsis an Array containing direction component of x coordypntsis an Array containing list of y coordinatesydirsis an Array containing direction component of y coordtitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub 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,
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
xpntsis an Array containing list of x coordinatesxdirsis an Array containing direction component of x coordypntsis an Array containing list of y coordinatesydirsis an Array containing direction component of y coordzpntsis an Array containing list of z coordinateszdirsis an Array containing direction component of z coordtitleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.
Sourcepub fn draw_vector_field<T>(
&self,
points: &Array<T>,
directions: &Array<T>,
title: Option<String>,
)where
T: HasAfEnum,
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
pointsis an Array containing list of coordinates of vector fielddirectionsis an Array containing directions at the coordinates specified inpointsArray.titleparameter has effect only in multiview mode, where this string is displayed as the respective cell/view title.