ruby-gr 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/gr.rb +84 -58
- data/lib/gr/ffi.rb +6 -1
- data/lib/gr/plot.rb +5 -3
- data/lib/gr3.rb +33 -33
- 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: 668fdb6db9526bf6b55fb6b293aa776ec625b76a650be20852efcd2869f1c751
|
4
|
+
data.tar.gz: 3b3a7645021470b12840734506f2a466d32fdff111c0e7dd6762ccf9e374ee92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
#
|
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
|
-
#
|
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]
|
1807
|
+
# @param codes [String] A list containing the path codes
|
1805
1808
|
# The following path codes are recognized:
|
1806
1809
|
# * M, m
|
1807
|
-
# * moveto
|
1810
|
+
# * moveto x, y
|
1808
1811
|
# * L, l
|
1809
|
-
# * lineto
|
1812
|
+
# * lineto x, y
|
1810
1813
|
# * Q, q
|
1811
|
-
# * quadratic Bézier
|
1814
|
+
# * quadratic Bézier x1, x2 y1, y2
|
1812
1815
|
# * C, c
|
1813
|
-
# * cubic Bézier
|
1814
|
-
# * R, r
|
1815
|
-
# * rectangle w, h
|
1816
|
+
# * cubic Bézier x1, x2, x3 y1, y2, y3
|
1816
1817
|
# * A, a
|
1817
|
-
# * arc
|
1818
|
+
# * arc rx, a1, reserved ry, a2, reserved
|
1818
1819
|
# * Z
|
1819
|
-
# *
|
1820
|
+
# * close path -
|
1820
1821
|
# * s
|
1821
|
-
# * stroke
|
1822
|
+
# * stroke -
|
1823
|
+
# * s
|
1824
|
+
# * close path and stroke -
|
1822
1825
|
# * f
|
1823
|
-
# * fill
|
1824
|
-
#
|
1825
|
-
#
|
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
|
-
#
|
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
|
1975
|
-
#
|
1976
|
-
# the
|
1977
|
-
# to
|
1978
|
-
#
|
1979
|
-
# @param phi [Numeric]
|
1980
|
-
# @param theta [Numeric]
|
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
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
#
|
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.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-
|
11
|
+
date: 2020-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|