-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathgrruby.c
More file actions
2337 lines (2150 loc) · 84.5 KB
/
grruby.c
File metadata and controls
2337 lines (2150 loc) · 84.5 KB
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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <ruby.h>
#include <gr.h>
double* rb_ar_2_dbl_ar(VALUE ar) {
long ar_size=RARRAY_LEN(ar);
double *arc = (double *)malloc(ar_size * sizeof(double));
int i;
for (i=0; i < ar_size; i++){
arc[i] = NUM2DBL(rb_ary_entry(ar, i));
}
return arc;
}
int* rb_ar_2_int_ar(VALUE ar){
long ar_size=RARRAY_LEN(ar);
int *arc = (int *)malloc(ar_size * sizeof(int));
int i;
for (i=0; i < ar_size; i++){
arc[i] = NUM2INT(rb_ary_entry(ar, i));
}
return arc;
}
static VALUE opengks(VALUE self){
gr_opengks();
return Qtrue;
}
static VALUE closegks(VALUE self){
gr_closegks();
return Qtrue;
}
static VALUE inqdspsize(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d){
double *ac = rb_ar_2_dbl_ar(a);
double *bc = rb_ar_2_dbl_ar(b);
int *cc = rb_ar_2_int_ar(c);
int *dc = rb_ar_2_int_ar(d);
gr_inqdspsize(ac,bc,cc,dc);
return Qtrue;
}
/*
* call-seq:
* Rubyplot::GR.openws()
*
* Open a graphical workstation.
*
* *Parameters:**
*
* `workstation_id` :
* A workstation identifier.
* `connection` :
* A connection identifier.
* `workstation_type` :
* The desired workstation type.
*
* Available workstation types:
*
* +-------------+------------------------------------------------------+
* | 5|Workstation Independent Segment Storage |
* +-------------+------------------------------------------------------+
* | 7, 8|Computer Graphics Metafile (CGM binary, clear text) |
* +-------------+------------------------------------------------------+
* | 41|Windows GDI |
* +-------------+------------------------------------------------------+
* | 51|Mac Quickdraw |
* +-------------+------------------------------------------------------+
* | 61 - 64|PostScript (b/w, color) |
* +-------------+------------------------------------------------------+
* | 101, 102|Portable Document Format (plain, compressed) |
* +-------------+------------------------------------------------------+
* | 210 - 213|X Windows |
* +-------------+------------------------------------------------------+
* | 214|Sun Raster file (RF) |
* +-------------+------------------------------------------------------+
* | 215, 218|Graphics Interchange Format (GIF87, GIF89) |
* +-------------+------------------------------------------------------+
* | 216|Motif User Interface Language (UIL) |
* +-------------+------------------------------------------------------+
* | 320|Windows Bitmap (BMP) |
* +-------------+------------------------------------------------------+
* | 321|JPEG image file |
* +-------------+------------------------------------------------------+
* | 322|Portable Network Graphics file (PNG) |
* +-------------+------------------------------------------------------+
* | 323|Tagged Image File Format (TIFF) |
* +-------------+------------------------------------------------------+
* | 370|Xfig vector graphics file |
* +-------------+------------------------------------------------------+
* | 371|Gtk |
* +-------------+------------------------------------------------------+
* | 380|wxWidgets |
* +-------------+------------------------------------------------------+
* | 381|Qt4 |
* +-------------+------------------------------------------------------+
* | 382|Scaleable Vector Graphics (SVG) |
* +-------------+------------------------------------------------------+
* | 390|Windows Metafile |
* +-------------+------------------------------------------------------+
* | 400|Quartz |
* +-------------+------------------------------------------------------+
* | 410|Socket driver |
* +-------------+------------------------------------------------------+
* | 415|0MQ driver |
* +-------------+------------------------------------------------------+
* | 420|OpenGL |
* +-------------+------------------------------------------------------+
* | 430|HTML5 Canvas |
* +-------------+------------------------------------------------------+
*
*/
static VALUE openws(VALUE self,VALUE ws_id,VALUE connection, VALUE type) {
int ws_idc = NUM2INT(ws_id);
char *connectionc = StringValueCStr(connection);
int typec = NUM2INT(type);
gr_openws(ws_idc,connectionc,typec);
return Qtrue;
}
static VALUE closews(VALUE self,VALUE ws_id){
int ws_idc=NUM2INT(ws_id);
gr_closews(ws_idc);
return Qtrue;
}
static VALUE activatews(VALUE self,VALUE ws_id){
int ws_idc=NUM2INT(ws_id);
gr_activatews(ws_idc);
return Qtrue;
}
static VALUE deactivatews(VALUE self,VALUE ws_id){
int ws_idc=NUM2INT(ws_id);
gr_deactivatews(ws_idc);
return Qtrue;
}
static VALUE clearws(VALUE self){
gr_clearws();
return Qtrue;
}
static VALUE updatews(VALUE self){
gr_updatews();
return Qtrue;
}
/**
*
* call-seq:
* Rubyplot::GR.polyline(x,y) -> true
*
* Draw a polyline using the current line attributes, starting from the
* first data point and ending at the last data point.
*
* Parameters:
*
* `x` :
* A list containing the X coordinates
* `y` :
* A list containing the Y coordinates
*
* The values for `x` and `y` are in world coordinates. The attributes that
* control the appearance of a polyline are linetype, linewidth and color
* index.
*/
static VALUE polyline(VALUE self,VALUE x, VALUE y) {
int x_size = RARRAY_LEN(x);
int y_size = RARRAY_LEN(y);
int size = (x_size <= y_size)?x_size:y_size;
double *xc = rb_ar_2_dbl_ar(x);
double *yc = rb_ar_2_dbl_ar(y);
gr_polyline(size,xc,yc);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.polymarker(x, y) -> true
*
* Draw marker symbols centered at the given data points.
*
* **Parameters:**
*
* `x` :
* A list containing the X coordinates
* `y` :
* A list containing the Y coordinates
*
* The values for `x` and `y` are in world coordinates. The attributes that
* control the appearance of a polymarker are marker type, marker size
* scale factor and color index.
*/
static VALUE polymarker(VALUE self,VALUE x, VALUE y) {
int x_size = RARRAY_LEN(x);
int y_size = RARRAY_LEN(y);
int size = (x_size <= y_size) ? x_size : y_size;
double *xc = rb_ar_2_dbl_ar(x);
double *yc = rb_ar_2_dbl_ar(y);
gr_polymarker(size,xc,yc);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.text(x, y, text) -> true
*
* Draw a text at position `x`, `y` using the current text attributes.
*
* **Parameters:**
*
* `x` :
* The X coordinate of starting position of the text string
* `y` :
* The Y coordinate of starting position of the text string
* `string` :
* The text to be drawn
*
* The values for `x` and `y` are in normalized device coordinates.
* The attributes that control the appearance of text are text font and precision,
* character expansion factor, character spacing, text color index, character
* height, character up vector, text path and text alignment.
*/
static VALUE text(VALUE self,VALUE x, VALUE y, VALUE string) {
double xc = NUM2DBL(x);
double yc = NUM2DBL(y);
char *stringc=StringValueCStr(string);
gr_text(xc,yc,stringc);
return Qtrue;
}
static VALUE inqtext(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d,VALUE e) {
double ac = NUM2DBL(a);
double bc = NUM2DBL(b);
char *cc = StringValueCStr(c);
double *dc = rb_ar_2_dbl_ar(d);
double *ec = rb_ar_2_dbl_ar(e);
gr_inqtext(ac,bc,cc,dc,ec);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.fillarea([1,2,3], [1,2,3]) -> true
*
* Allows you to specify a polygonal shape of an area to be filled.
*
* **Parameters:**
*
* `x` :
* A list containing the X coordinates
* `y` :
* A list containing the Y coordinates
*
* The attributes that control the appearance of fill areas are fill area interior
* style, fill area style index and fill area color index.
*/
static VALUE fillarea(VALUE self,VALUE x, VALUE y){
int x_size = RARRAY_LEN(x);
int y_size = RARRAY_LEN(y);
int size = (x_size <= y_size) ? x_size : y_size;
double *xc = rb_ar_2_dbl_ar(x);
double *yc = rb_ar_2_dbl_ar(y);
gr_fillarea(size,xc,yc);
return Qtrue;
}
static VALUE cellarray(VALUE self,VALUE xmin,VALUE xmax,VALUE ymin,VALUE ymax,
VALUE dimx,VALUE dimy,VALUE scol,VALUE srow,VALUE ncol,
VALUE nrow,VALUE color) {
double xminc = NUM2DBL(xmin);
double xmaxc = NUM2DBL(xmax);
double yminc = NUM2DBL(ymin);
double ymaxc = NUM2DBL(ymax);
int dimxc = NUM2INT(dimx);
int dimyc = NUM2INT(dimy);
int scolc = NUM2INT(scol);
int srowc = NUM2INT(srow);
int ncolc = NUM2INT(ncol);
int nrowc = NUM2INT(nrow);
int *colorc = rb_ar_2_int_ar(color);
gr_cellarray(xminc,xmaxc,yminc,ymaxc,dimxc,dimyc,scolc,srowc,ncolc,nrowc,colorc);
return Qtrue;
}
static VALUE gdp(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d,VALUE e,VALUE f){
int ac = NUM2INT(a);
double *bc = rb_ar_2_dbl_ar(b);
double *cc = rb_ar_2_dbl_ar(c);
int dc = NUM2INT(d);
int ec = NUM2INT(e);
int *fc = rb_ar_2_int_ar(f);
gr_gdp(ac,bc,cc,dc,ec,fc);
return Qtrue;
}
static VALUE spline(VALUE self,VALUE n,VALUE px,VALUE py,VALUE m,VALUE method){
int nc = NUM2INT(n);
double *pxc = rb_ar_2_dbl_ar(px);
double *pyc = rb_ar_2_dbl_ar(py);
int mc = NUM2INT(m);
int methodc = NUM2INT(method);
gr_spline(nc,pxc,pyc,mc,methodc);
return Qtrue;
}
static VALUE gridit(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d,VALUE e,VALUE f,
VALUE g,VALUE h,VALUE i) {
int ac = NUM2INT(a);
double *bc = rb_ar_2_dbl_ar(b);
double *cc = rb_ar_2_dbl_ar(c);
double *dc = rb_ar_2_dbl_ar(d);
int ec = NUM2INT(e);
int fc = NUM2INT(f);
double *gc = rb_ar_2_dbl_ar(g);
double *hc = rb_ar_2_dbl_ar(h);
double *ic = rb_ar_2_dbl_ar(i);
gr_gridit(ac,bc,cc,dc,ec,fc,gc,hc,ic);
return Qtrue;
//Can be optimised for Ruby
}
/**
* call-seq:
* Rubyplot::GR.setlinetype(type) -> true
*
* Specify the line style for polylines.
*
* **Parameters:**
*
* `style` :
* The polyline line style
*
* The available line types are:
*
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_SOLID | 1|Solid line |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_DASHED | 2|Dashed line |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_DOTTED | 3|Dotted line |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_DASHED_DOTTED | 4|Dashed-dotted line |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_DASH_2_DOT | -1|Sequence of one dash followed by two dots |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_DASH_3_DOT | -2|Sequence of one dash followed by three dots |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_LONG_DASH | -3|Sequence of long dashes |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_LONG_SHORT_DASH | -4|Sequence of a long dash followed by a short dash |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_SPACED_DASH | -5|Sequence of dashes double spaced |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_SPACED_DOT | -6|Sequence of dots double spaced |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_DOUBLE_DOT | -7|Sequence of pairs of dots |
* +---------------------------+----+---------------------------------------------------+
* |LINETYPE_TRIPLE_DOT | -8|Sequence of groups of three dots |
* +---------------------------+----+---------------------------------------------------+
*/
static VALUE setlinetype(VALUE self,VALUE type){
int typec = NUM2INT(type);
gr_setlinetype(typec);
return Qtrue;
}
static VALUE inqlinetype(VALUE self,VALUE a){
int *ac = rb_ar_2_int_ar(a);
gr_inqlinetype(ac);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.setlinewidth(1.3) -> true
* Define the line width of subsequent polyline output primitives.
*
* Parameters:
*
* `width` :
* The polyline line width scale factor
*
* The line width is calculated as the nominal line width generated
* on the workstation multiplied by the line width scale factor.
* This value is mapped by the workstation to the nearest available line width.
* The default line width is 1.0, or 1 times the line width generated on the graphics device.
*/
static VALUE setlinewidth(VALUE self,VALUE width) {
double widthc = NUM2DBL(width);
gr_setlinewidth(widthc);
return Qtrue;
}
static VALUE inqlinewidth(VALUE self,VALUE a){
double *ac = rb_ar_2_dbl_ar(a);
gr_inqlinewidth(ac);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.setlinecolorind(4) -> true
*
* Define the color of subsequent polyline output primitives.
*
* **Parameters:**
*
* `color` :
* The polyline color index (COLOR < 1256)
*/
static VALUE setlinecolorind(VALUE self,VALUE color) {
int colorc = NUM2INT(color);
gr_setlinecolorind(colorc);
return Qtrue;
}
static VALUE inqlinecolorind(VALUE self,VALUE a){
int *ac = rb_ar_2_int_ar(a);
gr_inqlinecolorind(ac);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.setmarkertype(style) -> true
*
* Specifiy the marker type for polymarkers.
*
* **Parameters:**
*
* `style` :
* The polymarker marker type
*
* The available marker types are:
*
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_DOT | 1|Smallest displayable dot |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_PLUS | 2|Plus sign |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_ASTERISK | 3|Asterisk |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_CIRCLE | 4|Hollow circle |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_DIAGONAL_CROSS | 5|Diagonal cross |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_CIRCLE | -1|Filled circle |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_TRIANGLE_UP | -2|Hollow triangle pointing upward |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_TRI_UP | -3|Filled triangle pointing upward |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_TRIANGLE_DOWN | -4|Hollow triangle pointing downward |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_TRI_DOWN | -5|Filled triangle pointing downward |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SQUARE | -6|Hollow square |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_SQUARE | -7|Filled square |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_BOWTIE | -8|Hollow bowtie |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_BOWTIE | -9|Filled bowtie |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_HGLASS | -10|Hollow hourglass |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_HGLASS | -11|Filled hourglass |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_DIAMOND | -12|Hollow diamond |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_DIAMOND | -13|Filled Diamond |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_STAR | -14|Hollow star |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_STAR | -15|Filled Star |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_TRI_UP_DOWN | -16|Hollow triangles pointing up and down overlaid |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_TRI_RIGHT | -17|Filled triangle point right |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID_TRI_LEFT | -18|Filled triangle pointing left |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_HOLLOW PLUS | -19|Hollow plus sign |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_SOLID PLUS | -20|Solid plus sign |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_PENTAGON | -21|Pentagon |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_HEXAGON | -22|Hexagon |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_HEPTAGON | -23|Heptagon |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_OCTAGON | -24|Octagon |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_STAR_4 | -25|4-pointed star |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_STAR_5 | -26|5-pointed star (pentagram) |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_STAR_6 | -27|6-pointed star (hexagram) |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_STAR_7 | -28|7-pointed star (heptagram) |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_STAR_8 | -29|8-pointed star (octagram) |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_VLINE | -30|verical line |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_HLINE | -31|horizontal line |
* +-----------------------------+-----+------------------------------------------------+
* |MARKERTYPE_OMARK | -32|o-mark |
* +-----------------------------+-----+------------------------------------------------+
*
* Polymarkers appear centered over their specified coordinates.
*/
static VALUE setmarkertype(VALUE self, VALUE type){
int typec = NUM2INT(type);
gr_setmarkertype(typec);
return Qtrue;
}
static VALUE inqmarkertype(VALUE self,VALUE a){
int *ac = rb_ar_2_int_ar(a);
gr_inqmarkertype(ac);
return Qtrue;
}
static VALUE setmarkersize(VALUE self, VALUE size){
double sizec = NUM2DBL(size);
gr_setmarkersize(sizec);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR::setmarkercolorind(color) -> true
*
*
*/
static VALUE setmarkercolorind(VALUE self,VALUE color){
double colorc = NUM2INT(color);
gr_setmarkercolorind(colorc);
return Qtrue;
}
static VALUE inqmarkercolorind(VALUE self,VALUE a){
int *ac = rb_ar_2_int_ar(a);
gr_inqmarkercolorind(ac);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.settextprecision(font, precision)-> true
*
* Specify the text font and precision for subsequent text output primitives.
*
* **Parameters:**
*
* `font` :
* Text font (see tables below)
* `precision` :
* Text precision (see table below)
*
* The available text fonts are:
*
* +--------------------------------------+-----+
* |FONT_TIMES_ROMAN | 101|
* +--------------------------------------+-----+
* |FONT_TIMES_ITALIC | 102|
* +--------------------------------------+-----+
* |FONT_TIMES_BOLD | 103|
* +--------------------------------------+-----+
* |FONT_TIMES_BOLDITALIC | 104|
* +--------------------------------------+-----+
* |FONT_HELVETICA | 105|
* +--------------------------------------+-----+
* |FONT_HELVETICA_OBLIQUE | 106|
* +--------------------------------------+-----+
* |FONT_HELVETICA_BOLD | 107|
* +--------------------------------------+-----+
* |FONT_HELVETICA_BOLDOBLIQUE | 108|
* +--------------------------------------+-----+
* |FONT_COURIER | 109|
* +--------------------------------------+-----+
* |FONT_COURIER_OBLIQUE | 110|
* +--------------------------------------+-----+
* |FONT_COURIER_BOLD | 111|
* +--------------------------------------+-----+
* |FONT_COURIER_BOLDOBLIQUE | 112|
* +--------------------------------------+-----+
* |FONT_SYMBOL | 113|
* +--------------------------------------+-----+
* |FONT_BOOKMAN_LIGHT | 114|
* +--------------------------------------+-----+
* |FONT_BOOKMAN_LIGHTITALIC | 115|
* +--------------------------------------+-----+
* |FONT_BOOKMAN_DEMI | 116|
* +--------------------------------------+-----+
* |FONT_BOOKMAN_DEMIITALIC | 117|
* +--------------------------------------+-----+
* |FONT_NEWCENTURYSCHLBK_ROMAN | 118|
* +--------------------------------------+-----+
* |FONT_NEWCENTURYSCHLBK_ITALIC | 119|
* +--------------------------------------+-----+
* |FONT_NEWCENTURYSCHLBK_BOLD | 120|
* +--------------------------------------+-----+
* |FONT_NEWCENTURYSCHLBK_BOLDITALIC | 121|
* +--------------------------------------+-----+
* |FONT_AVANTGARDE_BOOK | 122|
* +--------------------------------------+-----+
* |FONT_AVANTGARDE_BOOKOBLIQUE | 123|
* +--------------------------------------+-----+
* |FONT_AVANTGARDE_DEMI | 124|
* +--------------------------------------+-----+
* |FONT_AVANTGARDE_DEMIOBLIQUE | 125|
* +--------------------------------------+-----+
* |FONT_PALATINO_ROMAN | 126|
* +--------------------------------------+-----+
* |FONT_PALATINO_ITALIC | 127|
* +--------------------------------------+-----+
* |FONT_PALATINO_BOLD | 128|
* +--------------------------------------+-----+
* |FONT_PALATINO_BOLDITALIC | 129|
* +--------------------------------------+-----+
* |FONT_ZAPFCHANCERY_MEDIUMITALIC | 130|
* +--------------------------------------+-----+
* |FONT_ZAPFDINGBATS | 131|
* +--------------------------------------+-----+
*
* The available text precisions are:
*
* +---------------------------+---+--------------------------------------+
* |TEXT_PRECISION_STRING | 0|String precision (higher quality) |
* +---------------------------+---+--------------------------------------+
* |TEXT_PRECISION_CHAR | 1|Character precision (medium quality) |
* +---------------------------+---+--------------------------------------+
* |TEXT_PRECISION_STROKE | 2|Stroke precision (lower quality) |
* +---------------------------+---+--------------------------------------+
*
* The appearance of a font depends on the text precision value specified.
* STRING, CHARACTER or STROKE precision allows for a greater or lesser
* realization of the text primitives, for efficiency. STRING is the default
* precision for GR and produces the highest quality output.
*/
static VALUE settextfontprec(VALUE self, VALUE font, VALUE precision){
int fontc = NUM2INT(font);
int precisionc = NUM2INT(precision);
gr_settextfontprec(fontc, precisionc);
return Qtrue;
}
static VALUE setcharexpan(VALUE self,VALUE factor){
double factorc = NUM2DBL(factor);
gr_setcharexpan(factorc);
return Qtrue;
}
static VALUE setcharspace(VALUE self,VALUE a){
double ac = NUM2DBL(a);
gr_setcharspace(ac);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.settextcolorind(color) -> true
*
* Sets the current text color index.
*
* **Parameters:**
*
* `color` :
* The text color index (COLOR < 1256)
*
* `settextcolorind` defines the color of subsequent text output primitives.
* GR uses the default foreground color (black=1) for the default text color index.
*/
static VALUE settextcolorind(VALUE self,VALUE color){
int colorc = NUM2INT(color);
gr_settextcolorind(colorc);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.setcharheight(0.05) -> true
*
* Set the current character height.
*
* **Parameters:**
*
* `height` :
* Text height value
*
* `setcharheight` defines the height of subsequent text output primitives. Text height
* is defined as a percentage of the default window. GR uses the default text height of
* 0.027 (2.7% of the height of the default window).
*/
static VALUE setcharheight(VALUE self, VALUE height) {
double heightc= NUM2DBL(height);
gr_setcharheight(heightc);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.setcharup(0, 0.5) -> true
*
* Set the current character text angle up vector.
*
* **Parameters:**
*
* `ux`, `uy` :
* Text up vector
*
* `setcharup` defines the vertical rotation of subsequent text output primitives.
* The text up vector is initially set to (0, 1), horizontal to the baseline.
*/
static VALUE setcharup(VALUE self,VALUE ux,VALUE uy) {
double uxc = NUM2DBL(ux);
double uyc = NUM2DBL(uy);
gr_setcharup(uxc,uyc);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.settextpath(2) -> true
*
* Define the current direction in which subsequent text will be drawn.
*
* **Parameters:**
*
* `path` :
* Text path (see table below)
*
* +----------------------+---+---------------+
* |TEXT_PATH_RIGHT | 0|left-to-right |
* +----------------------+---+---------------+
* |TEXT_PATH_LEFT | 1|right-to-left |
* +----------------------+---+---------------+
* |TEXT_PATH_UP | 2|downside-up |
* +----------------------+---+---------------+
* |TEXT_PATH_DOWN | 3|upside-down |
* +----------------------+---+---------------+
*/
static VALUE settextpath(VALUE self,VALUE path){
int pathc = NUM2INT(path);
gr_settextpath(pathc);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.settextalign(Rubyplot::GR::TEXT_HALIGN_NORMAL,
* Rubyplot::GR::TEXT_VALIGN_LEFT) -> true
*
* Set the current horizontal and vertical alignment for text.
*
* **Parameters:**
*
* `horizontal` :
* Horizontal text alignment (see the table below)
* `vertical` :
* Vertical text alignment (see the table below)
*
* `settextalign` specifies how the characters in a text primitive will be aligned
* in horizontal and vertical space. The default text alignment indicates horizontal left
* alignment and vertical baseline alignment.
*
* +-------------------------+---+----------------+
* |TEXT_HALIGN_NORMAL | 0| |
* +-------------------------+---+----------------+
* |TEXT_HALIGN_LEFT | 1|Left justify |
* +-------------------------+---+----------------+
* |TEXT_HALIGN_CENTER | 2|Center justify |
* +-------------------------+---+----------------+
* |TEXT_HALIGN_RIGHT | 3|Right justify |
* +-------------------------+---+----------------+
*
* +-------------------------+---+------------------------------------------------+
* |TEXT_VALIGN_NORMAL | 0| |
* +-------------------------+---+------------------------------------------------+
* |TEXT_VALIGN_TOP | 1|Align with the top of the characters |
* +-------------------------+---+------------------------------------------------+
* |TEXT_VALIGN_CAP | 2|Aligned with the cap of the characters |
* +-------------------------+---+------------------------------------------------+
* |TEXT_VALIGN_HALF | 3|Aligned with the half line of the characters |
* +-------------------------+---+------------------------------------------------+
* |TEXT_VALIGN_BASE | 4|Aligned with the base line of the characters |
* +-------------------------+---+------------------------------------------------+
* |TEXT_VALIGN_BOTTOM | 5|Aligned with the bottom line of the characters |
* +-------------------------+---+------------------------------------------------+
*/
static VALUE settextalign(VALUE self, VALUE horizontal, VALUE vertical) {
int horizontalc = NUM2INT(horizontal);
int verticalc = NUM2INT(vertical);
gr_settextalign(horizontalc,verticalc);
return Qtrue;
}
/**
* call-seq:
* Rubyplot::GR.setfillintstyle(3) -> true
*
* Set the fill area interior style to be used for fill areas.
*
* **Parameters:**
*
* `style` :
* The style of fill to be used
*
* `setfillintstyle` defines the interior style for subsequent fill area output
* primitives. The default interior style is HOLLOW.
*
* +------------------+-+-----------------------------------------------------------------------+
* |INTSTYLE_HOLLOW |0|No filling. Just draw the bounding polyline |
* +------------------+-+-----------------------------------------------------------------------+
* |INTSTYLE_SOLID |1|Fill the interior of the polygon using the fill color index |
* +------------------+-+-----------------------------------------------------------------------+
* |INTSTYLE_PATTERN |2|Fill the interior of the polygon using the style index as a pattern index|
* +-----------------+--+------------------------------------------------------------------------+
* |INTSTYLE_HATCH |3|Fill the interior of the polygon using the style index as a cross-hatched style|
* +-----------------+-+--------------------------------------------------------------------------+
*/
static VALUE setfillintstyle(VALUE self,VALUE style) {
int stylec = NUM2INT(style);
gr_setfillintstyle(stylec);
return Qtrue;
}
/**
*Sets the fill style to be used for subsequent fill areas.
*
***Parameters:**
*
*`index` :
*The fill style index to be used
*
*`setfillstyle` specifies an index when PATTERN fill or HATCH fill is requested by the
*`setfillintstyle` function. If the interior style is set to PATTERN, the fill style
* index points to a device-independent pattern table. If interior style is set to HATCH
* the fill style index indicates different hatch styles. If HOLLOW or SOLID is specified
* for the interior style, the fill style index is unused.
*/
static VALUE setfillstyle(VALUE self,VALUE index){
int indexc = NUM2INT(index);
gr_setfillstyle(indexc);
return Qtrue;
}
/*
*Sets the current fill area color index.
*
***Parameters:**
*
*`color` :
*The fill area color index (COLOR < 1256)
*
* `setfillcolorind` defines the color of subsequent fill area output primitives.
* GR uses the default foreground color (black=1) for the default fill area color index.
*/
static VALUE setfillcolorind(VALUE self,VALUE color) {
int colorc = NUM2INT(color);
gr_setfillcolorind(colorc);
return Qtrue;
}
static VALUE setcolorrep(VALUE self,VALUE index,VALUE red,VALUE green,VALUE blue){
int indexc = NUM2INT(index);
double redc = NUM2DBL(red);
double greenc = NUM2DBL(green);
double bluec = NUM2DBL(blue);
gr_setcolorrep(index,red,green,blue);
return Qtrue;
}
/*
* call-seq:
* Rubyplot::GR.setwindow(xmin, xmax, ymin, ymax) -> true
*
* Set a window or rectangular subspace of world co-ordinates to be plotted.
*
* xmin [Numeric] : Minimum value of X data in this window.
* xmax [Numeric] : Maximum value of X data in this window.
* ymin [Numeric] : Minimum value of Y data in this window.
* ymax [Numeric] : Maximum value of Y data in this window.
*
*/
static VALUE setwindow(VALUE self, VALUE xmin, VALUE xmax,VALUE ymin, VALUE ymax) {
double xminc = NUM2DBL(xmin);
double xmaxc = NUM2DBL(xmax);
double yminc = NUM2DBL(ymin);
double ymaxc = NUM2DBL(ymax);
gr_setwindow(xminc,xmaxc,yminc,ymaxc);
return Qtrue;
}
static VALUE inqwindow(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d) {
double *ac = rb_ar_2_dbl_ar(a);
double *bc = rb_ar_2_dbl_ar(b);
double *cc = rb_ar_2_dbl_ar(c);
double *dc = rb_ar_2_dbl_ar(d);
gr_inqwindow(ac,bc,cc,dc);
return Qtrue;
}
/*
* call-seq:
* Rubyplot::GR.setviewport(xmin, xmax, ymin, ymax) -> true
*
* `setviewport` establishes a rectangular subspace of normalized device coordinates.
*
* `setviewport` defines the rectangular portion of the Normalized Device Coordinate
* (NDC) space to be associated with the specified normalization transformation. The
* NDC viewport and World Coordinate (WC) window define the normalization transformation
* through which all output primitives pass. The WC window is mapped onto the rectangular
* NDC viewport which is, in turn, mapped onto the display surface of the open and active
* workstation, in device coordinates.
*
* xmin [Numeric] :
* xmax [Numeric] :
* ymin [Numeric] :
* ymax [Numeric] :
*/
static VALUE setviewport(VALUE self, VALUE xmin, VALUE xmax, VALUE ymin, VALUE ymax) {
double xminc = NUM2DBL(xmin);
double xmaxc = NUM2DBL(xmax);
double yminc = NUM2DBL(ymin);
double ymaxc = NUM2DBL(ymax);
gr_setviewport(xminc,xmaxc,yminc,ymaxc);
return Qtrue;
}
static VALUE inqviewport(VALUE self,VALUE a,VALUE b,VALUE c,VALUE d){
double *ac = rb_ar_2_dbl_ar(a);
double *bc = rb_ar_2_dbl_ar(b);
double *cc = rb_ar_2_dbl_ar(c);
double *dc = rb_ar_2_dbl_ar(d);
gr_inqviewport(ac,bc,cc,dc);
return Qtrue;
}
static VALUE selntran(VALUE self,VALUE transform){
int transformc = NUM2INT(transform);
gr_selntran(transformc);
return Qtrue;
}
static VALUE setclip(VALUE self,VALUE indicator){
int indicatorc = NUM2INT(indicator);
gr_setclip(indicatorc);
return Qtrue;
}
/*
* Set the area of the NDC viewport that is to be drawn in the workstation window.
*
* **Parameters:**
*
* `xmin` :
* The left horizontal coordinate of the workstation window.
* `xmax` :
* The right horizontal coordinate of the workstation window (0 <= `xmin` < `xmax` <= 1).
* `ymin` :
* The bottom vertical coordinate of the workstation window.
* `ymax` :
* The top vertical coordinate of the workstation window (0 <= `ymin` < `ymax` <= 1).
*
* `setwswindow` defines the rectangular area of the Normalized Device Coordinate space
* to be output to the device. By default, the workstation transformation will map the
* range [0,1] x [0,1] in NDC onto the largest square on the workstation’s display
* surface. The aspect ratio of the workstation window is maintained at 1 to 1.
**/
static VALUE setwswindow(VALUE self,VALUE xmin,VALUE xmax,VALUE ymin,VALUE ymax) {
double xminc = NUM2DBL(xmin);
double xmaxc = NUM2DBL(xmax);
double yminc = NUM2DBL(ymin);
double ymaxc = NUM2DBL(ymax);
gr_setwswindow(xminc,xmaxc,yminc,ymaxc);