-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGraphics.hs
676 lines (645 loc) · 21.7 KB
/
Graphics.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
{-# LANGUAGE ViewPatterns #-}
--------------------------------------------------------------------------------
-- |
-- Module : ArrayFire.Graphics
-- Copyright : David Johnson (c) 2019-2020
-- License : BSD 3
-- Maintainer : David Johnson <[email protected]>
-- Stability : Experimental
-- Portability : GHC
--
-- Functions for displaying 'Array' graphically.
--
-- @
-- >>> window <- createWindow 800 600 "New Chart"
-- @
--
--------------------------------------------------------------------------------
module ArrayFire.Graphics where
import Control.Exception
import Foreign.Marshal
import Foreign.Storable
import Foreign.ForeignPtr
import Foreign.C.String
import ArrayFire.Internal.Graphics
import ArrayFire.Exception
import ArrayFire.FFI
import ArrayFire.Internal.Types
-- | Create window
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm)
--
-- >>> window <- createWindow 800 600 "New Chart"
--
createWindow
:: Int
-- ^ width
-> Int
-- ^ height
-> String
-- ^ title
-> IO Window
-- ^ 'Window' handle
createWindow (fromIntegral -> x) (fromIntegral -> y) str =
withCString str $ \cstr ->
createWindow' (\p -> af_create_window p x y cstr)
-- | Sets 'Window' position
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm)
--
-- >>> window <- createWindow 800 600 "New Chart"
-- >>> setPosition window 800 600
--
setPosition
:: Window
-- ^ 'Window' handle
-> Int
-- ^ Horizontal start coordinate
-> Int
-- ^ Vertical start coordinate
-> IO ()
setPosition w (fromIntegral -> x) (fromIntegral -> y) =
w `opw` (\p -> af_set_position p x y)
-- | Sets 'Window' title
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm)
--
-- >>> window <- createWindow 800 600 "New Chart"
-- >>> setTitle window "window title"
--
setTitle
:: Window
-- ^ 'Window' handle
-> String
-- ^ title
-> IO ()
setTitle w str = withCString str $ \cstr ->
w `opw` (\p -> af_set_title p cstr)
-- | Sets 'Window' size
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm)
--
-- >>> window <- createWindow 800 600 "New Chart"
-- >>> setSize window 800 600
--
setSize
:: Window
-- ^ 'Window' handle
-> Int
-- ^ target width of the window
-> Int
-- ^ target height of the window
-> IO ()
setSize w (fromIntegral -> x) (fromIntegral -> y) =
w `opw` (\p -> af_set_size p x y)
-- | Draw an image onto a Window
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm)
--
-- >>> drawImage window ('constant' \@'Int' 1) ('Cell' 10 10 "test" 'ColorMapSpectrum')
--
drawImage
:: Window
-- ^ 'Window' handle
-> Array a
-- ^ Image
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawImage (Window wfptr) (Array fptr) cell =
mask_ $ withForeignPtr fptr $ \aptr ->
withForeignPtr wfptr $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_image wptr aptr cellPtr
-- | Draw a plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm)
--
-- >>> drawPlot window ('constant' \@'Int' 1) ('constant' \@'Int' 1) ('Cell' 10 10 "test" 'ColorMapSpectrum')
--
-- *Note* X and Y should be vectors.
--
drawPlot
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' with the x-axis data points
-> Array a
-- ^ is an 'Array' with the y-axis data points
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawPlot (Window w) (Array fptr1) (Array fptr2) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_plot wptr ptr1 ptr2 cellPtr
-- | Draw a plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm)
--
-- *Note* P should be a 3n x 1 vector or one of a 3xn or nx3 matrices.
--
drawPlot3
:: Window
-- ^ the window handle
-> Array a
-- ^ is an af_array or matrix with the xyz-values of the points
-> Cell
-- ^ is structure af_cell that has the properties that are used for the current rendering.
-> IO ()
drawPlot3 (Window w) (Array fptr) cell =
mask_ $ withForeignPtr fptr $ \aptr ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_plot3 wptr aptr cellPtr
-- | Draw a plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm)
--
-- *Note* in must be 2d and of the form [n, order], where order is either 2 or 3. If order is 2, then chart is 2D and if order is 3, then chart is 3D.
--
drawPlotNd
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' or matrix with the xyz-values of the points
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawPlotNd (Window w) (Array fptr) cell =
mask_ $ withForeignPtr fptr $ \aptr ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_plot_nd wptr aptr cellPtr
-- | Draw a plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm)
--
-- *Note* X and Y should be vectors.
--
drawPlot2d
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' with the x-axis data points
-> Array a
-- ^ is an 'Array' with the y-axis data points
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawPlot2d (Window w) (Array fptr1) (Array fptr2) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_plot_2d wptr ptr1 ptr2 cellPtr
-- | Draw a 3D plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm)
--
-- *Note* X, Y and Z should be vectors.
--
drawPlot3d
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' with the x-axis data points
-> Array a
-- ^ is an 'Array' with the y-axis data points
-> Array a
-- ^ is an 'Array' with the z-axis data points
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawPlot3d (Window w) (Array fptr1) (Array fptr2) (Array fptr3) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr fptr3 $ \ptr3 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_plot_3d wptr ptr1 ptr2 ptr3 cellPtr
-- | Draw a scatter plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm)
--
-- *Note* X and Y should be vectors.
--
drawScatter
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' with the x-axis data points
-> Array a
-- ^ is an 'Array' with the y-axis data points
-> MarkerType
-- ^ enum specifying which marker to use in the scatter plot
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawScatter (Window w) (Array fptr1) (Array fptr2) (fromMarkerType -> m) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_scatter wptr ptr1 ptr2 m cellPtr
-- | Draw a scatter plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#ga764410fbdf0cd60c7044c77e36fb2577)
--
-- *Note* X and Y should be vectors.
--
drawScatter3
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an af_array or matrix with the xyz-values of the points
-> MarkerType
-- ^ is an af_marker_type enum specifying which marker to use in the scatter plot
-> Cell
-- ^ is structure af_cell that has the properties that are used for the current rendering.
-> IO ()
drawScatter3 (Window w) (Array fptr1) (fromMarkerType -> m) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_scatter3 wptr ptr1 m cellPtr
-- | Draw a scatter plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#ga9991b93681e0c18693a5464458781d22)
--
-- *Note* in must be 2d and of the form [n, order], where order is either 2 or 3. If order is 2, then chart is 2D and if order is 3, then chart is 3D.
--
drawScatterNd
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' or matrix with the xyz-values of the points
-> MarkerType
-- ^ is an af_marker_type enum specifying which marker to use in the scatter plot
-> Cell
-- ^ is structure af_cell that has the properties that are used for the current rendering.
-> IO ()
drawScatterNd (Window w) (Array fptr1) (fromMarkerType -> m) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_scatter_nd wptr ptr1 m cellPtr
-- | Draw a scatter plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#ga79417722c69883e7a91282b138288010)
--
-- *Note* in must be 2d and of the form [n, order], where order is either 2 or 3. If order is 2, then chart is 2D and if order is 3, then chart is 3D.
--
drawScatter2d
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an af_array with the x-axis data points
-> Array a
-- ^ is an af_array with the y-axis data points
-> MarkerType
-- ^ is an af_marker_type enum specifying which marker to use in the scatter plot
-> Cell
-- ^ is structure af_cell that has the properties that are used for the current rendering.
-> IO ()
drawScatter2d (Window w) (Array fptr1) (Array fptr2) (fromMarkerType -> m) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr w $ \wptr ->
withForeignPtr fptr2 $ \ptr2 ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_scatter_2d wptr ptr1 ptr2 m cellPtr
-- | Draw a scatter plot onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#ga2b3d0dd690ebcba4c4dbb09cdcaed304)
--
-- *Note* X, Y and Z should be vectors.
--
drawScatter3d
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an af_array with the x-axis data points
-> Array a
-- ^ is an af_array with the y-axis data points
-> Array a
-- ^ is an af_array with the z-axis data points
-> MarkerType
-- ^ is an af_marker_type enum specifying which marker to use in the scatter plot
-> Cell
-- ^ is structure af_cell that has the properties that are used for the current rendering.
-> IO ()
drawScatter3d (Window w) (Array fptr1) (Array fptr2) (Array fptr3) (fromMarkerType -> m) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr w $ \wptr ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr fptr3 $ \ptr3 ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_scatter_3d wptr ptr1 ptr2 ptr3 m cellPtr
-- | Draw a Histogram onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#gaf1648ee35739c86116bfa9c22644dbd7)
--
-- *Note* X should be a vector.
--
drawHistogram
:: Window
-- ^ is the window handle
-> Array a
-- ^ is the data frequency af_array
-> Double
-- ^ is the value of the minimum data point of the array whose histogram(X) is going to be rendered.
-> Double
-- ^ is the value of the maximum data point of the array whose histogram(X) is going to be rendered.
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawHistogram (Window w) (Array fptr1) minval maxval cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_hist wptr ptr1 minval maxval cellPtr
-- | Draw a Surface onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#gaaee14e457272b2cd1bd4ed1228370229)
--
-- *Note* X and Y should be vectors. S should be a 2D array
--
drawSurface
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an af_array with the x-axis data points
-> Array a
-- ^ is an af_array with the y-axis data points
-> Array a
-- ^ is an af_array with the z-axis data points
-> Cell
-- ^ is structure af_cell that has the properties that are used for the current rendering.
-> IO ()
drawSurface (Window w) (Array fptr1) (Array fptr2) (Array fptr3) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr w $ \wptr ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr fptr3 $ \ptr3 ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_surface wptr ptr1 ptr2 ptr3 cellPtr
-- | Draw a Vector Field onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#ga2d31a148578d749be4224e7119b386bc)
--
-- *Note* all the 'Array' inputs should be vectors and the same size
--
drawVectorFieldND
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' with the points
-> Array a
-- ^ is an 'Array' with the directions
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawVectorFieldND (Window w) (Array fptr1) (Array fptr2) cell =
mask_ $ withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_vector_field_nd wptr ptr1 ptr2 cellPtr
-- | Draw a Vector Field onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#gaf2d3be32c1b6a9034a3bb851206b4b5a)
--
-- *Note* all the 'Array' inputs should be vectors and the same size
--
drawVectorField3d
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' with the x-axis points
-> Array a
-- ^ is an 'Array' with the y-axis points
-> Array a
-- ^ is an 'Array' with the z-axis points
-> Array a
-- ^ is an 'Array' with the x-axis directions
-> Array a
-- ^ is an 'Array' with the y-axis directions
-> Array a
-- ^ is an 'Array' with the z-axis directions
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
drawVectorField3d (Window w) (Array fptr1) (Array fptr2) (Array fptr3)
(Array fptr4) (Array fptr5) (Array fptr6) cell =
mask_ $ do
withForeignPtr w $ \wptr ->
withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr fptr3 $ \ptr3 ->
withForeignPtr fptr4 $ \ptr4 ->
withForeignPtr fptr5 $ \ptr5 ->
withForeignPtr fptr6 $ \ptr6 -> do
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_vector_field_3d wptr ptr1 ptr2 ptr3 ptr4 ptr5 ptr6 cellPtr
-- | Draw a Vector Field onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__draw.htm#gaa1a667e4d29ab089629acd5296f29a7b)
--
-- *Note* all the 'Array' inputs should be vectors and the same size
--
drawVectorField2d
:: Window
-- ^ is the window handle
-> Array a
-- ^ is an 'Array' with the x-axis points
-> Array a
-- ^ is the window handle
-> Array a
-- ^ is the window handle
-> Array a
-- ^ is the window handle
-> Cell
-- ^ is the window handle
-> IO ()
drawVectorField2d (Window w) (Array fptr1) (Array fptr2) (Array fptr3) (Array fptr4) cell =
mask_ $ do
withForeignPtr w $ \wptr ->
withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr fptr3 $ \ptr3 ->
withForeignPtr fptr4 $ \ptr4 ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_draw_vector_field_2d wptr ptr1 ptr2 ptr3 ptr4 cellPtr
-- | Draw a grid onto a 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#ga37fc7eb00ae11c25e1a60d341663d68d)
--
-- *Note* all the 'Array' inputs should be vectors and the same size
--
grid
:: Window
-- ^ is the window handle
-> Int
-- ^ is number of rows you want to show in a window
-> Int
-- ^ is number of coloumns you want to show in a window
-> IO ()
grid (Window w) (fromIntegral -> rows) (fromIntegral -> cols) =
mask_ . withForeignPtr w $ \wptr ->
throwAFError =<< af_grid wptr rows cols
-- | Setting axes limits for a histogram/plot/surface/vector field.
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#ga62d2cad30e3aad06c24999fe5ac34598)
--
-- *Note* Set to NULL if the chart is 2D.
--
setAxesLimitsCompute
:: Window
-- ^ is the window handle
-> Array a
-- ^ the data to compute the limits for x-axis.
-> Array a
-- ^ the data to compute the limits for y-axis.
-> Array a
-- ^ the data to compute the limits for z-axis.
-> Bool
-- ^ 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.
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
setAxesLimitsCompute (Window w) (Array fptr1) (Array fptr2) (Array fptr3) (fromIntegral . fromEnum -> exact) cell =
mask_ $ do
withForeignPtr w $ \wptr ->
withForeignPtr fptr1 $ \ptr1 ->
withForeignPtr fptr2 $ \ptr2 ->
withForeignPtr fptr3 $ \ptr3 ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_set_axes_limits_compute wptr ptr1 ptr2 ptr3 exact cellPtr
-- | Setting axes limits for a 2D histogram/plot/surface/vector field.
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#gadadc41caf7d6a9b7ca2e674079971895)
--
setAxesLimits2d
:: Window
-- ^ is the window handle
-> Float
-- ^ is the minimum on x-axis
-> Float
-- ^ is the maximum on x-axis
-> Float
-- ^ is the minimum on y-axis
-> Float
-- ^ is the maximum on y-axis
-> Bool
-- ^ 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.
-> Cell
-- ^ is structure af_cell that has the properties that are used for the current rendering.
-> IO ()
setAxesLimits2d (Window w) xmin xmax ymin ymax (fromIntegral . fromEnum -> exact) cell =
mask_ $ do
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_set_axes_limits_2d wptr xmin xmax ymin ymax exact cellPtr
-- | Setting axes limits for a 3D histogram/plot/surface/vector field.
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#gadcd1bd46b9d6fabc047365ca5dc3f73d)
--
setAxesLimits3d
:: Window
-- ^ is the window handle
-> Float
-- ^ is the minimum on x-axis
-> Float
-- ^ is the maximum on x-axis
-> Float
-- ^ is the minimum on y-axis
-> Float
-- ^ is the maximum on y-axis
-> Float
-- ^ is the minimum on z-axis
-> Float
-- ^ is the maximum on z-axis
-> Bool
-- ^ 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.
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
setAxesLimits3d (Window w) xmin xmax ymin ymax zmin zmax (fromIntegral . fromEnum -> exact) cell =
mask_ $ do
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_set_axes_limits_3d wptr xmin xmax ymin ymax zmin zmax exact cellPtr
-- | Setting axes titles
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#gadcd1bd46b9d6fabc047365ca5dc3f73d)
--
setAxesTitles
:: Window
-- ^ is the window handle
-> String
-- ^ is the name of the x-axis
-> String
-- ^ is the name of the y-axis
-> String
-- ^ is the name of the z-axis
-> Cell
-- ^ is structure 'Cell' that has the properties that are used for the current rendering.
-> IO ()
setAxesTitles (Window w) x y z cell =
mask_ $ do
withForeignPtr w $ \wptr ->
alloca $ \cellPtr -> do
withCString x $ \xstr ->
withCString y $ \ystr ->
withCString z $ \zstr -> do
poke cellPtr =<< cellToAFCell cell
throwAFError =<< af_set_axes_titles wptr xstr ystr zstr cellPtr
-- | Displays 'Window'
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#ga50dae861324dca1cce9f583256f5a654)
--
showWindow
:: Window
-- ^ 'Window' handle
-> IO ()
showWindow = (`opw` af_show)
-- | Checks if 'Window' is closed
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#ga50dae861324dca1cce9f583256f5a654)
--
isWindowClosed :: Window -> IO Bool
isWindowClosed w =
toEnum . fromIntegral
<$> (w `opw1` af_is_window_closed)
-- | Sets 'Window' visibility
--
-- [ArrayFire Docs](http://arrayfire.org/docs/group__gfx__func__window.htm#gad7b63c70d45e101c4d8d500273e310c7)
--
setVisibility
:: Window
-- ^ 'Window' handle
-> Bool
-- ^ Set to 'True' to display 'Window'
-> IO ()
setVisibility w (fromIntegral . fromEnum -> b) = w `opw` (`af_set_visibility` b)