<!DOCTYPE html><html><head><meta charset="utf-8"><title>Untitled Document.md</title><style></style></head><body id="preview">
<p>This post outlines the new graphics features and updates that come along with ArrayFire v3.4.0 release.</p>
<h5><a id="Deprecated_and_their_replacements_2"></a>Deprecated and their replacements</h5>
<h6><a id="C_API_4"></a>C API</h6>
<ul>
<li><code>af_draw_plot</code> has been deprecated in favour of <code>af_draw_plot_2d</code> or <code>af_draw_plot_nd</code> where the function with <strong>2d</strong> suffix is specific to two dimensional plots and the version with <strong>nd</strong> suffix is generalised.</li>
<li><code>af_draw_plot3</code> has been deprecated in favour of <code>af_draw_plot_3d</code> or <code>af_draw_plot_nd</code> where the function with <strong>3d</strong> suffix is specific to two dimensional plots and the version with <strong>nd</strong> suffix is generalised.</li>
<li><code>af_draw_scatter</code> has been deprecated in favour of <code>af_draw_scatter_2d</code> or <code>af_draw_scatter_nd</code> where the function with <strong>2d</strong> suffix is specific to two dimensional plots and the version with <strong>nd</strong> suffix is generalised.</li>
<li><code>af_draw_scatter3</code> has been deprecated in favour of <code>af_draw_scatter_3d</code> or <code>af_draw_scatter_nd</code> where the function with <strong>3d</strong> suffix is specific to two dimensional plots and the version with <strong>nd</strong> suffix is generalised.</li>
</ul>
<h6><a id="C_API_9"></a>C++ API</h6>
<ul>
<li><code>af::Window::plot3</code> has been deprecated in favour of <code>af::Window::plot</code>, which is generalized plotting draw call that can handle both 2d and 3d data.</li>
<li><code>af::Window::scatter3</code> has been deprecated in favour of <code>af::Window::scatter</code>, which is generalized plotting draw call that can handle both 2d and 3d data.</li>
</ul>
<h5><a id="Behavioral_Changes_13"></a>Behavioral Changes</h5>
<p>Prior to v3.4.0 release, all plotting functions used to compute the axes limits pertaining to corresponding data automatically. This additional step of computing axes is now not performed in any plotting functions. Instead, new API has been provided to set the axes limits of the corresponding graph plot. Following are the new API calls for setting axes limits.</p>
<h6><a id="C_API_16"></a>C API</h6>
<ul>
<li><code>af_set_axes_limits_compute</code> computes the axes limits from given <code>af_array</code>'s and then passed the same to draw call.</li>
<li><code>af_set_axes_limits_2d</code> can be used to explicitly set the x and y axes limits to specific minimum and maximum values.</li>
<li><code>af_set_axes_limits_3d</code> can be used to explicitly set the x, y &amp; z axes limits to specific minimum and maximum values.</li>
</ul>
<h6><a id="C_API_20"></a>C++ API</h6>
<ul>
<li><code>af::Window::setAxesLimits</code></li>
</ul>
<p>Given below is an example showing the code changes one has to make to their C++ ArrayFire program that uses graphics functionality of ArrayFire.</p>

<pre><code class="language-cpp">
af::Window myWindow(800, 800, "2D Plot example: ArrayFire");

array Y;
int sign = 1;
array X = seq(-af::Pi, af::Pi, PRECISION);
array noise = randn(X.dims(0))/5.f;

myWindow.grid(2, 1);
myWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);
myWindow(1, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1.25, 1.25, true);

for (double val=0; !myWindow.close(); )
{
    Y = sin(X);

    myWindow(0,0).plot(X, Y);
    myWindow(1,0).scatter(X, Y + noise, AF_MARKER_POINT);

    myWindow.show();

    X = X + PRECISION * float(sign);
    val += PRECISION * float(sign);

    if (val>af::Pi) {
        sign = -1;
    } else if (val<-af::Pi) {
        sign = 1;
    }
}
</code></pre>

<h5><a id="New_Features_56"></a>New Features</h5>
<p>Any new functions that have been already mentioned in the above two sections are not repeated below.</p>
<h6><a id="C_API_58"></a>C API</h6>
<ul>
<li><code>af_draw_vector_field_2d</code> renders given data as two dimensional vector field</li>
<li><code>af_draw_vector_field_2d</code> renders given data as two dimensional vector field</li>
<li><code>af_draw_vector_field_nd</code> is generalized version that can handle both 2d and 3d <code>af_array</code>s.</li>
<li><code>af_set_axes_titles</code> can be used to set the titles of axes of a given chart/graph.</li>
</ul>
<h6><a id="C_API_63"></a>C++ API</h6>
<ul>
<li><code>af::Window::vectorField</code> is an overloaded and generalized vector field rendering function.</li>
<li><code>af::Window::setAxesTitles</code> is used to set the chart/graph axes labels</li>
</ul>
<p>Apart from the above new functions, each window/view supports overlay of different renderables now. If you are not already aware of what a view (graphics context) in ArrayFire is: Each draw call in ArrayFire is either rendered to whole window(single view) or a portion of the screen(multiview mode or grid mode), this subset portion of the whole window is called a view.
The following renerables support overlay if they are of same type of object (2d/3d).</p>
<ul>
<li>plot</li>
<li>hist</li>
<li>surface</li>
<li>vector fields</li>
</ul>
<h5><a id="Misc_Changes_74"></a>Misc Changes</h5>
<p>Removed <a href="http://glew.sourceforge.net/">GLEW</a> and replaced with <a href="https://github.com/cginternals/glbinding">glbinding</a>.</p>
<h5><a id="Conclusion_77"></a>Conclusion</h5>
<p>We intend to add more graphcis functionality in future releases, keep checking for new posts from us. Please do try the new graphics functionality and kindly let us know if you find any bugs in the library.</p>

</body></html>