ruby-gr 0.0.12 → 0.0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f4e784e40e804964849c5c2f05a123b0d3e406ab7a13b7d04fd86585b5eb1c0
4
- data.tar.gz: bc5d9cd4960f02a434d01a2d61543a06d663408a4cb26eb3717074fd9106735f
3
+ metadata.gz: 0b2f6f44a5b2198487a5b2735ab2dcd33f1b7ce0176a2763ee50a2866273021a
4
+ data.tar.gz: 0073dd18c710ad1107e73b5a365f55f03f746398f33a0cd59211194d940ddee2
5
5
  SHA512:
6
- metadata.gz: 2d82b0a46cfd56972908ba0f79132e38d98b707b440f19e9895cf3698bf9fd6eae7ef44ecee6859f11a057908918e642fc167f2f60f04eb7e96d91daae7bab2f
7
- data.tar.gz: 1783d15a3ba35d762f7c0f53b56e042408a1e86b61924da0e4b49511564dee8961302646747ce4bd1ec9e18cb63f5c653dc2e4728636005b499dc18d8d11b75a
6
+ metadata.gz: 205f75736354151eda828e200ff746e8bd69a8825476f9e7da02aafef6baf360904a8097edf27b12579b4e956821e142b83da9603d3d150b5b32b5f3e08e4214
7
+ data.tar.gz: c7ddc7fd1949b22008f030ace9d3299ce38d6fa80553a27b5c3a3b74441d3376d1a15abc21b9753c5f38296f71981cd019373a2ab09fce5ab43eb413cb58107a
data/README.md CHANGED
@@ -62,7 +62,7 @@ brew install libgr
62
62
  Set environment variable GRDIR.
63
63
 
64
64
  ```sh
65
- export GRDIR="/usr/local/Cellar/libgr/0.44.1"
65
+ export GRDIR=$(brew --prefix libgr)
66
66
  ```
67
67
 
68
68
  ### Mac Linux Windows
data/lib/gr.rb CHANGED
@@ -43,26 +43,25 @@ module GR
43
43
  class Error < StandardError; end
44
44
 
45
45
  class << self
46
- attr_reader :ffi_lib
46
+ attr_accessor :ffi_lib
47
47
  end
48
48
 
49
+ raise Error, 'Please set env variable GRDIR' unless ENV['GRDIR']
50
+
49
51
  # Platforms | path
50
52
  # Windows | bin/libgr.dll
51
53
  # MacOSX | lib/libGR.so (NOT .dylib)
52
54
  # Ubuntu | lib/libGR.so
53
- raise Error, 'Please set env variable GRDIR' unless ENV['GRDIR']
54
-
55
- # Set the font path
56
- ENV['GKS_FONTPATH'] ||= ENV['GRDIR']
57
- # Change the default encoding to UTF-8
58
- ENV['GKS_ENCODING'] ||= 'utf8'
59
55
  if Object.const_defined?(:RubyInstaller)
60
- @ffi_lib = File.expand_path('bin/libgr.dll', ENV['GRDIR'])
61
- RubyInstaller::Runtime.add_dll_directory(File.dirname(@ffi_lib))
56
+ self.ffi_lib = File.expand_path('bin/libgr.dll', ENV['GRDIR'])
57
+ RubyInstaller::Runtime.add_dll_directory(File.dirname(ffi_lib))
62
58
  else
63
- @ffi_lib = File.expand_path('lib/libGR.so', ENV['GRDIR'])
59
+ self.ffi_lib = File.expand_path('lib/libGR.so', ENV['GRDIR'])
64
60
  end
65
61
 
62
+ # Change the default encoding to UTF-8
63
+ ENV['GKS_ENCODING'] ||= 'utf8'
64
+
66
65
  require_relative 'gr_commons/gr_commons'
67
66
  require_relative 'gr/version'
68
67
  require_relative 'gr/ffi'
@@ -1810,6 +1809,110 @@ module GR
1810
1809
  def inqbordercolorind
1811
1810
  inquiry_int { |pt| super(pt) }
1812
1811
  end
1812
+
1813
+ # Set the projection type with this flag.
1814
+ # @param flag [Integer] projection type
1815
+ # The available options are:
1816
+ # * 0 : GR_PROJECTION_DEFAULT
1817
+ # * default
1818
+ # * 1 : GR_PROJECTION_ORTHOGRAPHIC
1819
+ # * orthographic
1820
+ # * 2 : GR_PROJECTION_PERSPECTIVE
1821
+ # * perspective
1822
+ def setprojectiontype(*)
1823
+ super
1824
+ end
1825
+
1826
+ # Return the projection type.
1827
+ def inqprojectiontype
1828
+ inquiry_int { |pt| super(pt) }
1829
+ end
1830
+
1831
+ # Method to set the camera position, the upward facing direction and the
1832
+ # focus point of the shown volume.
1833
+ # @param camera_pos_x [Numeric] x component of the cameraposition in world coordinates
1834
+ # @param camera_pos_y [Numeric] y component of the cameraposition in world coordinates
1835
+ # @param camera_pos_z [Numeric] z component of the cameraposition in world coordinates
1836
+ # @param up_x [Numeric] x component of the up vector
1837
+ # @param up_y [Numeric] y component of the up vector
1838
+ # @param up_z [Numeric] z component of the up vector
1839
+ # @param focus_point_x [Numeric] x component of focus-point inside volume
1840
+ # @param focus_point_y [Numeric] y component of focus-point inside volume
1841
+ # @param focus_point_z [Numeric] z component of focus-point inside volume
1842
+ def settransformationparameters(*)
1843
+ super
1844
+ end
1845
+
1846
+ # Return the camera position, up vector and focus point.
1847
+ def inqtransformationparameters
1848
+ inquiry([:double] * 9) do |*pts|
1849
+ super(*pts)
1850
+ end
1851
+ end
1852
+
1853
+ # Set the far and near clipping plane for perspective projection and the
1854
+ # vertical field ov view.
1855
+ # Switches projection type to perspective.
1856
+ # @param near_plane [Numeric] distance to near clipping plane
1857
+ # @param far_plane [Numeric] distance to far clipping plane
1858
+ # @param fov [Numeric] vertical field of view, input must be between 0 and 180 degrees
1859
+ def setperspectiveprojection(*)
1860
+ super
1861
+ end
1862
+
1863
+ # Return the parameters for the perspective projection.
1864
+ def inqperspectiveprojection
1865
+ inquiry %i[double double double] do |*pts|
1866
+ super(*pts)
1867
+ end
1868
+ end
1869
+
1870
+ # Set parameters for orthographic transformation.
1871
+ # Switches projection type to orthographic.
1872
+ # @param left [Numeric] xmin of the volume in worldcoordinates
1873
+ # @param right [Numeric] xmax of volume in worldcoordinates
1874
+ # @param bottom [Numeric] ymin of volume in worldcoordinates
1875
+ # @param top [Numeric] ymax of volume in worldcoordinates
1876
+ # @param near_plane [Numeric] distance to near clipping plane
1877
+ # @param far_plane [Numeric] distance to far clipping plane
1878
+ def setorthographicprojection(*)
1879
+ super
1880
+ end
1881
+
1882
+ # Return the camera position, up vector and focus point.
1883
+ def inqorthographicprojection
1884
+ inquiry([:double] * 6) do |*pts|
1885
+ super(*pts)
1886
+ end
1887
+ end
1888
+
1889
+ # Interface for interaction with the rotation of the model.
1890
+ # For this a virtual Arcball is used.
1891
+ # @param start_mouse_pos_x [Numeric] x component of the start mouse position
1892
+ # @param start_mouse_pos_y [Numeric] y component of the start mouse position
1893
+ # @param end_mouse_pos_x [Numeric] x component of the end mouse position
1894
+ # @param end_mouse_pos_y [Numeric] y component of the end mouse position
1895
+ def camerainteraction(*)
1896
+ super
1897
+ end
1898
+
1899
+ # Set the three dimensional window. Only used for perspective and orthographic projection.
1900
+ # @param xmin [Numeric] min x-value
1901
+ # @param xmax [Numeric] max x-value
1902
+ # @param ymin [Numeric] min y-value
1903
+ # @param ymax [Numeric] max y-value
1904
+ # @param zmin [Numeric] min z-value
1905
+ # @param zmax [Numeric] max z-value
1906
+ def setwindow3d(*)
1907
+ super
1908
+ end
1909
+
1910
+ # Return the three dimensional window.
1911
+ def inqwindow3d
1912
+ inquiry([:double] * 6) do |*pts|
1913
+ super(*pts)
1914
+ end
1915
+ end
1813
1916
  end
1814
1917
 
1815
1918
  ASF_BUNDLED = 0
@@ -35,15 +35,15 @@ module GR
35
35
  try_extern 'void gr_inqtext(double, double, char *, double *, double *)'
36
36
  try_extern 'void gr_fillarea(int, double *, double *)'
37
37
  try_extern 'void gr_cellarray(double, double, double, double, ' \
38
- 'int, int, int, int, int, int, int *)'
38
+ 'int, int, int, int, int, int, int *)'
39
39
  try_extern 'void gr_nonuniformcellarray(double *, double *, ' \
40
- 'int, int, int, int, int, int, int *)'
40
+ 'int, int, int, int, int, int, int *)'
41
41
  try_extern 'void gr_polarcellarray(double, double, double, double, double, double, ' \
42
- 'int, int, int, int, int, int, int *)'
42
+ 'int, int, int, int, int, int, int *)'
43
43
  try_extern 'void gr_gdp(int, double *, double *, int, int, int *)'
44
44
  try_extern 'void gr_spline(int, double *, double *, int, int)'
45
45
  try_extern 'void gr_gridit(int, double *, double *, double *, int, int, ' \
46
- 'double *, double *, double *)'
46
+ 'double *, double *, double *)'
47
47
  try_extern 'void gr_setlinetype(int)'
48
48
  try_extern 'void gr_inqlinetype(int *)'
49
49
  try_extern 'void gr_setlinewidth(double)'
@@ -94,8 +94,8 @@ module GR
94
94
  try_extern 'void gr_inqtextext(double, double, char *, double *, double *)'
95
95
  try_extern 'void gr_axes(double, double, double, double, int, int, double)'
96
96
  try_extern 'void gr_axeslbl(double, double, double, double, int, int, double,' \
97
- 'void (*)(double, double, const char *, double),' \
98
- 'void (*)(double, double, const char *, double))'
97
+ 'void (*)(double, double, const char *, double),' \
98
+ 'void (*)(double, double, const char *, double))'
99
99
  try_extern 'void gr_grid(double, double, double, double, int, int)'
100
100
  try_extern 'void gr_grid3d(double, double, double, double, double, double, int, int, int)'
101
101
  try_extern 'void gr_verrorbars(int, double *, double *, double *, double *)'
@@ -165,35 +165,7 @@ module GR
165
165
  try_extern 'void gr_gradient(int, int, double *, double *, double *, double *, double *)'
166
166
  try_extern 'void gr_quiver(int, int, double *, double *, double *, double *, int)'
167
167
  try_extern 'void gr_interp2(int nx, int ny, const double *x, const double *y, const double *z,' \
168
- 'int nxq, int nyq, const double *xq, const double *yq, double *zq, int method, double extrapval)'
169
- # try_extern :gr_newmeta
170
- # try_extern :gr_deletemeta
171
- # try_extern :gr_finalizemeta
172
- # try_extern :gr_meta_args_push
173
- # try_extern :gr_meta_args_push_buf
174
- # try_extern :gr_meta_args_contains
175
- # try_extern :gr_meta_args_clear
176
- # try_extern :gr_meta_args_remove
177
- # try_extern :gr_meta_get_box
178
- # try_extern :gr_openmeta
179
- # try_extern :gr_recvmeta
180
- # try_extern :gr_sendmeta
181
- # try_extern :gr_sendmeta_buf
182
- # try_extern :gr_sendmeta_ref
183
- # try_extern :gr_sendmeta_args
184
- # try_extern :gr_closemeta
185
- # try_extern :gr_clearmeta
186
- # try_extern :gr_inputmeta
187
- # try_extern :gr_mergemeta
188
- # try_extern :gr_plotmeta
189
- # try_extern :gr_readmeta
190
- # try_extern :gr_switchmeta
191
- # try_extern :gr_registermeta
192
- # try_extern :gr_unregistermeta
193
- # try_extern :gr_meta_max_plotid
194
- # try_extern :gr_dumpmeta
195
- # try_extern :gr_dumpmeta_json
196
-
168
+ 'int nxq, int nyq, const double *xq, const double *yq, double *zq, int method, double extrapval)'
197
169
  try_extern 'const char *gr_version(void)'
198
170
  try_extern 'void gr_shade(int, double *, double *, int, int, double *, int, int, int *)'
199
171
  try_extern 'void gr_shadepoints(int, double *, double *, int, int, int)'
@@ -202,10 +174,23 @@ module GR
202
174
  # try_extern 'int gr_findboundary(int, double *, double *, double, double (*)(double, double), int, int *)'
203
175
  try_extern 'void gr_setresamplemethod(unsigned int flag)'
204
176
  try_extern 'void gr_inqresamplemethod(unsigned int *flag)'
205
- try_extern 'void gr_path(int, double *, double *, char *)'
177
+ try_extern 'void gr_path(int, double *, double *, const char *)'
206
178
  try_extern 'void gr_setborderwidth(double)'
207
179
  try_extern 'void gr_inqborderwidth(double *)'
208
180
  try_extern 'void gr_setbordercolorind(int)'
209
181
  try_extern 'void gr_inqbordercolorind(int *)'
182
+ try_extern 'void gr_setprojectiontype(int)'
183
+ try_extern 'void gr_inqprojectiontype(int *)'
184
+ try_extern 'void gr_setperspectiveprojection(double, double, double)'
185
+ try_extern 'void gr_inqperspectiveprojection(double *, double *, double *)'
186
+ try_extern 'void gr_settransformationparameters(double, double, double, ' \
187
+ 'double, double, double, double, double, double)'
188
+ try_extern 'void gr_inqtransformationparameters(double *, double *, double *, ' \
189
+ 'double *, double *, double *, double *, double *, double *);'
190
+ try_extern 'void gr_setorthographicprojection(double, double, double, double, double, double)'
191
+ try_extern 'void gr_inqorthographicprojection(double *, double *, double *, double *, double *, double *)'
192
+ try_extern 'void gr_camerainteraction(double, double, double, double)'
193
+ try_extern 'void gr_setwindow3d(double, double, double, double, double, double)'
194
+ try_extern 'void gr_inqwindow3d(double *, double *, double *, double *, double *, double *)'
210
195
  end
211
196
  end
@@ -4,6 +4,7 @@ require 'gr'
4
4
  autoload :GR3, 'gr3'
5
5
 
6
6
  # FIXME: Plot should not depend on Numo::Narrray unless the GR3 module is required.
7
+ # Note: The Plot class has a linspace function that is independent of Numo..
7
8
  require 'numo/narray'
8
9
 
9
10
  module GR
@@ -35,9 +36,9 @@ module GR
35
36
 
36
37
  # Keyword options conform to GR.jl.
37
38
  KW_ARGS = %i[accelerate algorithm alpha backgroundcolor barwidth baseline
38
- clabels color colormap figsize isovalue labels levels location
39
- nbins rotation size tilt title where xflip xform xlabel xlim
40
- xlog yflip ylabel ylim ylog zflip zlabel zlim zlog clim
39
+ clabels color colormap figsize isovalue label labels levels
40
+ location nbins rotation size tilt title where xflip xform xlabel
41
+ xlim xlog yflip ylabel ylim ylog zflip zlabel zlim zlog clim
41
42
  subplot].freeze
42
43
 
43
44
  @@last_plot = nil
@@ -51,8 +52,12 @@ module GR
51
52
  else
52
53
  {}
53
54
  end
55
+ # Check keyword options.
56
+ @kvs.each_key do |k|
57
+ warn "Unknown keyword: #{k}" unless KW_ARGS.include? k
58
+ end
54
59
 
55
- # label is a original keyword arg which GR.jl does not have.
60
+ # label(singular form) is a original keyword arg which GR.jl does not have.
56
61
  @kvs[:labels] = [@kvs[:label]] if @kvs[:label] && @kvs[:labels].nil?
57
62
 
58
63
  @args = plot_args(args) # method name is the same as Julia/Python
@@ -165,7 +170,7 @@ module GR
165
170
  scale |= GR::OPTION_FLIP_Y if kvs[:yflip]
166
171
  scale |= GR::OPTION_FLIP_Z if kvs[:zflip]
167
172
  end
168
- if kvs.key?(:panzoom)
173
+ if kvs.has_key?(:panzoom)
169
174
  xmin, xmax, ymin, ymax = GR.panzoom(*kvs[:panzoom])
170
175
  kvs[:xrange] = [xmin, xmax]
171
176
  kvs[:yrange] = [ymin, ymax]
@@ -182,8 +187,8 @@ module GR
182
187
 
183
188
  xmin, xmax = kvs[:xrange]
184
189
  if (scale & GR::OPTION_X_LOG) == 0
185
- xmin, xmax = GR.adjustlimits(xmin, xmax) unless kvs.key?(:xlim) || kvs.key?(:panzoom)
186
- if kvs.key?(:xticks)
190
+ xmin, xmax = GR.adjustlimits(xmin, xmax) unless kvs.has_key?(:xlim) || kvs.has_key?(:panzoom)
191
+ if kvs.has_key?(:xticks)
187
192
  xtick, majorx = kvs[:xticks]
188
193
  else
189
194
  majorx = major_count
@@ -200,12 +205,12 @@ module GR
200
205
  kvs[:xaxis] = xtick, xorg, majorx
201
206
 
202
207
  ymin, ymax = kvs[:yrange]
203
- if kind == :hist && !kvs.key?(:ylim)
208
+ if kind == :hist && !kvs.has_key?(:ylim)
204
209
  ymin = (scale & GR::OPTION_Y_LOG) == 0 ? 0 : 1
205
210
  end
206
211
  if (scale & GR::OPTION_Y_LOG) == 0
207
- ymin, ymax = GR.adjustlimits(ymin, ymax) unless kvs.key?(:ylim) || kvs.key?(:panzoom)
208
- if kvs.key?(:yticks)
212
+ ymin, ymax = GR.adjustlimits(ymin, ymax) unless kvs.has_key?(:ylim) || kvs.has_key?(:panzoom)
213
+ if kvs.has_key?(:yticks)
209
214
  ytick, majory = kvs[:yticks]
210
215
  else
211
216
  majory = major_count
@@ -224,8 +229,8 @@ module GR
224
229
  if %i[wireframe surface plot3 scatter3 trisurf volume].include?(kind)
225
230
  zmin, zmax = kvs[:zrange]
226
231
  if (scale & GR::OPTION_Z_LOG) == 0
227
- zmin, zmax = GR.adjustlimits(zmin, zmax) if kvs.key?(:zlim)
228
- if kvs.key?(:zticks)
232
+ zmin, zmax = GR.adjustlimits(zmin, zmax) if kvs.has_key?(:zlim)
233
+ if kvs.has_key?(:zticks)
229
234
  ztick, majorz = kvs[:zticks]
230
235
  else
231
236
  majorz = major_count
@@ -288,8 +293,8 @@ module GR
288
293
  else
289
294
  drawgrid && GR.grid(xtick, ytick, 0, 0, majorx, majory)
290
295
  end
291
- if kvs.key?(:xticklabels) || kvs.key?(:yticklabels)
292
- fx = if kvs.key?(:xticklabels)
296
+ if kvs.has_key?(:xticklabels) || kvs.has_key?(:yticklabels)
297
+ fx = if kvs.has_key?(:xticklabels)
293
298
  GRCommons::Fiddley::Function.new(
294
299
  :void, %i[double double string double]
295
300
  ) do |x, y, _svalue, value|
@@ -303,7 +308,7 @@ module GR
303
308
  GR.textext(x, y, value.to_s)
304
309
  end
305
310
  end
306
- fy = if kvs.key?(:yticklabels)
311
+ fy = if kvs.has_key?(:yticklabels)
307
312
  GRCommons::Fiddley::Function.new(
308
313
  :void, %i[double double string double]
309
314
  ) do |x, y, _svalue, value|
@@ -324,7 +329,7 @@ module GR
324
329
  GR.axes(xtick, ytick, xorg[1], yorg[1], -majorx, -majory, -ticksize)
325
330
  end
326
331
 
327
- if kvs.key?(:title)
332
+ if kvs.has_key?(:title)
328
333
  GR.savestate
329
334
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
330
335
  text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
@@ -336,13 +341,13 @@ module GR
336
341
  zlabel = kvs[:zlabel] || ''
337
342
  GR.titles3d(xlabel, ylabel, zlabel)
338
343
  else
339
- if kvs.key?(:xlabel)
344
+ if kvs.has_key?(:xlabel)
340
345
  GR.savestate
341
346
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_BOTTOM)
342
347
  text(0.5 * (viewport[0] + viewport[1]), vp[2] + 0.5 * charheight, kvs[:xlabel])
343
348
  GR.restorestate
344
349
  end
345
- if kvs.key?(:ylabel)
350
+ if kvs.has_key?(:ylabel)
346
351
  GR.savestate
347
352
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
348
353
  GR.setcharup(-1, 0)
@@ -380,13 +385,13 @@ module GR
380
385
  GR.drawarc(-r, r, -r, r, 0, 359)
381
386
  end
382
387
  end
383
- linspace(0, 315, 8).each do |alpha|
388
+ 0.step(by: 45, to: 315) do |alpha|
384
389
  sinf = Math.sin(alpha * Math::PI / 180)
385
390
  cosf = Math.cos(alpha * Math::PI / 180)
386
391
  GR.polyline([cosf, 0], [sinf, 0])
387
392
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_HALF)
388
393
  x, y = GR.wctondc(1.1 * cosf, 1.1 * sinf)
389
- GR.textext(x, y, "%<alpha>g\xb0")
394
+ GR.textext(x, y, "#{alpha}^o")
390
395
  end
391
396
  GR.restorestate
392
397
  end
@@ -409,7 +414,7 @@ module GR
409
414
 
410
415
  def plot_img(img)
411
416
  viewport = kvs[:vp].clone
412
- viewport[3] -= 0.05 if kvs.key?(:title)
417
+ viewport[3] -= 0.05 if kvs.has_key?(:title)
413
418
  vp = kvs[:vp]
414
419
 
415
420
  if img.is_a? String
@@ -437,12 +442,12 @@ module GR
437
442
 
438
443
  GR.selntran(0)
439
444
  GR.setscale(0)
440
- if kvs.key?(:xflip)
445
+ if kvs.has_key?(:xflip)
441
446
  tmp = xmax
442
447
  xmax = xmin
443
448
  xmin = tmp
444
449
  end
445
- if kvs.key?(:yflip)
450
+ if kvs.has_key?(:yflip)
446
451
  tmp = ymax
447
452
  ymax = ymin
448
453
  ymin = tmp
@@ -453,7 +458,7 @@ module GR
453
458
  GR.cellarray(xmin, xmax, ymin, ymax, width, height, data)
454
459
  end
455
460
 
456
- if kvs.key?(:title)
461
+ if kvs.has_key?(:title)
457
462
  GR.savestate
458
463
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
459
464
  text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
@@ -508,9 +513,9 @@ module GR
508
513
  viewport = kvs[:viewport]
509
514
  zmin, zmax = kvs[:zrange]
510
515
  mask = (GR::OPTION_Z_LOG | GR::OPTION_FLIP_Y | GR::OPTION_FLIP_Z)
511
- options = if kvs.key?(:zflip)
516
+ options = if kvs.has_key?(:zflip)
512
517
  (GR.inqscale | GR::OPTION_FLIP_Y)
513
- elsif kvs.key?(:yflip)
518
+ elsif kvs.has_key?(:yflip)
514
519
  GR.inqscale & ~GR::OPTION_FLIP_Y
515
520
  else
516
521
  GR.inqscale
@@ -566,7 +571,7 @@ module GR
566
571
  end
567
572
  end
568
573
 
569
- if kvs.key?(:colormap)
574
+ if kvs.has_key?(:colormap)
570
575
  GR.setcolormap(kvs[:colormap])
571
576
  else
572
577
  GR.setcolormap(GR::COLORMAP_VIRIDIS)
@@ -577,7 +582,7 @@ module GR
577
582
  # FIXME
578
583
  spec ||= ''
579
584
  GR.savestate
580
- GR.settransparency(kvs[:alpha]) if kvs.key?(:alpha)
585
+ GR.settransparency(kvs[:alpha]) if kvs.has_key?(:alpha)
581
586
 
582
587
  case kind
583
588
 
@@ -851,9 +856,9 @@ module GR
851
856
  GR.restorestate
852
857
  end
853
858
 
854
- draw_legend if %i[line step scatter stem].include?(kind) && kvs.key?(:labels)
859
+ draw_legend if %i[line step scatter stem].include?(kind) && kvs.has_key?(:labels)
855
860
 
856
- if kvs.key?(:update)
861
+ if kvs.has_key?(:update)
857
862
  GR.updatews
858
863
  # if GR.isinline()
859
864
  # restore_context()
@@ -1069,7 +1074,7 @@ module GR
1069
1074
  xmin, xmax = fix_minmax(xmin, xmax)
1070
1075
  ymin, ymax = fix_minmax(ymin, ymax)
1071
1076
  zmin, zmax = fix_minmax(zmin, zmax)
1072
- if kvs.key?(:xlim)
1077
+ if kvs.has_key?(:xlim)
1073
1078
  x0, x1 = kvs[:xlim]
1074
1079
  x0 ||= xmin
1075
1080
  x1 ||= xmax
@@ -1077,7 +1082,7 @@ module GR
1077
1082
  else
1078
1083
  kvs[:xrange] = [xmin, xmax]
1079
1084
  end
1080
- if kvs.key?(:ylim)
1085
+ if kvs.has_key?(:ylim)
1081
1086
  y0, y1 = kvs[:ylim]
1082
1087
  y0 ||= ymin
1083
1088
  y1 ||= ymax
@@ -1085,7 +1090,7 @@ module GR
1085
1090
  else
1086
1091
  kvs[:yrange] = [ymin, ymax]
1087
1092
  end
1088
- if kvs.key?(:zlim)
1093
+ if kvs.has_key?(:zlim)
1089
1094
  z0, z1 = kvs[:zlim]
1090
1095
  z0 ||= zmin
1091
1096
  z1 ||= zmax
@@ -1093,7 +1098,7 @@ module GR
1093
1098
  else
1094
1099
  kvs[:zrange] = [zmin, zmax]
1095
1100
  end
1096
- if kvs.key?(:clim)
1101
+ if kvs.has_key?(:clim)
1097
1102
  c0, c1 = kvs[:clim]
1098
1103
  c0 ||= cmin
1099
1104
  c1 ||= cmax
data/lib/gr3.rb CHANGED
@@ -52,26 +52,25 @@ module GR3
52
52
  class Error < StandardError; end
53
53
 
54
54
  class << self
55
- attr_reader :ffi_lib
55
+ attr_accessor :ffi_lib
56
56
  end
57
57
 
58
+ raise Error, 'Please set env variable GRDIR' unless ENV['GRDIR']
59
+
58
60
  # Platforms | path
59
61
  # Windows | bin/libGR3.dll
60
62
  # MacOSX | lib/libGR3.so (NOT .dylib)
61
63
  # Ubuntu | lib/libGR3.so
62
- raise Error, 'Please set env variable GRDIR' unless ENV['GRDIR']
63
-
64
- # Set the font path
65
- ENV['GKS_FONTPATH'] ||= ENV['GRDIR']
66
- # change the default encoding to UTF-8
67
- ENV['GKS_ENCODING'] ||= 'utf8'
68
64
  if Object.const_defined?(:RubyInstaller)
69
- @ffi_lib = File.expand_path('bin/libGR3.dll', ENV['GRDIR'])
70
- RubyInstaller::Runtime.add_dll_directory(File.dirname(@ffi_lib))
65
+ self.ffi_lib = File.expand_path('bin/libGR3.dll', ENV['GRDIR'])
66
+ RubyInstaller::Runtime.add_dll_directory(File.dirname(ffi_lib))
71
67
  else
72
- @ffi_lib = File.expand_path('lib/libGR3.so', ENV['GRDIR'])
68
+ self.ffi_lib = File.expand_path('lib/libGR3.so', ENV['GRDIR'])
73
69
  end
74
70
 
71
+ # change the default encoding to UTF-8
72
+ ENV['GKS_ENCODING'] ||= 'utf8'
73
+
75
74
  require_relative 'gr_commons/gr_commons'
76
75
  require_relative 'gr3/version'
77
76
  require_relative 'gr3/ffi'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.0.12'
4
+ VERSION = '0.0.13'
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-01 00:00:00.000000000 Z
11
+ date: 2020-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: histogram
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: 12.3.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: 12.3.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: wavefile
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
125
  description: GR framework - the graphics library for visualisation - for Ruby
140
126
  email: 2xijok@gmail.com
141
127
  executables: []