- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

Public Member Functions
Window Class Reference
Graphics

Window object to render af::arrays. More...

`#include <graphics.h>`

## Public Member Functions
| Window ()
| Creates a window object with default width and height with title set to "ArrayFire". More...
| Window (const char *const title)
| Creates a window object with default width and height using the title provided by the user. More...
| Window (const int width, const int height, const char *const title="ArrayFire")
| Creates a window object using the parameters provided by the user. More...
| Window (const af_window wnd)
| Creates a window object with default width and height with title set to "ArrayFire". More...
| ~Window ()
| Destroys the window handle. More...
af_window | get () const
void | setPos (const unsigned x, const unsigned y)
| Set the start position where the window will appear. More...
void | setTitle (const char *const title)
| Set the window title. More...
void | setSize (const unsigned w, const unsigned h)
| Set the window size. More...
void | setColorMap (const ColorMap cmap)
| Set the colormap to be used for subsequent rendering calls. More...
void | image (const array &in, const char *title=NULL)
| Renders the input array as an image to the window. More...
void | plot (const array &X, const array &Y, const char *const title=NULL)
| Renders the input arrays as a 2D plot to the window. More...
void | hist (const array &X, const double minval, const double maxval, const char *const title=NULL)
| Renders the input array as a histogram to the window. More...
void | grid (const int rows, const int cols)
| Setup grid layout for multiview mode in a window. More...
void | show ()
| This function swaps the background buffer to current view and polls for any key strokes while the window was in focus. More...
bool | close ()
| Check if window is marked for close. More...
Window & | operator() (const int r, const int c)
| This function is used to keep track of which cell in the grid mode is being currently rendered. More...

## Detailed Description

Window object to render af::arrays.

Examples:
  adaptive_thresholding.cpp, binary_thresholding.cpp, brain_segmentation.cpp, conway.cpp, conway_pretty.cpp, edge.cpp, filters.cpp, fractal.cpp, image_demo.cpp, image_editing.cpp, matching.cpp, morphing.cpp, optical_flow.cpp, plot2d.cpp, and pyramids.cpp.

## Constructor & Destructor Documentation

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.

Parameters

  [in] | title | is the window title

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 | ( | const af_window | wnd | ) |

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

Parameters

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

~Window | ( |  | ) |

Destroys the window handle.

## Member Function Documentation

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:
  conway.cpp, conway_pretty.cpp, and plot2d.cpp.

af_window get | ( |  | ) | const
| inline

Returns
  Returns the af_window window handle.

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 show in a window
  [in] | cols | is number of coloumns you want to show in a window

void hist | ( | const array & | X,
|  | const double | minval,
|  | const double | maxval,
|  | const char *const | title = `NULL`
| ) |  |

Renders the input array as a histogram to the window.

Parameters

  [in] | X | is the data frequency array
  [in] | minval | is the value of the minimum data point of the array whose histogram(`X`) is going to be rendered.
  [in] | maxval | is the value of the maximum data point of the array whose histogram(`X`) is going to be rendered.
  [in] | title | parameter is used when this function is called in grid mode

Note
  `X` should be a vector.

void image | ( | const array & | in,
|  | const char * | title = `NULL`
| ) |  |

Renders the input array as an image to the window.

Parameters

  [in] | in | is an array
  [in] | title | parameter is used when this function is called in grid mode

Note
  `in` should be 2d array or 3d array with 3 channels.

Examples:
  conway.cpp, and conway_pretty.cpp.

Window& operator() | ( | const int | r,
|  | const int | c
| ) |  |
| inline

This function is used to keep track of which cell in the grid mode is being currently rendered.

When a user does Window(0,0), we internally store the cell coordinates and return a reference to the very object that called upon this function. This reference can be used later to issue draw calls using rendering functions.

Returns
  a reference to the object pointed by this to enable cascading this call with rendering functions.

void plot | ( | const array & | X,
|  | const array & | Y,
|  | const char *const | title = `NULL`
| ) |  |

Renders the input arrays as a 2D plot to the window.

Parameters

  [in] | X | is an array with the x-axis data points
  [in] | Y | is an array with the y-axis data points
  [in] | title | parameter is used when this function is called in grid mode

Note
  `X` and `Y` should be vectors.

Examples:
  plot2d.cpp.

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

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:
  conway_pretty.cpp.

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

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

Set the window title.

Parameters

  [in] | title | is the window title

void show | ( |  | ) |

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

The documentation for this class was generated from the following file:

- graphics.h