ruby-gr 0.0.16 → 0.0.17

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: d1884c5391124334045320390f35efd167865a6f1f063e6b763228c707cad400
4
- data.tar.gz: '07929d47c8a49344fb625526b34f170b1fd0da2cfbddf538bef39f29ef122ec8'
3
+ metadata.gz: 668fdb6db9526bf6b55fb6b293aa776ec625b76a650be20852efcd2869f1c751
4
+ data.tar.gz: 3b3a7645021470b12840734506f2a466d32fdff111c0e7dd6762ccf9e374ee92
5
5
  SHA512:
6
- metadata.gz: 132db88979be43ca20834522630d5970442a3565b7b14d6dafb5d970b7706b39112f56b83ab223c804e129ec9fcc612812ee691fa181d0dcdf7a86643ab7ba4b
7
- data.tar.gz: 7bc7e311d1c22d81afada8611c1775b93a477c80d52b545c665975a8736a4fdb25dfcbde2c44604eb616c8018ab918148ba5b280166d228fae6205aa98b31322
6
+ metadata.gz: 982637afaeb9be0f9b7abb631e1554fd04a2082ec7b019cb55e4f8d4ec870634f734b1b28dda8177e784a593476e0f065a924bd362ba58a881210015a7ec2f4c
7
+ data.tar.gz: 5bd9205778607854747d7ab9e4c1165600792710a9c3df0452c3c306fceff7ab90d665ccb244aa4761c407f59df9c3f80413bf4663ff81643887966b87109e27
data/README.md CHANGED
@@ -49,7 +49,8 @@ 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. Start with [`fast_plot`](https://github.com/red-data-tools/GR.rb/blob/master/examples/fast_plots.rb).
52
+ Have a look in the [`examples`](https://github.com/red-data-tools/GR.rb/tree/master/examples) directory.
53
+ * [Example Gallery](https://github.com/red-data-tools/GR.rb/wiki/Example-gallery)
53
54
 
54
55
  ## Features
55
56
 
data/lib/gr.rb CHANGED
@@ -2,39 +2,39 @@
2
2
 
3
3
  # OverView of GR.rb
4
4
  #
5
- # +--------------------+ +--------------------+
6
- # | GR module | | GR3 module |
7
- # | +----------------+ | | +----------------+ |
8
- # | | GR::FFI | | | | GR3::FFI | |
9
- # | | + libGR.so | | | | + libGR3.so | |
10
- # | +----------------+ | | +----------------+ |
11
- # | | define_method | | | define_method |
12
- # | +----------------+ | | +----------------+ |
13
- # | | | GR::GRBase | | | | | GR3::GR3Base | |
14
- # | | v (Pri^ate) | | | | v (Pri^ate) | |
15
- # | +++--------------+ | | +++--------------+ |
16
- # | | Extend | | | Extend |
17
- # | v | | v +-------+ |
18
- # | +-----------+ | | | Check | |
19
- # | | GR::Plot | | | <--+ Error | |
20
- # | +-----------+ | | +-------+ |
21
- # +--------------------+ +----------+---------+
22
- # ^ ^
23
- # | +------------------+ |
24
- # Extend | | GRCommons module | | Extend
25
- # | | +--------------+ | |
26
- # | | | Fiddley | | |
27
- # | | +--------------+ | |
28
- # | | +--------------+ | |
29
- # +----+ CommonUtils +----+
30
- # | | +--------------+ | |
31
- # | | +--------------+ | |
32
- # +----+ Version +----+
33
- # | | +--------------+ |
34
- # | | +--------------+ |
35
- # +----+JupyterSupport| |
36
- # | +--------------+ |
37
- # +------------------+
5
+ # +--------------------+ +--------------------+
6
+ # | GR module | | GR3 module |
7
+ # | +----------------+ | | +----------------+ |
8
+ # | | GR::FFI | | | | GR3::FFI | |
9
+ # | | + libGR.so | | | | + libGR3.so | |
10
+ # | +----------------+ | | +----------------+ |
11
+ # | | define_method | | | define_method |
12
+ # | +----------------+ | | +----------------+ |
13
+ # | | | GR::GRBase | | | | | GR3::GR3Base | |
14
+ # | | v (Pri^ate) | | | | v (Pri^ate) | |
15
+ # | +++--------------+ | | +++--------------+ |
16
+ # | | Extend | | | Extend |
17
+ # | v | | v +-------+ |
18
+ # | +-----------+ | | | Check | |
19
+ # | | GR::Plot | | | <--+ Error | |
20
+ # | +-----------+ | | +-------+ |
21
+ # +--------------------+ +----------+---------+
22
+ # ^ ^
23
+ # | +------------------+ |
24
+ # Extend | | GRCommons module | | Extend
25
+ # | | +--------------+ | |
26
+ # | | | Fiddley | | |
27
+ # | | +--------------+ | |
28
+ # | | +--------------+ | |
29
+ # +----+ CommonUtils +----+
30
+ # | | +--------------+ | |
31
+ # | | +--------------+ | |
32
+ # +----+ Version +----+
33
+ # | | +--------------+ |
34
+ # | | +--------------+ |
35
+ # +----+JupyterSupport| |
36
+ # | +--------------+ |
37
+ # +------------------+
38
38
  #
39
39
  # (You can edit the above AA diagram with http://asciiflow.com/))
40
40
  #
@@ -239,6 +239,9 @@ module GR
239
239
  # @param dimx [Integer] X dimension of the color index array
240
240
  # @param dimy [Integer] Y dimension of the color index array
241
241
  # @param color [Array, NArray] Color index array
242
+ # The values for `x` and `y` are in world coordinates. `x` must contain
243
+ # `dimx` + 1 elements and `y` must contain `dimy` + 1 elements. The elements
244
+ # i and i+1 are respectively the edges of the i-th cell in X and Y direction.
242
245
  def nonuniformcellarray(x, y, dimx, dimy, color)
243
246
  raise ArgumentError unless x.length == dimx + 1 && y.length == dimy + 1
244
247
 
@@ -1798,31 +1801,32 @@ module GR
1798
1801
  end
1799
1802
  end
1800
1803
 
1801
- # Draw paths using given vertices and path codes.
1804
+ # Draw paths using the given vertices and path codes.
1802
1805
  # @param x [Array, NArray] A list containing the X coordinates
1803
1806
  # @param y [Array, NArray] A list containing the Y coordinates
1804
- # @param codes [String] Path codes
1807
+ # @param codes [String] A list containing the path codes
1805
1808
  # The following path codes are recognized:
1806
1809
  # * M, m
1807
- # * moveto x, y
1810
+ # * moveto x, y
1808
1811
  # * L, l
1809
- # * lineto x, y
1812
+ # * lineto x, y
1810
1813
  # * Q, q
1811
- # * quadratic Bézier x1, y1 x2, y2
1814
+ # * quadratic Bézier x1, x2 y1, y2
1812
1815
  # * C, c
1813
- # * cubic Bézier x1, y1 x2, y2 x3, y3
1814
- # * R, r
1815
- # * rectangle w, h
1816
+ # * cubic Bézier x1, x2, x3 y1, y2, y3
1816
1817
  # * A, a
1817
- # * arc w, h a1, a2
1818
+ # * arc rx, a1, reserved ry, a2, reserved
1818
1819
  # * Z
1819
- # * closepath -
1820
+ # * close path -
1820
1821
  # * s
1821
- # * stroke -
1822
+ # * stroke -
1823
+ # * s
1824
+ # * close path and stroke -
1822
1825
  # * f
1823
- # * fill -
1824
- # The values for `x` and `y` are in normalized device coordinates.
1825
- # The `codes` describe several patch primitives that can be used to create compound paths.
1826
+ # * close path and fill -
1827
+ # * F
1828
+ # * close path, fill and stroke -
1829
+ # See https://gr-framework.org/python-gr.html#gr.path for more details.
1826
1830
  def path(x, y, codes)
1827
1831
  n = equal_length(x, y)
1828
1832
  super(n, x, y, codes)
@@ -1968,22 +1972,41 @@ module GR
1968
1972
  end
1969
1973
  end
1970
1974
 
1971
- # This is an interface for REPL based languages to enable an easier way to
1972
- # rotate around an object.
1975
+ # Set the camera for orthographic or perspective projection.
1973
1976
  # The center of the 3d window is used as the focus point and the camera is
1974
- # positioned relative to it, using spherical coordinates. This function can
1975
- # therefore also be used if the user prefers spherical coordinates to setting
1976
- # the direct camera position, but with reduced functionality in comparison
1977
- # to gr.settransformationparameters, gr.setperspectiveprojection and
1978
- # gr.setorthographicprojection.
1979
- # @param phi [Numeric] phi angle of the spherical coordinates
1980
- # @param theta [Numeric] theta angle of the spherical coordinates
1977
+ # positioned relative to it, using camera distance, rotation and tilt similar
1978
+ # to gr_setspace. This function can be used if the user prefers spherical
1979
+ # coordinates to setting the camera position directly, but has reduced
1980
+ # functionality in comparison to GR.settransformationparameters,
1981
+ # GR.setperspectiveprojection and GR.setorthographicprojection.
1982
+ # @param phi [Numeric] azimuthal angle of the spherical coordinates
1983
+ # @param theta [Numeric] polar angle of the spherical coordinates
1981
1984
  # @param fov [Numeric] vertical field of view (0 or NaN for orthographic projection)
1982
- # @param radius [Numeric] distance between the camera and the focus point
1985
+ # @param camera_distance [Numeric] distance between the camera and the focus point
1983
1986
  # (0 or NaN for the radius of the object's smallest bounding sphere)
1984
- def transformationinterfaceforrepl(*)
1987
+ def setspace3d(*)
1988
+ super
1989
+ end
1990
+
1991
+ def text3d(*)
1985
1992
  super
1986
1993
  end
1994
+
1995
+ def inqtext3d(x, y, z, string, axis)
1996
+ inquiry [{ double: 16 }, { double: 16 }] do |tbx, tby|
1997
+ super(x, y, z, string, axis, tbx, tby)
1998
+ end
1999
+ end
2000
+
2001
+ def settextencoding(*)
2002
+ super
2003
+ end
2004
+
2005
+ def inqtextencoding
2006
+ inquiry_int do |encoding|
2007
+ super(encoding)
2008
+ end
2009
+ end
1987
2010
  end
1988
2011
 
1989
2012
  ASF_BUNDLED = 0
@@ -2202,6 +2225,9 @@ module GR
2202
2225
  XFORM_CUBIC = 4
2203
2226
  XFORM_EQUALIZED = 5
2204
2227
 
2228
+ ENCODING_LATIN1 = 300
2229
+ ENCODING_UTF8 = 301
2230
+
2205
2231
  UPSAMPLE_VERTICAL_DEFAULT = 0x00000000
2206
2232
  UPSAMPLE_HORIZONTAL_DEFAULT = 0x00000000
2207
2233
  DOWNSAMPLE_VERTICAL_DEFAULT = 0x00000000
data/lib/gr/ffi.rb CHANGED
@@ -63,6 +63,7 @@ module GR
63
63
  try_extern 'void gr_settextcolorind(int)'
64
64
  try_extern 'void gr_inqtextcolorind(int *)'
65
65
  try_extern 'void gr_setcharheight(double)'
66
+ try_extern 'void gr_inqcharheight(double *)'
66
67
  try_extern 'void gr_setcharup(double, double)'
67
68
  try_extern 'void gr_settextpath(int)'
68
69
  try_extern 'void gr_settextalign(int, int)'
@@ -196,6 +197,10 @@ module GR
196
197
  try_extern 'void gr_inqwindow3d(double *, double *, double *, double *, double *, double *)'
197
198
  try_extern 'void gr_setscalefactors3d(double, double, double)'
198
199
  try_extern 'void gr_inqscalefactors3d(double *, double *, double *)'
199
- try_extern 'void gr_transformationinterfaceforrepl(double, double, double, double)'
200
+ try_extern 'void gr_setspace3d(double, double, double, double)'
201
+ try_extern 'void gr_text3d(double, double, double, char *, int axis)'
202
+ try_extern 'void gr_inqtext3d(double, double, double, char *, int axis, double *, double *)'
203
+ try_extern 'void gr_settextencoding(int)'
204
+ try_extern 'void gr_inqtextencoding(int *)'
200
205
  end
201
206
  end
data/lib/gr/plot.rb CHANGED
@@ -421,7 +421,7 @@ module GR
421
421
  if img.is_a? String
422
422
  width, height, data = GR.readimage(img)
423
423
  else
424
- width, height = img.shape
424
+ height, width = img.shape
425
425
  cmin, cmax = kvs[:crange]
426
426
  data = img.map { |i| normalize_color(i, cmin, cmax) }
427
427
  data = data.map { |i| (1000 + i * 255).round }
@@ -488,7 +488,9 @@ module GR
488
488
  end
489
489
 
490
490
  GR.selntran(0)
491
- values = ((v - v.min) / (v.max - v.min) * (2 ^ 16 - 1)).round
491
+ v = Numo::DFloat.cast(v) if v.is_a? Array
492
+ values = ((v - v.min) / (v.max - v.min) * (2**16 - 1)).round
493
+ values = Numo::UInt16.cast(values)
492
494
  nx, ny, nz = v.shape
493
495
  isovalue = ((kvs[:isovalue] || 0.5) - v.min) / (v.max - v.min)
494
496
  rotation = ((kvs[:rotation] || 40) * Math::PI / 180.0)
@@ -497,7 +499,7 @@ module GR
497
499
  GR3.clear
498
500
  mesh = GR3.createisosurfacemesh(values, [2.0 / (nx - 1), 2.0 / (ny - 1), 2.0 / (nz - 1)],
499
501
  [-1, -1, -1],
500
- (isovalue * (2 ^ 16 - 1)).round)
502
+ (isovalue * (2**16 - 1)).round)
501
503
  color = kvs[:color] || [0.0, 0.5, 0.8]
502
504
  GR3.setbackgroundcolor(1, 1, 1, 0)
503
505
  GR3.drawmesh(mesh, 1, [0, 0, 0], [0, 0, 1], [0, 1, 0], color, [1, 1, 1])
data/lib/gr3.rb CHANGED
@@ -2,39 +2,39 @@
2
2
 
3
3
  # OverView of GR.rb
4
4
  #
5
- # +--------------------+ +--------------------+
6
- # | GR module | | GR3 module |
7
- # | +----------------+ | | +----------------+ |
8
- # | | GR::FFI | | | | GR3::FFI | |
9
- # | | + libGR.so | | | | + libGR3.so | |
10
- # | +----------------+ | | +----------------+ |
11
- # | | define_method | | | define_method |
12
- # | +----------------+ | | +----------------+ |
13
- # | | | GR::GRBase | | | | | GR3::GR3Base | |
14
- # | | v (Pri^ate) | | | | v (Pri^ate) | |
15
- # | +++--------------+ | | +++--------------+ |
16
- # | | Extend | | | Extend |
17
- # | v | | v +-------+ |
18
- # | +-----------+ | | | Check | |
19
- # | | GR::Plot | | | <--+ Error | |
20
- # | +-----------+ | | +-------+ |
21
- # +--------------------+ +----------+---------+
22
- # ^ ^
23
- # | +------------------+ |
24
- # Extend | | GRCommons module | | Extend
25
- # | | +--------------+ | |
26
- # | | | Fiddley | | |
27
- # | | +--------------+ | |
28
- # | | +--------------+ | |
29
- # +----+ CommonUtils +----+
30
- # | | +--------------+ | |
31
- # | | +--------------+ | |
32
- # +----+ Version +----+
33
- # | | +--------------+ |
34
- # | | +--------------+ |
35
- # +----+JupyterSupport| |
36
- # | +--------------+ |
37
- # +------------------+
5
+ # +--------------------+ +--------------------+
6
+ # | GR module | | GR3 module |
7
+ # | +----------------+ | | +----------------+ |
8
+ # | | GR::FFI | | | | GR3::FFI | |
9
+ # | | + libGR.so | | | | + libGR3.so | |
10
+ # | +----------------+ | | +----------------+ |
11
+ # | | define_method | | | define_method |
12
+ # | +----------------+ | | +----------------+ |
13
+ # | | | GR::GRBase | | | | | GR3::GR3Base | |
14
+ # | | v (Pri^ate) | | | | v (Pri^ate) | |
15
+ # | +++--------------+ | | +++--------------+ |
16
+ # | | Extend | | | Extend |
17
+ # | v | | v +-------+ |
18
+ # | +-----------+ | | | Check | |
19
+ # | | GR::Plot | | | <--+ Error | |
20
+ # | +-----------+ | | +-------+ |
21
+ # +--------------------+ +----------+---------+
22
+ # ^ ^
23
+ # | +------------------+ |
24
+ # Extend | | GRCommons module | | Extend
25
+ # | | +--------------+ | |
26
+ # | | | Fiddley | | |
27
+ # | | +--------------+ | |
28
+ # | | +--------------+ | |
29
+ # +----+ CommonUtils +----+
30
+ # | | +--------------+ | |
31
+ # | | +--------------+ | |
32
+ # +----+ Version +----+
33
+ # | | +--------------+ |
34
+ # | | +--------------+ |
35
+ # +----+JupyterSupport| |
36
+ # | +--------------+ |
37
+ # +------------------+
38
38
  #
39
39
  # (You can edit the above AA diagram with http://asciiflow.com/)
40
40
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.0.16'
4
+ VERSION = '0.0.17'
5
5
  end
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.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2020-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler