<!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="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.

<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);
// Set the axes limits to view (0,0), prior to v3.4 this was not needed
myWindow(0, 0).setAxesLimits(-2 * af::Pi, 2 * af::Pi, -1, 1, true);
// Set the axes limits to view (0,0), prior to v3.4 this was not needed
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>
<p>Above code should render as the following and you can find the complete example <a href="https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/plot2d.cpp" target="_blank">here</a>.</p>
<a href="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d.png"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot2d-1024x927.png" alt="plot2d" width="742" height="672" class="alignnone size-large wp-image-9183" /></a>

<h5><a id="New_Features_56"></a>New Features</h5>

<h6>Vector Fields</h6>
<p>An example of how to render your data as a vector field has been provided in our examples which you can find <a href="https://github.com/arrayfire/arrayfire/blob/devel/examples/graphics/field.cpp" target="_blank">here</a>. This example shows a static and dynamic vector field in multi-view mode. Given below is the screenshot of this example while running.</p>
<a href="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield.png"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/vfield-1024x550.png" alt="vfield" width="742" height="399" class="alignnone size-large wp-image-9185" /></a>

<p>Apart from the above new renderables, 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.

<p>Given below is a screen shot of mult-view mode which renders an image, 2d line plot, histogram and surface. You can find the corresponding example code <a href="https://github.com/arrayfire/arrayfire/blob/devel/examples/pde/swe.cpp" target="_blank">here</a>
<a href="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe.png"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/swe-1024x549.png" alt="swe" width="742" height="398" class="alignnone size-large wp-image-9184" /></a>

The following renerables support overlay if they are of same type of object (2d/3d).</p>
<ul>
<li>plot <a href="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3.png"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/plot3-150x150.png" alt="plot3" width="150" height="150" class="alignnone size-thumbnail wp-image-9208" /></a></li>
<li>histogram <a href="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram.png"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/histogram-300x152.png" alt="histogram" width="300" height="152" class="alignnone size-medium wp-image-9207" /></a></li>
<li>surface <a href="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface.png"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/surface-300x300.png" alt="surface" width="300" height="300" class="alignnone size-medium wp-image-9209" /></a></li>
<li>vector fields</li>
</ul>
<p>You can see an example screenshot of how overlay of plots looks like below.</p>
<a href="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png"><img src="http://sandbox.arrayfire.com/wp-content/uploads/2016/09/multipleplot.png" alt="multipleplot" width="1002" height="828" class="alignnone size-full wp-image-9182" /></a>

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