ruby-gr 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fd375d6fbd9ef427ca5eeb0540bf83b456ade3dac53e48572df7b4c2b5f2466
4
- data.tar.gz: 127c524864be21dac6bf57c07f61546208b95559f359edff61d82048b7e16ff9
3
+ metadata.gz: a4952b2f2f30277b1fecfae2d49660addde63d4b1476aa63dacdba4643568294
4
+ data.tar.gz: a99aee8f75ff9f102ae713723e582aa9be12a1d1a5ef8fbede028df731d27ea3
5
5
  SHA512:
6
- metadata.gz: 937b324d8199571ed75ac494889c6550bb35da07012f4770b23b37fe1b0aad0e853366c791bf1349fd96b531bf1292415925762271a8619e59aef6859ad7e6ab
7
- data.tar.gz: 635b60aa7adc76b87bec35e11d419aaa402b49387b89b80534797b41f89ed8800fc3bb8e11321a6f4ea917ec2ff610c2e9c8b817ea13ed7091c78958bffdf078
6
+ metadata.gz: 0ba5e877d1363a6e27c986f5380ed169ea37615cb803633dea6fbb8e00a7d4c42bc7c52e9559e5d5719d094db6ed6b8cbe26d9a663cf94582545e9f0df715956
7
+ data.tar.gz: f2b76c28406593d64150e885a4f2d50731d3fb9d079677c94aaff7191a0a546d2bb23647352e729474ce9ebef619a12bac32b6d04045889a34cdbf0a44b21c6d
data/lib/gr.rb CHANGED
@@ -25,6 +25,7 @@ module GR
25
25
  end
26
26
 
27
27
  require_relative 'gr_commons'
28
+ require_relative 'gr/version'
28
29
  require_relative 'gr/ffi'
29
30
  require_relative 'gr/grbase'
30
31
 
@@ -36,58 +37,118 @@ module GR
36
37
  # a FFI::MemoryPointer in the GRBase class.
37
38
 
38
39
  class << self
40
+ def initgr(*)
41
+ super
42
+ end
43
+
44
+ def opengks(*)
45
+ super
46
+ end
47
+
48
+ def closegks(*)
49
+ super
50
+ end
51
+
52
+ # inqdspsize
39
53
  def inqdspsize
40
54
  inquiry %i[double double int int] do |*pts|
41
55
  super(*pts)
42
56
  end
43
57
  end
44
58
 
59
+ def openws(*)
60
+ super
61
+ end
62
+
63
+ def closews(*)
64
+ super
65
+ end
66
+
67
+ def activatews(*)
68
+ super
69
+ end
70
+
71
+ def deactivatews(*)
72
+ super
73
+ end
74
+
75
+ def configurews(*)
76
+ super
77
+ end
78
+
79
+ def clearws(*)
80
+ super
81
+ end
82
+
83
+ def updatews(*)
84
+ super
85
+ end
86
+
87
+ # Draw a polyline using the current line attributes,
88
+ # starting from the first data point and ending at the last data point.
45
89
  def polyline(x, y)
46
90
  n = equal_length(x, y)
47
91
  super(n, x, y)
48
92
  end
49
93
 
94
+ # Draw marker symbols centered at the given data points.
50
95
  def polymarker(x, y)
51
96
  n = equal_length(x, y)
52
97
  super(n, x, y)
53
98
  end
54
99
 
100
+ def text(*)
101
+ super
102
+ end
103
+
104
+ # inqtext
55
105
  def inqtext(x, y, string)
56
106
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
57
107
  super(x, y, string, tbx, tby)
58
108
  end
59
109
  end
60
110
 
111
+ # Allows you to specify a polygonal shape of an area to be filled.
61
112
  def fillarea(x, y)
62
113
  n = equal_length(x, y)
63
114
  super(n, x, y)
64
115
  end
65
116
 
117
+ # Display rasterlike images in a device-independent manner.
118
+ # The cell array function partitions a rectangle given by two corner points into DIMX X DIMY cells,
119
+ # each of them colored individually by the corresponding color index of the given cell array.
66
120
  def cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color)
67
121
  super(xmin, xmax, ymin, ymax, dimx, dimy, 1, 1, dimx, dimy, int(color))
68
122
  end
69
123
 
124
+ # Display a two dimensional color index array with nonuniform cell sizes.
70
125
  def nonuniformcellarray(x, y, dimx, dimy, color)
71
- raise ArgumentError unless length(x) == dimx + 1 && length(y) == dimy + 1
126
+ raise ArgumentError unless x.length == dimx + 1 && y.length == dimy + 1
72
127
 
73
128
  super(x, y, dimx, dimy, 1, 1, dimx, dimy, int(color))
74
129
  end
75
130
 
131
+ # Display a two dimensional color index array mapped to a disk using polar coordinates.
76
132
  def polarcellarray(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, color)
77
133
  super(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, 1, 1, dimphi, dimr, int(color))
78
134
  end
79
135
 
136
+ # Generates a generalized drawing primitive (GDP) of the type you specify,
137
+ # using specified points and any additional information contained in a data record.
80
138
  def gdp(x, y, primid, datrec)
81
139
  n = equal_length(x, y)
82
- ldr = length(datrec, :int)
140
+ ldr = datrec.length
83
141
  super(n, x, y, primid, ldr, datrec)
84
142
  end
85
143
 
144
+ # Generate a cubic spline-fit,
145
+ # starting from the first data point and ending at the last data point.
86
146
  def spline(px, py, m, method)
87
147
  n = equal_length(px, py)
88
148
  super(n, px, py, m, method)
89
149
  end
90
150
 
151
+ # gridit
91
152
  def gridit(xd, yd, zd, nx, ny)
92
153
  nd = equal_length(xd, yd, zd)
93
154
  inquiry [{ double: nx }, { double: ny }, { double: nx * ny }] do |px, py, pz|
@@ -95,169 +156,380 @@ module GR
95
156
  end
96
157
  end
97
158
 
159
+ def setlinetype(*)
160
+ super
161
+ end
162
+
163
+ # inqlinetype
98
164
  def inqlinetype
99
165
  inquiry_int { |pt| super(pt) }
100
166
  end
101
167
 
168
+ def setlinewidth(*)
169
+ super
170
+ end
171
+
172
+ # inqlinewidth
102
173
  def inqlinewidth
103
174
  inquiry_double { |pt| super(pt) }
104
175
  end
105
176
 
177
+ def setlinecolorind(*)
178
+ super
179
+ end
180
+
181
+ # inqlinecolorind
106
182
  def inqlinecolorind
107
183
  inquiry_int { |pt| super(pt) }
108
184
  end
109
185
 
186
+ def setmarkertype(*)
187
+ super
188
+ end
189
+
190
+ # inqmarkertype
110
191
  def inqmarkertype
111
192
  inquiry_int { |pt| super(pt) }
112
193
  end
113
194
 
195
+ def setmarkersize(*)
196
+ super
197
+ end
198
+
199
+ # inqmarkersize
200
+ def inqmarkersize
201
+ inquiry_double { |pt| super(pt) }
202
+ end
203
+
204
+ def setmarkercolorind(*)
205
+ super
206
+ end
207
+
208
+ # inqmarkercolorind
114
209
  def inqmarkercolorind
115
210
  inquiry_int { |pt| super(pt) }
116
211
  end
117
212
 
213
+ def settextfontprec(*)
214
+ super
215
+ end
216
+
217
+ def setcharexpan(*)
218
+ super
219
+ end
220
+
221
+ def setcharspace(*)
222
+ super
223
+ end
224
+
225
+ def settextcolorind(*)
226
+ super
227
+ end
228
+
229
+ def setcharheight(*)
230
+ super
231
+ end
232
+
233
+ def setcharup(*)
234
+ super
235
+ end
236
+
237
+ def settextpath(*)
238
+ super
239
+ end
240
+
241
+ def settextalign(*)
242
+ super
243
+ end
244
+
245
+ def setfillintstyle(*)
246
+ super
247
+ end
248
+
249
+ # inqfillintstyle
118
250
  def inqfillintstyle
119
251
  inquiry_int { |pt| super(pt) }
120
252
  end
121
253
 
254
+ def setfillstyle(*)
255
+ super
256
+ end
257
+
258
+ # inqfillstyle
122
259
  def inqfillstyle
123
260
  inquiry_int { |pt| super(pt) }
124
261
  end
125
262
 
263
+ def setfillcolorind(*)
264
+ super
265
+ end
266
+
267
+ # inqfillcolorind
126
268
  def inqfillcolorind
127
269
  inquiry_int { |pt| super(pt) }
128
270
  end
129
271
 
272
+ def setcolorrep(*)
273
+ super
274
+ end
275
+
276
+ def setscale(*)
277
+ super
278
+ end
279
+
280
+ # inqscale
130
281
  def inqscale
131
282
  inquiry_int { |pt| super(pt) }
132
283
  end
133
284
 
134
- def inqtextext(x, y, string)
135
- inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
136
- super(x, y, string, tbx, tby)
137
- end
285
+ def setwindow(*)
286
+ super
138
287
  end
139
288
 
289
+ # inqwindow
140
290
  def inqwindow
141
291
  inquiry %i[double double double double] do |*pts|
142
292
  super(*pts)
143
293
  end
144
294
  end
145
295
 
296
+ def setviewport(*)
297
+ super
298
+ end
299
+
300
+ # inqviewport
146
301
  def inqviewport
147
302
  inquiry %i[double double double double] do |*pts|
148
303
  super(*pts)
149
304
  end
150
305
  end
151
306
 
307
+ def selntran(*)
308
+ super
309
+ end
310
+
311
+ def setclip(*)
312
+ super
313
+ end
314
+
315
+ def setwswindow(*)
316
+ super
317
+ end
318
+
319
+ def setwsviewport(*)
320
+ super
321
+ end
322
+
323
+ def createseg(*)
324
+ super
325
+ end
326
+
327
+ def copysegws(*)
328
+ super
329
+ end
330
+
331
+ def redrawsegws(*)
332
+ super
333
+ end
334
+
335
+ def setsegtran(*)
336
+ super
337
+ end
338
+
339
+ def closeseg(*)
340
+ super
341
+ end
342
+
343
+ def emergencyclosegks(*)
344
+ super
345
+ end
346
+
347
+ def updategks(*)
348
+ super
349
+ end
350
+
351
+ def setspace(*)
352
+ super
353
+ end
354
+
355
+ # inqspace
152
356
  def inqspace
153
357
  inquiry %i[double double int int] do |*pts|
154
358
  super(*pts)
155
359
  end
156
360
  end
157
361
 
362
+ def textext(*)
363
+ super
364
+ end
365
+
366
+ # inqtextext
367
+ def inqtextext(x, y, string)
368
+ inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
369
+ super(x, y, string, tbx, tby)
370
+ end
371
+ end
372
+
373
+ def axes(*)
374
+ super
375
+ end
376
+
158
377
  alias axes2d axes
159
378
 
379
+ def grid(*)
380
+ super
381
+ end
382
+
383
+ def grid3d(*)
384
+ super
385
+ end
386
+
387
+ # Draw a standard vertical error bar graph.
160
388
  def verrorbars(px, py, e1, e2)
161
389
  n = equal_length(px, py, e1, e2)
162
390
  super(n, px, py, e1, e2)
163
391
  end
164
392
 
393
+ # Draw a standard horizontal error bar graph.
165
394
  def herrorbars(px, py, e1, e2)
166
395
  n = equal_length(px, py, e1, e2)
167
396
  super(n, px, py, e1, e2)
168
397
  end
169
398
 
399
+ # Draw a 3D curve using the current line attributes,
400
+ # starting from the first data point and ending at the last data point.
170
401
  def polyline3d(px, py, pz)
171
402
  n = equal_length(px, py, pz)
172
403
  super(n, px, py, pz)
173
404
  end
174
405
 
406
+ # Draw marker symbols centered at the given 3D data points.
175
407
  def polymarker3d(px, py, pz)
176
408
  n = equal_length(px, py, pz)
177
409
  super(n, px, py, pz)
178
410
  end
179
411
 
180
- def surface(px, py, pz, option)
181
- # TODO: check: Arrays have incorrect length or dimension.
182
- nx = length(px)
183
- ny = length(py)
184
- super(nx, ny, px, py, pz, option)
412
+ def axes3d(*)
413
+ super
185
414
  end
186
415
 
187
- def trisurface(px, py, pz)
188
- n = [length(px), length(py), length(pz)].min
189
- super(n, px, py, pz)
416
+ def titles3d(*)
417
+ super
190
418
  end
191
419
 
192
- def gradient(x, y, z)
193
- # TODO: check: Arrays have incorrect length or dimension.
194
- nx = length(x)
195
- ny = length(y)
196
- inquiry [{ double: nx * ny }, { double: nx * ny }] do |pu, pv|
197
- super(nx, ny, x, y, z, pu, pv)
198
- end
199
- end
200
-
201
- def quiver(x, y, u, v, color)
420
+ # Draw a three-dimensional surface plot for the given data points.
421
+ def surface(px, py, pz, option)
202
422
  # TODO: check: Arrays have incorrect length or dimension.
203
- nx = length(x)
204
- ny = length(y)
205
- super(nx, ny, x, y, u, v, (color ? 1 : 0))
423
+ nx = px.length
424
+ ny = py.length
425
+ super(nx, ny, px, py, pz, option)
206
426
  end
207
427
 
428
+ # Draw contours of a three-dimensional data set
429
+ # whose values are specified over a rectangular mesh.
430
+ # Contour lines may optionally be labeled.
208
431
  def contour(px, py, h, pz, major_h)
209
432
  # TODO: check: Arrays have incorrect length or dimension.
210
- nx = length(px)
211
- ny = length(py)
212
- nh = h.size
433
+ nx = px.length
434
+ ny = py.length
435
+ nh = h.length
213
436
  super(nx, ny, nh, px, py, h, pz, major_h)
214
437
  end
215
438
 
439
+ # Draw filled contours of a three-dimensional data set
440
+ # whose values are specified over a rectangular mesh.
216
441
  def contourf(px, py, h, pz, major_h)
217
442
  # TODO: check: Arrays have incorrect length or dimension.
218
- nx = length(px)
219
- ny = length(py)
220
- nh = h.size
443
+ nx = px.length
444
+ ny = py.length
445
+ nh = h.length
221
446
  super(nx, ny, nh, px, py, h, pz, major_h)
222
447
  end
223
448
 
449
+ # Draw a contour plot for the given triangle mesh.
224
450
  def tricontour(x, y, z, levels)
225
- npoints = length(x) # equal_length ?
226
- nlevels = length(levels)
451
+ npoints = x.length # equal_length ?
452
+ nlevels = levels.length
227
453
  super(npoints, x, y, z, nlevels, levels)
228
454
  end
229
455
 
456
+ # hexbin
230
457
  def hexbin(x, y, nbins)
231
- n = length(x)
458
+ n = x.length
232
459
  super(n, x, y, nbins)
233
460
  end
234
461
 
462
+ def setcolormap(*)
463
+ super
464
+ end
465
+
466
+ # inqcolormap
235
467
  def inqcolormap
236
468
  inquiry_int { |pt| super(pt) }
237
469
  end
238
470
 
471
+ # Define a linear interpolated colormap by a list of RGB colors.
239
472
  def setcolormapfromrgb(r, g, b, positions: nil)
240
473
  n = equal_length(r, g, b)
241
474
  if positions.nil?
242
475
  positions = ::FFI::Pointer::NULL
243
476
  else
244
- raise if length(positions) != n
477
+ raise if positions.length != n
245
478
  end
246
479
  super(n, r, g, b, positions)
247
480
  end
248
481
 
482
+ def colorbar(*)
483
+ super
484
+ end
485
+
486
+ # inqcolor
249
487
  def inqcolor(color)
250
488
  inquiry_int do |rgb|
251
489
  super(color, rgb)
252
490
  end
253
491
  end
254
492
 
493
+ def inqcolorfromrgb(*)
494
+ super
495
+ end
496
+
497
+ # hsvtorgb
255
498
  def hsvtorgb(h, s, v)
256
499
  inquiry %i[double double double] do |r, g, b|
257
500
  super(h, s, v, r, g, b)
258
501
  end
259
502
  end
260
503
 
504
+ def tick(*)
505
+ super
506
+ end
507
+
508
+ def validaterange(*)
509
+ super
510
+ end
511
+
512
+ def adjustlimits(*)
513
+ super
514
+ end
515
+
516
+ def adjustrange(*)
517
+ super
518
+ end
519
+
520
+ def beginprint(*)
521
+ super
522
+ end
523
+
524
+ def beginprintext(*)
525
+ super
526
+ end
527
+
528
+ def endprint(*)
529
+ super
530
+ end
531
+
532
+ # ndctowc
261
533
  def ndctowc(x, y)
262
534
  inquiry %i[double double] do |px, py|
263
535
  px.write_double x
@@ -266,6 +538,7 @@ module GR
266
538
  end
267
539
  end
268
540
 
541
+ # wctondc
269
542
  def wctondc(x, y)
270
543
  inquiry %i[double double] do |px, py|
271
544
  px.write_double x
@@ -274,6 +547,7 @@ module GR
274
547
  end
275
548
  end
276
549
 
550
+ # wc3towc
277
551
  def wc3towc(x, y, z)
278
552
  inquiry %i[double double double] do |px, py, pz|
279
553
  px.write_double x
@@ -283,43 +557,156 @@ module GR
283
557
  end
284
558
  end
285
559
 
560
+ def drawrect(*)
561
+ super
562
+ end
563
+
564
+ def fillrect(*)
565
+ super
566
+ end
567
+
568
+ def drawarc(*)
569
+ super
570
+ end
571
+
572
+ def fillarc(*)
573
+ super
574
+ end
575
+
576
+ # Draw simple and compound outlines consisting of line segments and bezier curves.
286
577
  def drawpath(points, codes, fill)
287
- len = length(codes)
578
+ len = codes.length
288
579
  super(len, points, uint8(codes), fill)
289
580
  end
290
581
 
582
+ def setarrowstyle(*)
583
+ super
584
+ end
585
+
586
+ def setarrowsize(*)
587
+ super
588
+ end
589
+
590
+ def drawarrow(*)
591
+ super
592
+ end
593
+
594
+ # readimage
595
+ def readimage(path)
596
+ w, h, d = inquiry [:int, :int, :pointer] do |width, height, data|
597
+ # data is a pointer of a pointer
598
+ super(path, width, height, data)
599
+ end
600
+ [w, h, d.read_array_of_uint(w * h)]
601
+ end
602
+
603
+ # Draw an image into a given rectangular area.
291
604
  def drawimage(xmin, xmax, ymin, ymax, width, height, data, model = 0)
292
- super(xmin, xmax, ymin, ymax, width, height, int(data), model)
605
+ super(xmin, xmax, ymin, ymax, width, height, uint(data), model)
606
+ end
607
+
608
+ def importgraphics(*)
609
+ super
293
610
  end
294
611
 
612
+ def setshadow(*)
613
+ super
614
+ end
615
+
616
+ def settransparency(*)
617
+ super
618
+ end
619
+
620
+ # Change the coordinate transformation according to the given matrix.
295
621
  def setcoordxform(mat)
296
622
  raise if mat.size != 6
297
623
 
298
624
  super(mat)
299
625
  end
300
626
 
627
+ def begingraphics(*)
628
+ super
629
+ end
630
+
631
+ def endgraphics(*)
632
+ super
633
+ end
634
+
635
+ def getgraphics(*)
636
+ super
637
+ end
638
+
639
+ def drawgraphics(*)
640
+ super
641
+ end
642
+
643
+ def mathtex(*)
644
+ super
645
+ end
646
+
647
+ # inqmathtex
301
648
  def inqmathtex(x, y, string)
302
649
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
303
650
  super(x, y, string, tbx, tby)
304
651
  end
305
652
  end
306
653
 
654
+ def beginselection(*)
655
+ super
656
+ end
657
+
658
+ def endselection(*)
659
+ super
660
+ end
661
+
662
+ def moveselection(*)
663
+ super
664
+ end
665
+
666
+ def resizeselection(*)
667
+ super
668
+ end
669
+
670
+ # inqbbox
307
671
  def inqbbox
308
672
  inquiry %i[double double double double] do |*pts|
309
673
  super(*pts)
310
674
  end
311
675
  end
312
676
 
313
- def adjustlimits(_amin, _amax)
314
- inquiry %i[double double] do |*pts|
315
- super(*pts)
316
- end
677
+ def precision(*)
678
+ super
317
679
  end
318
680
 
319
- def version
320
- super.read_string
681
+ def setregenflags(*)
682
+ super
683
+ end
684
+
685
+ def inqregenflags(*)
686
+ super
687
+ end
688
+
689
+ def savestate(*)
690
+ super
691
+ end
692
+
693
+ def restorestate(*)
694
+ super
695
+ end
696
+
697
+ def selectcontext(*)
698
+ super
699
+ end
700
+
701
+ def destroycontext(*)
702
+ super
703
+ end
704
+
705
+ def uselinespec(*)
706
+ super
321
707
  end
322
708
 
709
+ # Reduces the number of points of the x and y array.
323
710
  def reducepoints(xd, yd, n)
324
711
  nd = equal_length(xd, yd)
325
712
  inquiry [{ double: n }, { double: n }] do |x, y|
@@ -328,18 +715,66 @@ module GR
328
715
  end
329
716
  end
330
717
 
718
+ # Draw a triangular surface plot for the given data points.
719
+ def trisurface(px, py, pz)
720
+ n = [px, py, pz].map(&:length).min
721
+ super(n, px, py, pz)
722
+ end
723
+
724
+ # gradient
725
+ def gradient(x, y, z)
726
+ # TODO: check: Arrays have incorrect length or dimension.
727
+ nx = x.length
728
+ ny = y.length
729
+ inquiry [{ double: nx * ny }, { double: nx * ny }] do |pu, pv|
730
+ super(nx, ny, x, y, z, pu, pv)
731
+ end
732
+ end
733
+
734
+ # quiver
735
+ def quiver(x, y, u, v, color)
736
+ # TODO: check: Arrays have incorrect length or dimension.
737
+ nx = x.length
738
+ ny = y.length
739
+ super(nx, ny, x, y, u, v, (color ? 1 : 0))
740
+ end
741
+
742
+ # interp2
743
+ def interp2(x, y, z, xq, yq, method, extrapval) # flatten
744
+ nx = x.length
745
+ ny = y.length
746
+ # nz = z.length
747
+ nxq = xq.length
748
+ nyq = yq.length
749
+ inquiry(double: nxq * nyq) do |zq|
750
+ super(nx, ny, x, y, z, nxq, nyq, xq, yq, zq, method, extrapval)
751
+ end
752
+ end
753
+
754
+ # version
755
+ def version
756
+ super.read_string
757
+ end
758
+
759
+ # Display a point set as a aggregated and rasterized image.
331
760
  def shadepoints(x, y, dims: [1200, 1200], xform: 1)
332
- n = length(x)
761
+ n = x.length
333
762
  w, h = dims
334
763
  super(n, x, y, xform, w, h)
335
764
  end
336
765
 
766
+ # Display a line set as an aggregated and rasterized image.
337
767
  def shadelines(x, y, dims: [1200, 1200], xform: 1)
338
- n = length(x)
768
+ n = x.length
339
769
  w, h = dims
340
770
  super(n, x, y, xform, w, h)
341
771
  end
342
772
 
773
+ def panzoom(*)
774
+ super
775
+ end
776
+
777
+ # panzoom
343
778
  def panzoom(x, y, zoom)
344
779
  inquiry %i[double double double double] do |xmin, xmax, ymin, ymax|
345
780
  super(x, y, zoom, zoom, xmin, xmax, ymin, ymax)