ruby-gr 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +24 -0
- data/README.md +52 -9
- data/lib/gr.rb +80 -1
- data/lib/gr/ffi.rb +5 -1
- data/lib/gr/plot.rb +40 -23
- data/lib/gr3/ffi.rb +11 -2
- data/lib/gr_commons/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d9ef46d38e4a4cb1d52b933af0b1d3a44de17e780bbb0dc404ac62a40026827
|
4
|
+
data.tar.gz: 9084d96ecd560a87d7540d736e87312cc3351f85bcdc4a2ed1a4eb5b590b3ed0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b4acddc1c8237754644b1e75b9b11d87364e0ef2d5fac59e9ce5685464dcab180817e130a0b244cf27ac3716d0c9e1e6f78192b031a229b42cc1157117aea70
|
7
|
+
data.tar.gz: cf0daf98117cf7408bb1b8f3e33006043a0cd3c7f17da6f0521d98b2ebf5788be88defc0e6909ed00101a1f3a9023dbfb3cc9879b86c79193fc6750d8f6022f9
|
data/LICENSE.txt
CHANGED
@@ -20,3 +20,27 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
20
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
22
|
THE SOFTWARE.
|
23
|
+
|
24
|
+
The Fiddley module is:
|
25
|
+
|
26
|
+
Copyright (c) 2017 NAKAMURA Usaku usa@garbagecollect.jp
|
27
|
+
|
28
|
+
Redistribution and use in source and binary forms, with or without
|
29
|
+
modification, are permitted provided that the following conditions are met:
|
30
|
+
|
31
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
32
|
+
list of conditions and the following disclaimer.
|
33
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
34
|
+
this list of conditions and the following disclaimer in the documentation
|
35
|
+
and/or other materials provided with the distribution.
|
36
|
+
|
37
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
38
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
39
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
40
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
41
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
42
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
43
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
44
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
45
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
46
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -49,10 +49,49 @@ GR.plot(x, y)
|
|
49
49
|
|
50
50
|
## Examples
|
51
51
|
|
52
|
-
Have a look in the [`examples`](https://github.com/red-data-tools/GR.rb/tree/master/examples) directory.
|
52
|
+
Have a look in the [`examples`](https://github.com/red-data-tools/GR.rb/tree/master/examples) directory. Start with [`fast_plot`](https://github.com/red-data-tools/GR.rb/blob/master/examples/fast_plots.rb).
|
53
|
+
|
54
|
+
## Features
|
55
|
+
|
56
|
+
#### GR::Plot
|
57
|
+
|
58
|
+
A simple, matlab-style API.
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
require 'gr/plot'
|
62
|
+
```
|
63
|
+
|
64
|
+
`plot` `step` `scatter` `stem` `histogram` `contour` `contourf` `hexbin` `heatmap` `wireframe` `surface` `plot3` `scatter3` `imshow` `isosurface` `polar` `polarhist` `polarheatmap` `trisurf` `tricont` `shade` `volume`
|
65
|
+
|
66
|
+
#### GR
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
require 'gr'
|
70
|
+
```
|
71
|
+
|
72
|
+
#### GR3
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
require 'gr3'
|
76
|
+
```
|
77
|
+
|
78
|
+
## Documentation
|
79
|
+
|
80
|
+
- [GR Framework](https://gr-framework.org/)
|
81
|
+
- [GR.rb API Documentation](https://rubydoc.info/gems/ruby-gr)
|
53
82
|
|
54
83
|
## GR Installation
|
55
84
|
|
85
|
+
### Official binary release
|
86
|
+
|
87
|
+
Download the [latest release](https://github.com/sciapp/gr/releases).
|
88
|
+
|
89
|
+
Set environment variable GRDIR.
|
90
|
+
|
91
|
+
```sh
|
92
|
+
export GRDIR="your/path/to/gr"
|
93
|
+
```
|
94
|
+
|
56
95
|
### Homebrew
|
57
96
|
|
58
97
|
```sh
|
@@ -65,16 +104,20 @@ Set environment variable GRDIR.
|
|
65
104
|
export GRDIR=$(brew --prefix libgr)
|
66
105
|
```
|
67
106
|
|
68
|
-
|
107
|
+
If you fail to build libgr using homebrew, Please feel free to [send us your feedback](https://github.com/red-data-tools/GR.rb/issues).
|
69
108
|
|
70
|
-
|
109
|
+
## Backend for Charty
|
71
110
|
|
72
|
-
|
73
|
-
|
74
|
-
```sh
|
75
|
-
export GRDIR="your/path/to/gr"
|
76
|
-
```
|
111
|
+
GR.rb is expected to be the backend for [Charty](https://github.com/red-data-tools/charty) in the future.
|
77
112
|
|
78
113
|
## Contributing
|
79
114
|
|
80
|
-
|
115
|
+
* Report bugs
|
116
|
+
* Fix bugs and submit pull requests
|
117
|
+
* Write, clarify, or fix documentation
|
118
|
+
* Suggest or add new features
|
119
|
+
|
120
|
+
## Acknowledgements
|
121
|
+
|
122
|
+
We would like to thank Josef Heinen, the creator of [GR.jl](https://github.com/jheinen/GR.jl) and Florian Rhiem, the creator of [python-gr](https://github.com/sciapp/python-gr).
|
123
|
+
|
data/lib/gr.rb
CHANGED
@@ -529,6 +529,13 @@ module GR
|
|
529
529
|
super
|
530
530
|
end
|
531
531
|
|
532
|
+
# Gets the current text color index.
|
533
|
+
# This function gets the color of text output primitives.
|
534
|
+
# @return [Integer] color The text color index (COLOR < 1256)
|
535
|
+
def inqtextcolorind
|
536
|
+
inquiry_int { |pt| super(pt) }
|
537
|
+
end
|
538
|
+
|
532
539
|
# Set the current character height.
|
533
540
|
# @param height [Numeric] Text height value
|
534
541
|
# `setcharheight` defines the height of subsequent text output primitives. Text height
|
@@ -1399,12 +1406,14 @@ module GR
|
|
1399
1406
|
|
1400
1407
|
# @return [Integer]
|
1401
1408
|
def readimage(path)
|
1409
|
+
# Feel free to make a pull request if you catch a mistake
|
1410
|
+
# or you have an idea to improve it.
|
1402
1411
|
data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
|
1403
1412
|
w, h = inquiry [:int, :int] do |width, height|
|
1404
1413
|
# data is a pointer of a pointer
|
1405
1414
|
super(path, width, height, data.ref)
|
1406
1415
|
end
|
1407
|
-
d = data.to_str(w * h *
|
1416
|
+
d = data.to_str(w * h * Fiddle::SIZEOF_INT).unpack('L*') # UInt32
|
1408
1417
|
[w, h, d]
|
1409
1418
|
end
|
1410
1419
|
|
@@ -1560,6 +1569,26 @@ module GR
|
|
1560
1569
|
super
|
1561
1570
|
end
|
1562
1571
|
|
1572
|
+
def delaunay(x, y)
|
1573
|
+
# Feel free to make a pull request if you catch a mistake
|
1574
|
+
# or you have an idea to improve it.
|
1575
|
+
npoints = equal_length(x, y)
|
1576
|
+
triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
|
1577
|
+
dim = 3
|
1578
|
+
n_tri = inquiry_int do |ntri|
|
1579
|
+
super(npoints, x, y, ntri, triangles.ref)
|
1580
|
+
end
|
1581
|
+
if n_tri > 0
|
1582
|
+
tri = triangles.to_str(3 * n_tri * Fiddle::SIZEOF_INT).unpack('l*') # Int32
|
1583
|
+
# Ruby : 0-based indexing
|
1584
|
+
# Julia : 1-based indexing
|
1585
|
+
tri = tri.each_slice(3).to_a
|
1586
|
+
[n_tri, tri]
|
1587
|
+
else
|
1588
|
+
0
|
1589
|
+
end
|
1590
|
+
end
|
1591
|
+
|
1563
1592
|
# Reduces the number of points of the x and y array.
|
1564
1593
|
def reducepoints(xd, yd, n)
|
1565
1594
|
nd = equal_length(xd, yd)
|
@@ -1913,6 +1942,39 @@ module GR
|
|
1913
1942
|
super(*pts)
|
1914
1943
|
end
|
1915
1944
|
end
|
1945
|
+
|
1946
|
+
# Set the scale factor for each axis. A one means no scale.
|
1947
|
+
# All factor have to be != 0.
|
1948
|
+
# @param x_axis_scale [Numeric] factor for scaling the x-axis
|
1949
|
+
# @param y_axis_scale [Numeric] factor for scaling the y-axis
|
1950
|
+
# @param z_axis_scale [Numeric] factor for scaling the z-axis
|
1951
|
+
def setscalefactors3d(*)
|
1952
|
+
super
|
1953
|
+
end
|
1954
|
+
|
1955
|
+
# Returns the scale factors for each axis.
|
1956
|
+
def inqscalefactors3d
|
1957
|
+
inquiry %i[double double double] do |*opts|
|
1958
|
+
super(*opts)
|
1959
|
+
end
|
1960
|
+
end
|
1961
|
+
|
1962
|
+
# This is an interface for REPL based languages to enable an easier way to
|
1963
|
+
# rotate around an object.
|
1964
|
+
# The center of the 3d window is used as the focus point and the camera is
|
1965
|
+
# positioned relative to it, using spherical coordinates. This function can
|
1966
|
+
# therefore also be used if the user prefers spherical coordinates to setting
|
1967
|
+
# the direct camera position, but with reduced functionality in comparison
|
1968
|
+
# to gr.settransformationparameters, gr.setperspectiveprojection and
|
1969
|
+
# gr.setorthographicprojection.
|
1970
|
+
# @param phi [Numeric] phi angle of the spherical coordinates
|
1971
|
+
# @param theta [Numeric] theta angle of the spherical coordinates
|
1972
|
+
# @param fov [Numeric] vertical field of view (0 or NaN for orthographic projection)
|
1973
|
+
# @param radius [Numeric] distance between the camera and the focus point
|
1974
|
+
# (0 or NaN for the radius of the object's smallest bounding sphere)
|
1975
|
+
def transformationinterfaceforrepl(*)
|
1976
|
+
super
|
1977
|
+
end
|
1916
1978
|
end
|
1917
1979
|
|
1918
1980
|
ASF_BUNDLED = 0
|
@@ -2147,4 +2209,21 @@ module GR
|
|
2147
2209
|
UPSAMPLE_HORIZONTAL_LANCZOS = 0x00000300
|
2148
2210
|
DOWNSAMPLE_VERTICAL_LANCZOS = 0x00030000
|
2149
2211
|
DOWNSAMPLE_HORIZONTAL_LANCZOS = 0x03000000
|
2212
|
+
|
2213
|
+
RESAMPLE_DEFAULT =
|
2214
|
+
(UPSAMPLE_VERTICAL_DEFAULT | UPSAMPLE_HORIZONTAL_DEFAULT |
|
2215
|
+
DOWNSAMPLE_VERTICAL_DEFAULT | DOWNSAMPLE_HORIZONTAL_DEFAULT)
|
2216
|
+
RESAMPLE_NEAREST =
|
2217
|
+
(UPSAMPLE_VERTICAL_NEAREST | UPSAMPLE_HORIZONTAL_NEAREST |
|
2218
|
+
DOWNSAMPLE_VERTICAL_NEAREST | DOWNSAMPLE_HORIZONTAL_NEAREST)
|
2219
|
+
RESAMPLE_LINEAR =
|
2220
|
+
(UPSAMPLE_VERTICAL_LINEAR | UPSAMPLE_HORIZONTAL_LINEAR |
|
2221
|
+
DOWNSAMPLE_VERTICAL_LINEAR | DOWNSAMPLE_HORIZONTAL_LINEAR)
|
2222
|
+
RESAMPLE_LANCZOS =
|
2223
|
+
(UPSAMPLE_VERTICAL_LANCZOS | UPSAMPLE_HORIZONTAL_LANCZOS |
|
2224
|
+
DOWNSAMPLE_VERTICAL_LANCZOS | DOWNSAMPLE_HORIZONTAL_LANCZOS)
|
2225
|
+
|
2226
|
+
PROJECTION_DEFAULT = 0
|
2227
|
+
PROJECTION_ORTHOGRAPHIC = 1
|
2228
|
+
PROJECTION_PERSPECTIVE = 2
|
2150
2229
|
end
|
data/lib/gr/ffi.rb
CHANGED
@@ -61,6 +61,7 @@ module GR
|
|
61
61
|
try_extern 'void gr_setcharexpan(double)'
|
62
62
|
try_extern 'void gr_setcharspace(double)'
|
63
63
|
try_extern 'void gr_settextcolorind(int)'
|
64
|
+
try_extern 'void gr_inqtextcolorind(int *)'
|
64
65
|
try_extern 'void gr_setcharheight(double)'
|
65
66
|
try_extern 'void gr_setcharup(double, double)'
|
66
67
|
try_extern 'void gr_settextpath(int)'
|
@@ -160,7 +161,7 @@ module GR
|
|
160
161
|
try_extern 'void gr_selectcontext(int)'
|
161
162
|
try_extern 'void gr_destroycontext(int)'
|
162
163
|
try_extern 'int gr_uselinespec(char *)'
|
163
|
-
|
164
|
+
try_extern 'void gr_delaunay(int, const double *, const double *, int *, int **)'
|
164
165
|
try_extern 'void gr_reducepoints(int, const double *, const double *, int, double *, double *)'
|
165
166
|
try_extern 'void gr_trisurface(int, double *, double *, double *)'
|
166
167
|
try_extern 'void gr_gradient(int, int, double *, double *, double *, double *, double *)'
|
@@ -193,5 +194,8 @@ module GR
|
|
193
194
|
try_extern 'void gr_camerainteraction(double, double, double, double)'
|
194
195
|
try_extern 'void gr_setwindow3d(double, double, double, double, double, double)'
|
195
196
|
try_extern 'void gr_inqwindow3d(double *, double *, double *, double *, double *, double *)'
|
197
|
+
try_extern 'void gr_setscalefactors3d(double, double, double)'
|
198
|
+
try_extern 'void gr_inqscalefactors3d(double *, double *, double *)'
|
199
|
+
try_extern 'void gr_transformationinterfaceforrepl(double, double, double, double)'
|
196
200
|
end
|
197
201
|
end
|
data/lib/gr/plot.rb
CHANGED
@@ -172,6 +172,7 @@ module GR
|
|
172
172
|
scale |= GR::OPTION_FLIP_Y if kvs[:yflip]
|
173
173
|
scale |= GR::OPTION_FLIP_Z if kvs[:zflip]
|
174
174
|
end
|
175
|
+
kvs[:scale] = scale
|
175
176
|
if kvs.has_key?(:panzoom)
|
176
177
|
xmin, xmax, ymin, ymax = GR.panzoom(*kvs[:panzoom])
|
177
178
|
kvs[:xrange] = [xmin, xmax]
|
@@ -561,6 +562,8 @@ module GR
|
|
561
562
|
# Not yet.
|
562
563
|
end
|
563
564
|
|
565
|
+
GR.settextfontprec(232, 3)
|
566
|
+
|
564
567
|
set_viewport(kind, kvs[:subplot])
|
565
568
|
unless kvs[:ax]
|
566
569
|
set_window(kind)
|
@@ -821,7 +824,7 @@ module GR
|
|
821
824
|
plot_polar(x, y)
|
822
825
|
|
823
826
|
when :trisurf
|
824
|
-
GR.
|
827
|
+
GR.trisurface(x, y, z)
|
825
828
|
draw_axes(kind, 2)
|
826
829
|
colorbar(0.05)
|
827
830
|
|
@@ -1035,9 +1038,12 @@ module GR
|
|
1035
1038
|
def minmax
|
1036
1039
|
xmin = ymin = zmin = cmin = Float::INFINITY
|
1037
1040
|
xmax = ymax = zmax = cmax = -Float::INFINITY
|
1038
|
-
|
1041
|
+
scale = kvs[:scale]
|
1039
1042
|
args.each do |x, y, z, c|
|
1040
1043
|
if x
|
1044
|
+
if scale & GR::OPTION_X_LOG != 0
|
1045
|
+
x.map! { |v| v > 0 ? v : Float::NAN }
|
1046
|
+
end
|
1041
1047
|
x0, x1 = x.minmax
|
1042
1048
|
xmin = [x0, xmin].min
|
1043
1049
|
xmax = [x1, xmax].max
|
@@ -1046,6 +1052,9 @@ module GR
|
|
1046
1052
|
xmax = 1
|
1047
1053
|
end
|
1048
1054
|
if y
|
1055
|
+
if scale & GR::OPTION_Y_LOG != 0
|
1056
|
+
y.map! { |v| v > 0 ? v : Float::NAN }
|
1057
|
+
end
|
1049
1058
|
y0, y1 = y.minmax
|
1050
1059
|
ymin = [y0, ymin].min
|
1051
1060
|
ymax = [y1, ymax].max
|
@@ -1054,6 +1063,9 @@ module GR
|
|
1054
1063
|
ymax = 1
|
1055
1064
|
end
|
1056
1065
|
if z
|
1066
|
+
if scale & GR::OPTION_Z_LOG != 0
|
1067
|
+
z.map! { |v| v > 0 ? v : Float::NAN }
|
1068
|
+
end
|
1057
1069
|
z0, z1 = z.minmax
|
1058
1070
|
zmin = [z0, zmin].min
|
1059
1071
|
zmax = [z1, zmax].max
|
@@ -1114,7 +1126,7 @@ module GR
|
|
1114
1126
|
kvs[:labels].each do |label|
|
1115
1127
|
label = label.to_s
|
1116
1128
|
tbx, tby = inqtext(0, 0, label)
|
1117
|
-
w = [w, tbx[2]].max
|
1129
|
+
w = [w, tbx[2] - tbx[0]].max
|
1118
1130
|
h += [tby[2] - tby[0], 0.03].max
|
1119
1131
|
end
|
1120
1132
|
GR.setscale(scale)
|
@@ -1140,26 +1152,27 @@ module GR
|
|
1140
1152
|
end
|
1141
1153
|
|
1142
1154
|
class << self
|
1143
|
-
# Draw one or more line plots.
|
1155
|
+
# (Plot) Draw one or more line plots.
|
1144
1156
|
def plot(*args)
|
1145
1157
|
create_plot(:line, *args)
|
1146
1158
|
end
|
1147
1159
|
|
1148
|
-
# Draw one or more step or staircase plots.
|
1160
|
+
# (Plot) Draw one or more step or staircase plots.
|
1149
1161
|
def step(*args)
|
1150
1162
|
create_plot(:step, *args)
|
1151
1163
|
end
|
1152
1164
|
|
1153
|
-
# Draw one or more scatter plots.
|
1165
|
+
# (Plot) Draw one or more scatter plots.
|
1154
1166
|
def scatter(*args)
|
1155
1167
|
create_plot(:scatter, *args)
|
1156
1168
|
end
|
1157
1169
|
|
1158
|
-
# Draw a stem plot.
|
1170
|
+
# (Plot) Draw a stem plot.
|
1159
1171
|
def stem(*args)
|
1160
1172
|
create_plot(:stem, *args)
|
1161
1173
|
end
|
1162
1174
|
|
1175
|
+
# (Plot)
|
1163
1176
|
def polarhistogram(x, kv = {})
|
1164
1177
|
plt = GR::Plot.new(x, kv)
|
1165
1178
|
plt.kvs[:kind] = :polarhist
|
@@ -1169,7 +1182,7 @@ module GR
|
|
1169
1182
|
plt.plot_data
|
1170
1183
|
end
|
1171
1184
|
|
1172
|
-
# Draw a heatmap.
|
1185
|
+
# (Plot) Draw a heatmap.
|
1173
1186
|
def heatmap(*args)
|
1174
1187
|
# FIXME
|
1175
1188
|
_x, _y, z, kv = parse_args(*args)
|
@@ -1182,6 +1195,7 @@ module GR
|
|
1182
1195
|
end
|
1183
1196
|
end
|
1184
1197
|
|
1198
|
+
# (Plot) Draw a polarheatmap.
|
1185
1199
|
def polarheatmap(*args)
|
1186
1200
|
d = args.shift
|
1187
1201
|
# FIXME
|
@@ -1197,77 +1211,79 @@ module GR
|
|
1197
1211
|
end
|
1198
1212
|
|
1199
1213
|
alias _contour_ contour
|
1200
|
-
# Draw a contour plot.
|
1214
|
+
# (Plot) Draw a contour plot.
|
1201
1215
|
def contour(*args)
|
1202
1216
|
x, y, z, kv = parse_args(*args)
|
1203
1217
|
create_plot(:contour, x, y, z, kv)
|
1204
1218
|
end
|
1205
1219
|
|
1206
1220
|
alias _contourf_ contourf
|
1207
|
-
# Draw a filled contour plot.
|
1221
|
+
# (Plot) Draw a filled contour plot.
|
1208
1222
|
def contourf(*args)
|
1209
1223
|
x, y, z, kv = parse_args(*args)
|
1210
1224
|
create_plot(:contourf, x, y, z, kv)
|
1211
1225
|
end
|
1212
1226
|
|
1213
1227
|
alias _hexbin_ hexbin
|
1214
|
-
# Draw a hexagon binning plot.
|
1228
|
+
# (Plot) Draw a hexagon binning plot.
|
1215
1229
|
def hexbin(*args)
|
1216
1230
|
create_plot(:hexbin, *args)
|
1217
1231
|
end
|
1218
1232
|
|
1219
|
-
# Draw a triangular contour plot.
|
1233
|
+
# (Plot) Draw a triangular contour plot.
|
1220
1234
|
def tricont(*args)
|
1221
1235
|
x, y, z, kv = parse_args(*args)
|
1222
1236
|
create_plot(:tricont, x, y, z, kv)
|
1223
1237
|
end
|
1224
1238
|
|
1225
|
-
# Draw a three-dimensional wireframe plot.
|
1239
|
+
# (Plot) Draw a three-dimensional wireframe plot.
|
1226
1240
|
def wireframe(*args)
|
1227
1241
|
x, y, z, kv = parse_args(*args)
|
1228
1242
|
create_plot(:wireframe, x, y, z, kv)
|
1229
1243
|
end
|
1230
1244
|
|
1231
|
-
# Draw a three-dimensional surface plot.
|
1245
|
+
# (Plot) Draw a three-dimensional surface plot.
|
1232
1246
|
alias _surface_ surface
|
1233
1247
|
def surface(*args)
|
1234
1248
|
x, y, z, kv = parse_args(*args)
|
1235
1249
|
create_plot(:surface, x, y, z, kv)
|
1236
1250
|
end
|
1237
1251
|
|
1252
|
+
# (Plot)
|
1238
1253
|
def polar(*args)
|
1239
1254
|
create_plot(:polar, *args)
|
1240
1255
|
end
|
1241
1256
|
|
1242
|
-
|
1243
|
-
|
1244
|
-
def trisurface(*args)
|
1257
|
+
# (Plot) Draw a triangular surface plot.
|
1258
|
+
def trisurf(*args)
|
1245
1259
|
x, y, z, kv = parse_args(*args)
|
1246
1260
|
create_plot(:trisurf, x, y, z, kv)
|
1247
1261
|
end
|
1248
1262
|
|
1249
|
-
# Draw one or more three-dimensional line plots.
|
1263
|
+
# (Plot) Draw one or more three-dimensional line plots.
|
1250
1264
|
def plot3(*args)
|
1251
1265
|
create_plot(:plot3, *args)
|
1252
1266
|
end
|
1253
1267
|
|
1254
|
-
# Draw one or more three-dimensional scatter plots.
|
1268
|
+
# (Plot) Draw one or more three-dimensional scatter plots.
|
1255
1269
|
def scatter3(*args)
|
1256
1270
|
create_plot(:scatter3, *args)
|
1257
1271
|
end
|
1258
1272
|
|
1259
1273
|
alias _shade_ shade
|
1274
|
+
# (Plot)
|
1260
1275
|
def shade(*args)
|
1261
1276
|
create_plot(:shade, *args)
|
1262
1277
|
end
|
1263
1278
|
|
1279
|
+
# (Plot)
|
1264
1280
|
def volume(v, kv = {})
|
1265
1281
|
create_plot(:volume, v, kv) do |plt|
|
1266
1282
|
plt.args = [[nil, nil, v, nil, '']]
|
1267
1283
|
end
|
1268
1284
|
end
|
1269
1285
|
|
1270
|
-
# Draw a bar plot.
|
1286
|
+
# (Plot) Draw a bar plot.
|
1271
1287
|
def barplot(labels, heights, kv = {})
|
1272
1288
|
labels = labels.map(&:to_s)
|
1273
1289
|
wc, hc = barcoordinates(heights)
|
@@ -1285,7 +1301,7 @@ module GR
|
|
1285
1301
|
end
|
1286
1302
|
end
|
1287
1303
|
|
1288
|
-
# Draw a histogram.
|
1304
|
+
# (Plot) Draw a histogram.
|
1289
1305
|
def histogram(x, kv = {})
|
1290
1306
|
create_plot(:hist, x, kv) do |plt|
|
1291
1307
|
nbins = plt.kvs[:nbins] || 0
|
@@ -1294,7 +1310,7 @@ module GR
|
|
1294
1310
|
end
|
1295
1311
|
end
|
1296
1312
|
|
1297
|
-
# Draw an image.
|
1313
|
+
# (Plot) Draw an image.
|
1298
1314
|
def imshow(img, kv = {})
|
1299
1315
|
img = Numo::DFloat.cast(img) # Umm...
|
1300
1316
|
create_plot(:imshow, img, kv) do |plt|
|
@@ -1302,7 +1318,7 @@ module GR
|
|
1302
1318
|
end
|
1303
1319
|
end
|
1304
1320
|
|
1305
|
-
# Draw an isosurface.
|
1321
|
+
# (Plot) Draw an isosurface.
|
1306
1322
|
def isosurface(v, kv = {})
|
1307
1323
|
v = Numo::DFloat.cast(v) # Umm...
|
1308
1324
|
create_plot(:isosurface, v, kv) do |plt|
|
@@ -1310,6 +1326,7 @@ module GR
|
|
1310
1326
|
end
|
1311
1327
|
end
|
1312
1328
|
|
1329
|
+
# (Plot) Save the current figure to a file.
|
1313
1330
|
def savefig(filename, kv = {})
|
1314
1331
|
GR.beginprint(filename)
|
1315
1332
|
plt = GR::Plot.last_plot
|
data/lib/gr3/ffi.rb
CHANGED
@@ -73,8 +73,17 @@ module GR3
|
|
73
73
|
try_extern 'void gr3_setviewmatrix(const float *m)'
|
74
74
|
try_extern 'int gr3_getprojectiontype(void)'
|
75
75
|
try_extern 'void gr3_setprojectiontype(int type)'
|
76
|
-
# try_extern 'unsigned int gr3_triangulate(const unsigned short *data,
|
77
|
-
#
|
76
|
+
# try_extern 'unsigned int gr3_triangulate(const unsigned short *data, ' \
|
77
|
+
# 'unsigned short isolevel, unsigned int dim_x, unsigned int dim_y, unsigned int dim_z, ' \
|
78
|
+
# 'unsigned int stride_x, unsigned int stride_y, unsigned int stride_z, ' \
|
79
|
+
# 'double step_x, double step_y, double step_z, double offset_x, double offset_y, double offset_z, ' \
|
80
|
+
# 'gr3_triangle_t **triangles_p)'
|
81
|
+
# try_extern 'void gr3_triangulateindexed(const unsigned short *data, ' \
|
82
|
+
# 'unsigned short isolevel, unsigned int dim_x, unsigned int dim_y, unsigned int dim_z, ' \
|
83
|
+
# 'unsigned int stride_x, unsigned int stride_y, unsigned int stride_z, ' \
|
84
|
+
# 'double step_x, double step_y, double step_z, double offset_x, double offset_y, double offset_z, ' \
|
85
|
+
# 'unsigned int *num_vertices, gr3_coord_t **vertices, gr3_coord_t **normals, ' \
|
86
|
+
# 'unsigned int *num_indices, unsigned int **indices)'
|
78
87
|
try_extern 'int gr3_createisosurfacemesh(int *mesh, unsigned short *data, ' \
|
79
88
|
'unsigned short isolevel, unsigned int dim_x, unsigned int dim_y, unsigned int dim_z, ' \
|
80
89
|
'unsigned int stride_x, unsigned int stride_y, unsigned int stride_z, ' \
|
data/lib/gr_commons/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-gr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03
|
11
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|