A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
Window Functions
Graphics

## Functions
| Window ()
| Creates a window object with default width and height with title set to "ArrayFire".
| Window (const char *const title)
| Creates a window object with default width and height using the title provided by the user.
| Window (const int width, const int height, const char *const title="ArrayFire")
| Creates a window object using the parameters provided by the user.
| Window (const af_window window)
| Creates a window object with default width and height with title set to "ArrayFire".
| ~Window ()
| Destroys the window handle.
af_window | get () const
void | setPos (const unsigned x, const unsigned y)
| Set the start position where the window will appear.
void | setTitle (const char *const title)
| Set the window title.
void | setSize (const unsigned w, const unsigned h)
| Set the window size.
void | setColorMap (const ColorMap cmap)
| Set the colormap to be used for subsequent rendering calls.
void | setAxesLimits (const array &x, const array &y, const bool exact=false)
| Setup the axes limits for a 2D histogram/plot/vector field.
void | setAxesLimits (const array &x, const array &y, const array &z, const bool exact=false)
| Setup the axes limits for a histogram/plot/surface/vector field.
void | setAxesLimits (const float xmin, const float xmax, const float ymin, const float ymax, const bool exact=false)
| Setup the axes limits for a histogram/plot/surface/vector field.
void | setAxesLimits (const float xmin, const float xmax, const float ymin, const float ymax, const float zmin, const float zmax, const bool exact=false)
| Setup the axes limits for a histogram/plot/surface/vector field.
void | setAxesTitles (const char *const xtitle="X-Axis", const char *const ytitle="Y-Axis", const char *const ztitle=NULL)
| Setup the axes titles for a plot/surface/vector field.
void | setAxesLabelFormat (const char *const xformat="4.1%f", const char *const yformat="4.1%f", const char *const zformat=NULL)
| Setup the axes label formats for charts.
void | grid (const int rows, const int cols)
| Setup grid layout for multiview mode in a window.
void | show ()
| This function swaps the background buffer to current view and polls for any key strokes while the window was in focus.
bool | close ()
| Check if window is marked for close.
void | setVisibility (const bool isVisible)
| Hide/Show the window.
AFAPI af_err | af_create_window (af_window *out, const int width, const int height, const char *const title)
| C Interface wrapper for creating a window.
AFAPI af_err | af_set_position (const af_window wind, const unsigned x, const unsigned y)
| C Interface wrapper for setting the start position when window is displayed.
AFAPI af_err | af_set_title (const af_window wind, const char *const title)
| C Interface wrapper for setting window title.
AFAPI af_err | af_set_size (const af_window wind, const unsigned w, const unsigned h)
| C Interface wrapper for setting window position.
AFAPI af_err | af_grid (const af_window wind, const int rows, const int cols)
| C Interface wrapper for grid setup in a window.
AFAPI af_err | af_set_axes_limits_compute (const af_window wind, const af_array x, const af_array y, const af_array z, const bool exact, const af_cell *const props)
| C Interface for setting axes limits for a histogram/plot/surface/vector field.
AFAPI af_err | af_set_axes_limits_2d (const af_window wind, const float xmin, const float xmax, const float ymin, const float ymax, const bool exact, const af_cell *const props)
| C Interface for setting axes limits for a 2D histogram/plot/vector field.
AFAPI af_err | af_set_axes_limits_3d (const af_window wind, const float xmin, const float xmax, const float ymin, const float ymax, const float zmin, const float zmax, const bool exact, const af_cell *const props)
| C Interface for setting axes limits for a 3D plot/surface/vector field.
AFAPI af_err | af_set_axes_titles (const af_window wind, const char *const xtitle, const char *const ytitle, const char *const ztitle, const af_cell *const props)
| C Interface wrapper for setting axes titles for histogram/plot/surface/vector field.
AFAPI af_err | af_set_axes_label_format (const af_window wind, const char *const xformat, const char *const yformat, const char *const zformat, const af_cell *const props)
| C Interface wrapper for setting axes labels formats for charts.
AFAPI af_err | af_show (const af_window wind)
| C Interface wrapper for showing a window.
AFAPI af_err | af_is_window_closed (bool *out, const af_window wind)
| C Interface wrapper for checking if window is marked for close.
AFAPI af_err | af_set_visibility (const af_window wind, const bool is_visible)
| Hide/Show a window.
AFAPI af_err | af_destroy_window (const af_window wind)
| C Interface wrapper for destroying a window handle.

## Detailed Description

Window creation, modification and destruction functions.

## Function Documentation

## ◆ af_create_window()

AFAPI af_err af_create_window | ( | af_window * | out,
|  | const int | width,
|  | const int | height,
|  | const char *const | title )

C Interface wrapper for creating a window.

Parameters

  [out] | out | is the handle to the created window
  [in] | width | is the width of the window that will be created
  [in] | height | is the height of the window that will be created
  [in] | title | is the window title

Returns
  AF_SUCCESS if window creation is successful, otherwise an appropriate error code is returned.

## ◆ af_destroy_window()

AFAPI af_err af_destroy_window | ( | const af_window | wind | ) |

C Interface wrapper for destroying a window handle.

Parameters

  [in] | wind | is the window handle

Returns
  AF_SUCCESS if window destroy is successful, otherwise an appropriate error code is returned.

## ◆ af_grid()

AFAPI af_err af_grid | ( | const af_window | wind,
|  | const int | rows,
|  | const int | cols )

C Interface wrapper for grid setup in a window.

Parameters

  [in] | wind | is the window handle
  [in] | rows | is number of rows you want to show in a window
  [in] | cols | is number of coloumns you want to show in a window

Returns
  AF_SUCCESS if grid setup for window is successful, otherwise an appropriate error code is returned.

## ◆ af_is_window_closed()

AFAPI af_err af_is_window_closed | ( | bool * | out,
|  | const af_window | wind )

C Interface wrapper for checking if window is marked for close.

Parameters

  [out] | out | is a boolean which indicates whether window is marked for close. This usually happens when user presses ESC key while the window is in focus.
  [in] | wind | is the window handle

Returns
  AF_SUCCESS if `wind` show is successful, otherwise an appropriate error code is returned.

## ◆ af_set_axes_label_format()

AFAPI af_err af_set_axes_label_format | ( | const af_window | wind,
|  | const char *const | xformat,
|  | const char *const | yformat,
|  | const char *const | zformat,
|  | const af_cell *const | props )

C Interface wrapper for setting axes labels formats for charts.

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

  [in] | wind | is the window handle
  [in] | xformat | is a printf-style format specifier for x-axis
  [in] | yformat | is a printf-style format specifier for y-axis
  [in] | zformat | is a printf-style format specifier for z-axis
  [in] | props | is structure af_cell that has the properties that are used for the current rendering.

Note
  `zformat` can be NULL in which case ArrayFire understands that the label formats are meant for a 2D chart corresponding to this `wind` or a specific cell in multi-viewport mode (provided via `props` argument). A non NULL value to `zformat` means the label formats belong to a 3D chart.

## ◆ af_set_axes_limits_2d()

AFAPI af_err af_set_axes_limits_2d | ( | const af_window | wind,
|  | const float | xmin,
|  | const float | xmax,
|  | const float | ymin,
|  | const float | ymax,
|  | const bool | exact,
|  | const af_cell *const | props )

C Interface for setting axes limits for a 2D histogram/plot/vector field.

This function sets the axes limits to the ones provided by the user.

Parameters

  [in] | wind | is the window handle
  [in] | xmin | is the minimum on x-axis
  [in] | xmax | is the maximum on x-axis
  [in] | ymin | is the minimum on y-axis
  [in] | ymax | is the maximum on y-axis
  [in] | exact | is for using the exact min/max values from `x`, and `y`. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.
  [in] | props | is structure af_cell that has the properties that are used for the current rendering.

## ◆ af_set_axes_limits_3d()

AFAPI af_err af_set_axes_limits_3d | ( | const af_window | wind,
|  | const float | xmin,
|  | const float | xmax,
|  | const float | ymin,
|  | const float | ymax,
|  | const float | zmin,
|  | const float | zmax,
|  | const bool | exact,
|  | const af_cell *const | props )

C Interface for setting axes limits for a 3D plot/surface/vector field.

This function sets the axes limits to the ones provided by the user.

Parameters

  [in] | wind | is the window handle
  [in] | xmin | is the minimum on x-axis
  [in] | xmax | is the maximum on x-axis
  [in] | ymin | is the minimum on y-axis
  [in] | ymax | is the maximum on y-axis
  [in] | zmin | is the minimum on z-axis
  [in] | zmax | is the maximum on z-axis
  [in] | exact | is for using the exact min/max values from `x`, `y` and `z`. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.
  [in] | props | is structure af_cell that has the properties that are used for the current rendering.

## ◆ af_set_axes_limits_compute()

AFAPI af_err af_set_axes_limits_compute | ( | const af_window | wind,
|  | const af_array | x,
|  | const af_array | y,
|  | const af_array | z,
|  | const bool | exact,
|  | const af_cell *const | props )

C Interface for setting axes limits for a histogram/plot/surface/vector field.

This function computes the minimum and maximum for each dimension

Parameters

  [in] | wind | is the window handle
  [in] | x | the data to compute the limits for x-axis.
  [in] | y | the data to compute the limits for y-axis.
  [in] | z | the data to compute the limits for z-axis.
  [in] | exact | is for using the exact min/max values from `x`, `y` and `z`. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.
  [in] | props | is structure af_cell that has the properties that are used for the current rendering.

Note
  Set `to` NULL if the chart is 2D.

## ◆ af_set_axes_titles()

AFAPI af_err af_set_axes_titles | ( | const af_window | wind,
|  | const char *const | xtitle,
|  | const char *const | ytitle,
|  | const char *const | ztitle,
|  | const af_cell *const | props )

C Interface wrapper for setting axes titles for histogram/plot/surface/vector field.

Passing correct value to `ztitle` dictates the right behavior when it comes to setting the axes titles appropriately. If the user is targeting a two dimensional chart on the window `wind`, then the user needs to pass NULL to `ztitle` so that internal caching mechanism understands this window requires a 2D chart. Any non NULL value passed to `ztitle` will result in ArrayFire thinking the `wind` intends to use a 3D chart.

Parameters

  [in] | wind | is the window handle
  [in] | xtitle | is the name of the x-axis
  [in] | ytitle | is the name of the y-axis
  [in] | ztitle | is the name of the z-axis
  [in] | props | is structure af_cell that has the properties that are used for the current rendering.

## ◆ af_set_position()

AFAPI af_err af_set_position | ( | const af_window | wind,
|  | const unsigned | x,
|  | const unsigned | y )

C Interface wrapper for setting the start position when window is displayed.

Parameters

  [in] | wind | is the window handle
  [in] | x | is horizontal start coordinate
  [in] | y | is vertical start coordinate

Returns
  AF_SUCCESS if set position for window is successful, otherwise an appropriate error code is returned.

## ◆ af_set_size()

AFAPI af_err af_set_size | ( | const af_window | wind,
|  | const unsigned | w,
|  | const unsigned | h )

C Interface wrapper for setting window position.

Parameters

  [in] | wind | is the window handle
  [in] | w | is target width of the window
  [in] | h | is target height of the window

Returns
  AF_SUCCESS if set size for window is successful, otherwise an appropriate error code is returned.

## ◆ af_set_title()

AFAPI af_err af_set_title | ( | const af_window | wind,
|  | const char *const | title )

C Interface wrapper for setting window title.

Parameters

  [in] | wind | is the window handle
  [in] | title | is title of the window

Returns
  AF_SUCCESS if set title for window is successful, otherwise an appropriate error code is returned.

## ◆ af_set_visibility()

AFAPI af_err af_set_visibility | ( | const af_window | wind,
|  | const bool | is_visible )

Hide/Show a window.

Parameters

  [in] | wind | is the window whose visibility is to be changed
  [in] | is_visible | indicates if the window is to be hidden or brought into focus

## ◆ af_show()

AFAPI af_err af_show | ( | const af_window | wind | ) |

C Interface wrapper for showing a window.

Parameters

  [in] | wind | is the window handle

Returns
  AF_SUCCESS if window show is successful, otherwise an appropriate error code is returned.

## ◆ close()

bool close | ( |  | ) |

Check if window is marked for close.

This usually happens when user presses ESC key while the window is in focus.

Returns
  AF_SUCCESS if window show is successful, otherwise an appropriate error code is returned.

Examples
  computer_vision/fast.cpp, computer_vision/harris.cpp, computer_vision/susan.cpp, graphics/conway.cpp, graphics/conway_pretty.cpp, graphics/field.cpp, graphics/histogram.cpp, graphics/plot2d.cpp, graphics/plot3.cpp, graphics/surface.cpp, and pde/swe.cpp.

## ◆ get()

af_window get | ( |  | ) | const
| inline

Returns
  Returns the af_window window handle.

Definition at line 108 of file graphics.h.

108{ return wnd; }

## ◆ grid()

void grid | ( | const int | rows,
|  | const int | cols )

Setup grid layout for multiview mode in a window.

Parameters

  [in] | rows | is number of rows you want to divide the display area
  [in] | cols | is number of coloumns you want to divide the display area

Examples
  graphics/field.cpp, graphics/plot2d.cpp, and pde/swe.cpp.

## ◆ setAxesLabelFormat()

void setAxesLabelFormat | ( | const char *const | xformat = "4.1%f",
|  | const char *const | yformat = "4.1%f",
|  | const char *const | zformat = NULL )

Setup the axes label formats for charts.

Parameters

  [in] | xformat | is a printf-style format specifier for x-axis
  [in] | yformat | is a printf-style format specifier for y-axis
  [in] | zformat | is a printf-style format specifier for z-axis

## ◆ setAxesLimits() [1/4]

void setAxesLimits | ( | const array & | x,
|  | const array & | y,
|  | const array & | z,
|  | const bool | exact = false )

Setup the axes limits for a histogram/plot/surface/vector field.

This function computes the minimum and maximum for each dimension

Parameters

  [in] | x | the data to compute the limits for x-axis.
  [in] | y | the data to compute the limits for y-axis.
  [in] | z | the data to compute the limits for z-axis.
  [in] | exact | is for using the exact min/max values from `x` and `y`. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.

## ◆ setAxesLimits() [2/4]

void setAxesLimits | ( | const array & | x,
|  | const array & | y,
|  | const bool | exact = false )

Setup the axes limits for a 2D histogram/plot/vector field.

This function computes the minimum and maximum for each dimension

Parameters

  [in] | x | the data to compute the limits for x-axis.
  [in] | y | the data to compute the limits for y-axis.
  [in] | exact | is for using the exact min/max values from `x` and `y`. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.

## ◆ setAxesLimits() [3/4]

void setAxesLimits | ( | const float | xmin,
|  | const float | xmax,
|  | const float | ymin,
|  | const float | ymax,
|  | const bool | exact = false )

Setup the axes limits for a histogram/plot/surface/vector field.

This function sets the axes limits to the ones provided by the user.

Parameters

  [in] | xmin | is the minimum on x-axis
  [in] | xmax | is the maximum on x-axis
  [in] | ymin | is the minimum on y-axis
  [in] | ymax | is the maximum on y-axis
  [in] | exact | is for using the exact min/max values from `x` and `y`. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.

## ◆ setAxesLimits() [4/4]

void setAxesLimits | ( | const float | xmin,
|  | const float | xmax,
|  | const float | ymin,
|  | const float | ymax,
|  | const float | zmin,
|  | const float | zmax,
|  | const bool | exact = false )

Setup the axes limits for a histogram/plot/surface/vector field.

This function sets the axes limits to the ones provided by the user.

Parameters

  [in] | xmin | is the minimum on x-axis
  [in] | xmax | is the maximum on x-axis
  [in] | ymin | is the minimum on y-axis
  [in] | ymax | is the maximum on y-axis
  [in] | zmin | is the minimum on z-axis
  [in] | zmax | is the maximum on z-axis
  [in] | exact | is for using the exact min/max values from `x`, `y` and `z`. If exact is false then the most significant digit is rounded up to next power of 2 and the magnitude remains the same.

## ◆ setAxesTitles()

void setAxesTitles | ( | const char *const | xtitle = "X-Axis",
|  | const char *const | ytitle = "Y-Axis",
|  | const char *const | ztitle = NULL )

Setup the axes titles for a plot/surface/vector field.

This function creates the axis titles for a chart.

Parameters

  [in] | xtitle | is the name of the x-axis
  [in] | ytitle | is the name of the y-axis
  [in] | ztitle | is the name of the z-axis

Examples
  graphics/histogram.cpp.

## ◆ setColorMap()

void setColorMap | ( | const ColorMap | cmap | ) |

Set the colormap to be used for subsequent rendering calls.

Parameters

  [in] | cmap | should be one of the enum values from ColorMap

## ◆ setPos()

void setPos | ( | const unsigned | x,
|  | const unsigned | y )

Set the start position where the window will appear.

Parameters

  [in] | x | is horizontal coordinate
  [in] | y | is vertical coordinate

Examples
  graphics/conway_pretty.cpp, and graphics/histogram.cpp.

## ◆ setSize()

void setSize | ( | const unsigned | w,
|  | const unsigned | h )

Set the window size.

Parameters

  [in] | w | is target width of the window
  [in] | h | is target height of the window

## ◆ setTitle()

void setTitle | ( | const char *const | title | ) |

Set the window title.

Parameters

  [in] | title | is the window title

## ◆ setVisibility()

void setVisibility | ( | const bool | isVisible | ) |

Hide/Show the window.

Parameters

  [in] | isVisible | indicates if the window is to be hidden or brought into focus

## ◆ show()

void show | ( |  | ) |

This function swaps the background buffer to current view and polls for any key strokes while the window was in focus.

Examples
  graphics/field.cpp, and graphics/plot2d.cpp.

## ◆ Window() [1/4]

Window | ( |  | ) |

Creates a window object with default width and height with title set to "ArrayFire".

## ◆ Window() [2/4]

Window | ( | const af_window | window | ) |

Creates a window object with default width and height with title set to "ArrayFire".

Parameters

  [in] | window | is an af_window handle which can be retrieved by doing a get call on any Window object

## ◆ Window() [3/4]

Window | ( | const char *const | title | ) |

Creates a window object with default width and height using the title provided by the user.

Parameters

  [in] | title | is the window title

## ◆ Window() [4/4]

Window | ( | const int | width,
|  | const int | height,
|  | const char *const | title = "ArrayFire" )

Creates a window object using the parameters provided by the user.

Parameters

  [in] | width | is the window width
  [in] | height | is the window height
  [in] | title | is the window title with default value as "ArrayFire"

## ◆ ~Window()

~Window | ( |  | ) |

Destroys the window handle.