ruby-gr 0.0.14 → 0.0.19
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 +141 -13
- data/lib/gr.rb +172 -54
- data/lib/gr/ffi.rb +10 -1
- data/lib/gr/grbase.rb +2 -3
- data/lib/gr/plot.rb +160 -123
- data/lib/gr3.rb +51 -40
- data/lib/gr3/ffi.rb +11 -2
- data/lib/gr3/gr3base.rb +2 -3
- data/lib/gr_commons/define_methods.rb +2 -2
- data/lib/gr_commons/fiddley.rb +1 -1
- data/lib/gr_commons/gr_common_utils.rb +53 -27
- data/lib/gr_commons/version.rb +1 -1
- data/lib/grm.rb +45 -0
- data/lib/grm/ffi.rb +63 -0
- data/lib/grm/grmbase.rb +13 -0
- data/lib/grm/version.rb +5 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07da9fb7d76476cb7598eac022e5a1b5e4004af6e0bdd0e87d1acd817f36abc7
|
4
|
+
data.tar.gz: 87961c4df97b188a7c5fbd77a9e0ac993a6190ddc9e3fc2f9c30b2c7e88c19cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb5d8869e80d488a5b2076eb80125136f27f18b4e352066ba1c5260b343440b7474ace25d708464c827954c1f02f47c682e83eff0b3e0a47d0374b58bc74ad09
|
7
|
+
data.tar.gz: 677a4c8839974102a3d4ac618f41cd06b23e4c7d7d68f70110efb7f838c1689588fc00f8c462eabfe724c7fe7a639319bd83728d047901ddd9013bba3c3db029
|
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
@@ -6,9 +6,21 @@
|
|
6
6
|
[](https://gitter.im/red-data-tools/en)
|
7
7
|
[](https://rubydoc.info/gems/ruby-gr)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+

|
10
|
+

|
11
|
+

|
12
|
+

|
13
|
+

|
14
|
+

|
15
|
+

|
16
|
+

|
17
|
+

|
18
|
+

|
19
|
+

|
20
|
+

|
21
|
+

|
22
|
+

|
23
|
+

|
12
24
|
|
13
25
|
:bar_chart: [GR framework](https://github.com/sciapp/gr) - the graphics library for visualization - for Ruby
|
14
26
|
|
@@ -47,13 +59,118 @@ y = [0.3, 0.5, 0.4, 0.2, 0.6, 0.7]
|
|
47
59
|
GR.plot(x, y)
|
48
60
|
```
|
49
61
|
|
50
|
-
|
62
|
+
<p align="center">
|
63
|
+
<img src="https://user-images.githubusercontent.com/5798442/84570709-242ab880-adca-11ea-9099-3a6b3418bf19.png">
|
64
|
+
</p>
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
require 'gr/plot'
|
68
|
+
|
69
|
+
x = Numo::DFloat.linspace(0, 10, 101)
|
70
|
+
y1 = Numo::NMath.sin(x)
|
71
|
+
y2 = Numo::NMath.cos(x)
|
72
|
+
|
73
|
+
GR.plot(
|
74
|
+
[x, y1, 'bo'], [x, y2, 'g*'],
|
75
|
+
title: "Multiple plot example",
|
76
|
+
xlabel: "x",
|
77
|
+
ylabel: "y",
|
78
|
+
ylim: [-1.2, 1.2],
|
79
|
+
labels: ["sin(x)", "cos(x)"],
|
80
|
+
location: 11
|
81
|
+
)
|
82
|
+
```
|
83
|
+
|
84
|
+
Save to PNG file.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
GR.savefig("figure.png")
|
88
|
+
```
|
89
|
+
|
90
|
+
## Features
|
91
|
+
|
92
|
+
There are two layers to the GR.rb API.
|
93
|
+
|
94
|
+
#### GR::Plot - A simple, matlab-style API.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
require 'gr/plot'
|
98
|
+
GR.plot(x, y)
|
99
|
+
```
|
100
|
+
|
101
|
+
List of vailable functions. See [GR.rb Wiki](https://github.com/red-data-tools/GR.rb/wiki) for details.
|
102
|
+
|
103
|
+
[`plot`](../../wiki/Plotting-functions#plot)
|
104
|
+
[`step`](../../wiki/Plotting-functions#step)
|
105
|
+
[`plot3`](../../wiki/Plotting-functions#plot3)
|
106
|
+
[`polar`](../../wiki/Plotting-functions#polar)
|
107
|
+
[`scatter`](../../wiki/Plotting-functions#scatter)
|
108
|
+
[`scatter3`](../../wiki/Plotting-functions#scatter3)
|
109
|
+
[`stem`](../../wiki/Plotting-functions#stem)
|
110
|
+
[`barplot`](../../wiki/Plotting-functions#barplot)
|
111
|
+
[`histogram`](../../wiki/Plotting-functions#histogram)
|
112
|
+
[`polarhistogram`](../../wiki/Plotting-functions#polarhistogram)
|
113
|
+
[`hexbin`](../../wiki/Plotting-functions#hexbin)
|
114
|
+
[`contour`](../../wiki/Plotting-functions#contour)
|
115
|
+
[`contourf`](../../wiki/Plotting-functions#contourf)
|
116
|
+
[`tricont`](../../wiki/Plotting-functions#tricont)
|
117
|
+
[`surface`](../../wiki/Plotting-functions#surface)
|
118
|
+
[`trisurf`](../../wiki/Plotting-functions#trisurf)
|
119
|
+
[`wireframe`](../../wiki/Plotting-functions#wireframe)
|
120
|
+
[`volume`](../../wiki/Plotting-functions#volume)
|
121
|
+
[`heatmap`](../../wiki/Plotting-functions#heatmap)
|
122
|
+
[`polarheatmap`](../../wiki/Plotting-functions#polarheatmap)
|
123
|
+
[`shade`](../../wiki/Plotting-functions#shade)
|
124
|
+
[`imshow`](../../wiki/Plotting-functions#imshow)
|
125
|
+
[`isosurface`](../../wiki/Plotting-functions#isosurface)
|
126
|
+
|
127
|
+
#### GR - A module for calling native GR functions.
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
require 'gr'
|
51
131
|
|
52
|
-
|
132
|
+
# For example
|
133
|
+
GR.setviewport(0.1, 0.9, 0.1, 0.9)
|
134
|
+
GR.setwindow(0.0, 20.0, 0.0, 20.0)
|
135
|
+
```
|
136
|
+
|
137
|
+
#### GR3 - A module for calling native GR3 functions.
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
require 'gr3'
|
141
|
+
|
142
|
+
# For example
|
143
|
+
GR3.cameralookat(-3, 2, -2, 0, 0, 0, 0, 0, -1)
|
144
|
+
```
|
145
|
+
|
146
|
+
* GR.rb can be used in Jupyter Notebook.
|
147
|
+
|
148
|
+
## Documentation
|
149
|
+
|
150
|
+
- [GR.rb Wiki](https://github.com/red-data-tools/GR.rb/wiki)
|
151
|
+
- [GR Framework](https://gr-framework.org/)
|
152
|
+
- [GR.rb API Documentation](https://rubydoc.info/gems/ruby-gr)
|
53
153
|
|
54
154
|
## GR Installation
|
55
155
|
|
56
|
-
###
|
156
|
+
### Installing an official release (recommended)
|
157
|
+
|
158
|
+
Download the [latest release](https://github.com/sciapp/gr/releases).
|
159
|
+
|
160
|
+
Set environment variable GRDIR.
|
161
|
+
|
162
|
+
```sh
|
163
|
+
export GRDIR="your/path/to/gr"
|
164
|
+
```
|
165
|
+
|
166
|
+
* macOS Catalina and macOS Mojave: See the "How to open an app that hasn’t been notarized or is from an unidentified developer" section of [Safely open apps on your Mac](https://support.apple.com/en-us/HT202491) in the Apple documentation.
|
167
|
+
|
168
|
+
### Using your package manager
|
169
|
+
|
170
|
+
* The third party GR packages for Mac, Linux and Windows (for advanced users) are available.
|
171
|
+
* If you find problems, please report to the [issue](https://github.com/red-data-tools/GR.rb/issues).
|
172
|
+
|
173
|
+
#### Mac: Homebrew
|
57
174
|
|
58
175
|
```sh
|
59
176
|
brew install libgr
|
@@ -65,16 +182,27 @@ Set environment variable GRDIR.
|
|
65
182
|
export GRDIR=$(brew --prefix libgr)
|
66
183
|
```
|
67
184
|
|
68
|
-
|
185
|
+
#### Linux: APT Yum
|
69
186
|
|
70
|
-
|
187
|
+
[packages.red-data-tools.org](https://github.com/red-data-tools/packages.red-data-tools.org) provides `libgr-dev` and `libgr3-dev`.
|
71
188
|
|
72
|
-
|
189
|
+
#### Windows: MSYS2
|
73
190
|
|
74
|
-
|
75
|
-
|
76
|
-
|
191
|
+
If you are using Rubyinstaller, pacman will automatically install [mingw-w64-gr](https://packages.msys2.org/base/mingw-w64-gr) when the gem is installed.
|
192
|
+
|
193
|
+
## Backend for Charty
|
194
|
+
|
195
|
+
GR.rb will be the default backend for [Charty](https://github.com/red-data-tools/charty).
|
77
196
|
|
78
197
|
## Contributing
|
79
198
|
|
80
|
-
|
199
|
+
* Report bugs
|
200
|
+
* Fix bugs and submit pull requests
|
201
|
+
* Write, clarify, or fix documentation
|
202
|
+
* Suggest or add new features
|
203
|
+
* Create visualization library based on GR.rb
|
204
|
+
|
205
|
+
## Acknowledgements
|
206
|
+
|
207
|
+
We would like to thank Josef Heinen, the creator of [GR.jl](https://github.com/jheinen/GR.jl), Florian Rhiem, the creator of [python-gr](https://github.com/sciapp/python-gr), and [GR](https://github.com/sciapp/gr) developers.
|
208
|
+
|
data/lib/gr.rb
CHANGED
@@ -2,40 +2,46 @@
|
|
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
|
-
#
|
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
|
+
#
|
39
|
+
# (You can edit the above AA diagram with http://asciiflow.com/))
|
40
|
+
#
|
41
|
+
# Fiddley is Ruby-FFI compatible API layer for Fiddle.
|
37
42
|
#
|
38
43
|
# The GR module works without Numo::Narrray.
|
44
|
+
# GR3 and GR::Plot depends on numo-narray.
|
39
45
|
#
|
40
46
|
# This is a procedural interface to the GR plotting library,
|
41
47
|
# https://github.com/sciapp/gr
|
@@ -46,20 +52,24 @@ module GR
|
|
46
52
|
attr_accessor :ffi_lib
|
47
53
|
end
|
48
54
|
|
49
|
-
raise Error, 'Please set env variable GRDIR' unless ENV['GRDIR']
|
50
|
-
|
51
55
|
# Platforms | path
|
52
56
|
# Windows | bin/libgr.dll
|
53
57
|
# MacOSX | lib/libGR.so (NOT .dylib)
|
54
58
|
# Ubuntu | lib/libGR.so
|
55
59
|
if Object.const_defined?(:RubyInstaller)
|
60
|
+
ENV['GRDIR'] ||= [
|
61
|
+
RubyInstaller::Runtime.msys2_installation.msys_path,
|
62
|
+
RubyInstaller::Runtime.msys2_installation.mingwarch
|
63
|
+
].join(File::ALT_SEPARATOR)
|
56
64
|
self.ffi_lib = File.expand_path('bin/libgr.dll', ENV['GRDIR'])
|
57
65
|
RubyInstaller::Runtime.add_dll_directory(File.dirname(ffi_lib))
|
58
66
|
else
|
67
|
+
raise Error, 'Please set env variable GRDIR' unless ENV['GRDIR']
|
68
|
+
|
59
69
|
self.ffi_lib = File.expand_path('lib/libGR.so', ENV['GRDIR'])
|
60
70
|
end
|
61
71
|
|
62
|
-
# Change the default encoding to UTF-8
|
72
|
+
# Change the default encoding to UTF-8.
|
63
73
|
ENV['GKS_ENCODING'] ||= 'utf8'
|
64
74
|
|
65
75
|
require_relative 'gr_commons/gr_commons'
|
@@ -67,16 +77,19 @@ module GR
|
|
67
77
|
require_relative 'gr/ffi'
|
68
78
|
require_relative 'gr/grbase'
|
69
79
|
|
80
|
+
# `inquiry` methods etc. are defined here.
|
81
|
+
extend GRCommons::GRCommonUtils
|
82
|
+
|
83
|
+
# Support for Jupyter Notebook / Lab.
|
70
84
|
extend GRCommons::JupyterSupport
|
71
85
|
|
72
|
-
# `double` is the default type in GR
|
86
|
+
# `double` is the default type in GR.
|
73
87
|
# A Ruby array or NArray passed to GR method is automatically converted to
|
74
|
-
# a
|
88
|
+
# a Fiddley::MemoryPointer in the GRBase class.
|
75
89
|
extend GRBase
|
76
90
|
|
77
91
|
# Now you can see a lot of methods just calling super here.
|
78
|
-
#
|
79
|
-
# Yes. They are written to help the yard generate the documentation.
|
92
|
+
# They are written to help the yard generate the documentation.
|
80
93
|
class << self
|
81
94
|
def initgr(*)
|
82
95
|
super
|
@@ -230,6 +243,9 @@ module GR
|
|
230
243
|
# @param dimx [Integer] X dimension of the color index array
|
231
244
|
# @param dimy [Integer] Y dimension of the color index array
|
232
245
|
# @param color [Array, NArray] Color index array
|
246
|
+
# The values for `x` and `y` are in world coordinates. `x` must contain
|
247
|
+
# `dimx` + 1 elements and `y` must contain `dimy` + 1 elements. The elements
|
248
|
+
# i and i+1 are respectively the edges of the i-th cell in X and Y direction.
|
233
249
|
def nonuniformcellarray(x, y, dimx, dimy, color)
|
234
250
|
raise ArgumentError unless x.length == dimx + 1 && y.length == dimy + 1
|
235
251
|
|
@@ -529,6 +545,13 @@ module GR
|
|
529
545
|
super
|
530
546
|
end
|
531
547
|
|
548
|
+
# Gets the current text color index.
|
549
|
+
# This function gets the color of text output primitives.
|
550
|
+
# @return [Integer] color The text color index (COLOR < 1256)
|
551
|
+
def inqtextcolorind
|
552
|
+
inquiry_int { |pt| super(pt) }
|
553
|
+
end
|
554
|
+
|
532
555
|
# Set the current character height.
|
533
556
|
# @param height [Numeric] Text height value
|
534
557
|
# `setcharheight` defines the height of subsequent text output primitives. Text height
|
@@ -1399,12 +1422,14 @@ module GR
|
|
1399
1422
|
|
1400
1423
|
# @return [Integer]
|
1401
1424
|
def readimage(path)
|
1425
|
+
# Feel free to make a pull request if you catch a mistake
|
1426
|
+
# or you have an idea to improve it.
|
1402
1427
|
data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
|
1403
1428
|
w, h = inquiry [:int, :int] do |width, height|
|
1404
1429
|
# data is a pointer of a pointer
|
1405
1430
|
super(path, width, height, data.ref)
|
1406
1431
|
end
|
1407
|
-
d = data.to_str(w * h *
|
1432
|
+
d = data.to_str(w * h * Fiddle::SIZEOF_INT).unpack('L*') # UInt32
|
1408
1433
|
[w, h, d]
|
1409
1434
|
end
|
1410
1435
|
|
@@ -1560,6 +1585,26 @@ module GR
|
|
1560
1585
|
super
|
1561
1586
|
end
|
1562
1587
|
|
1588
|
+
def delaunay(x, y)
|
1589
|
+
# Feel free to make a pull request if you catch a mistake
|
1590
|
+
# or you have an idea to improve it.
|
1591
|
+
npoints = equal_length(x, y)
|
1592
|
+
triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
|
1593
|
+
dim = 3
|
1594
|
+
n_tri = inquiry_int do |ntri|
|
1595
|
+
super(npoints, x, y, ntri, triangles.ref)
|
1596
|
+
end
|
1597
|
+
if n_tri > 0
|
1598
|
+
tri = triangles.to_str(dim * n_tri * Fiddle::SIZEOF_INT).unpack('l*') # Int32
|
1599
|
+
# Ruby : 0-based indexing
|
1600
|
+
# Julia : 1-based indexing
|
1601
|
+
tri = tri.each_slice(dim).to_a
|
1602
|
+
[n_tri, tri]
|
1603
|
+
else
|
1604
|
+
0
|
1605
|
+
end
|
1606
|
+
end
|
1607
|
+
|
1563
1608
|
# Reduces the number of points of the x and y array.
|
1564
1609
|
def reducepoints(xd, yd, n)
|
1565
1610
|
nd = equal_length(xd, yd)
|
@@ -1760,31 +1805,32 @@ module GR
|
|
1760
1805
|
end
|
1761
1806
|
end
|
1762
1807
|
|
1763
|
-
# Draw paths using given vertices and path codes.
|
1808
|
+
# Draw paths using the given vertices and path codes.
|
1764
1809
|
# @param x [Array, NArray] A list containing the X coordinates
|
1765
1810
|
# @param y [Array, NArray] A list containing the Y coordinates
|
1766
|
-
# @param codes [String]
|
1811
|
+
# @param codes [String] A list containing the path codes
|
1767
1812
|
# The following path codes are recognized:
|
1768
1813
|
# * M, m
|
1769
|
-
# * moveto
|
1814
|
+
# * moveto x, y
|
1770
1815
|
# * L, l
|
1771
|
-
# * lineto
|
1816
|
+
# * lineto x, y
|
1772
1817
|
# * Q, q
|
1773
|
-
# * quadratic Bézier
|
1818
|
+
# * quadratic Bézier x1, x2 y1, y2
|
1774
1819
|
# * C, c
|
1775
|
-
# * cubic Bézier
|
1776
|
-
# * R, r
|
1777
|
-
# * rectangle w, h
|
1820
|
+
# * cubic Bézier x1, x2, x3 y1, y2, y3
|
1778
1821
|
# * A, a
|
1779
|
-
# * arc
|
1822
|
+
# * arc rx, a1, reserved ry, a2, reserved
|
1780
1823
|
# * Z
|
1781
|
-
# *
|
1824
|
+
# * close path -
|
1825
|
+
# * s
|
1826
|
+
# * stroke -
|
1782
1827
|
# * s
|
1783
|
-
# * stroke
|
1828
|
+
# * close path and stroke -
|
1784
1829
|
# * f
|
1785
|
-
# * fill
|
1786
|
-
#
|
1787
|
-
#
|
1830
|
+
# * close path and fill -
|
1831
|
+
# * F
|
1832
|
+
# * close path, fill and stroke -
|
1833
|
+
# See https://gr-framework.org/python-gr.html#gr.path for more details.
|
1788
1834
|
def path(x, y, codes)
|
1789
1835
|
n = equal_length(x, y)
|
1790
1836
|
super(n, x, y, codes)
|
@@ -1913,6 +1959,58 @@ module GR
|
|
1913
1959
|
super(*pts)
|
1914
1960
|
end
|
1915
1961
|
end
|
1962
|
+
|
1963
|
+
# Set the scale factor for each axis. A one means no scale.
|
1964
|
+
# All factor have to be != 0.
|
1965
|
+
# @param x_axis_scale [Numeric] factor for scaling the x-axis
|
1966
|
+
# @param y_axis_scale [Numeric] factor for scaling the y-axis
|
1967
|
+
# @param z_axis_scale [Numeric] factor for scaling the z-axis
|
1968
|
+
def setscalefactors3d(*)
|
1969
|
+
super
|
1970
|
+
end
|
1971
|
+
|
1972
|
+
# Returns the scale factors for each axis.
|
1973
|
+
def inqscalefactors3d
|
1974
|
+
inquiry %i[double double double] do |*opts|
|
1975
|
+
super(*opts)
|
1976
|
+
end
|
1977
|
+
end
|
1978
|
+
|
1979
|
+
# Set the camera for orthographic or perspective projection.
|
1980
|
+
# The center of the 3d window is used as the focus point and the camera is
|
1981
|
+
# positioned relative to it, using camera distance, rotation and tilt similar
|
1982
|
+
# to gr_setspace. This function can be used if the user prefers spherical
|
1983
|
+
# coordinates to setting the camera position directly, but has reduced
|
1984
|
+
# functionality in comparison to GR.settransformationparameters,
|
1985
|
+
# GR.setperspectiveprojection and GR.setorthographicprojection.
|
1986
|
+
# @param phi [Numeric] azimuthal angle of the spherical coordinates
|
1987
|
+
# @param theta [Numeric] polar angle of the spherical coordinates
|
1988
|
+
# @param fov [Numeric] vertical field of view (0 or NaN for orthographic projection)
|
1989
|
+
# @param camera_distance [Numeric] distance between the camera and the focus point
|
1990
|
+
# (0 or NaN for the radius of the object's smallest bounding sphere)
|
1991
|
+
def setspace3d(*)
|
1992
|
+
super
|
1993
|
+
end
|
1994
|
+
|
1995
|
+
def text3d(*)
|
1996
|
+
super
|
1997
|
+
end
|
1998
|
+
|
1999
|
+
def inqtext3d(x, y, z, string, axis)
|
2000
|
+
inquiry [{ double: 16 }, { double: 16 }] do |tbx, tby|
|
2001
|
+
super(x, y, z, string, axis, tbx, tby)
|
2002
|
+
end
|
2003
|
+
end
|
2004
|
+
|
2005
|
+
def settextencoding(*)
|
2006
|
+
super
|
2007
|
+
end
|
2008
|
+
|
2009
|
+
def inqtextencoding
|
2010
|
+
inquiry_int do |encoding|
|
2011
|
+
super(encoding)
|
2012
|
+
end
|
2013
|
+
end
|
1916
2014
|
end
|
1917
2015
|
|
1918
2016
|
ASF_BUNDLED = 0
|
@@ -2131,6 +2229,9 @@ module GR
|
|
2131
2229
|
XFORM_CUBIC = 4
|
2132
2230
|
XFORM_EQUALIZED = 5
|
2133
2231
|
|
2232
|
+
ENCODING_LATIN1 = 300
|
2233
|
+
ENCODING_UTF8 = 301
|
2234
|
+
|
2134
2235
|
UPSAMPLE_VERTICAL_DEFAULT = 0x00000000
|
2135
2236
|
UPSAMPLE_HORIZONTAL_DEFAULT = 0x00000000
|
2136
2237
|
DOWNSAMPLE_VERTICAL_DEFAULT = 0x00000000
|
@@ -2147,4 +2248,21 @@ module GR
|
|
2147
2248
|
UPSAMPLE_HORIZONTAL_LANCZOS = 0x00000300
|
2148
2249
|
DOWNSAMPLE_VERTICAL_LANCZOS = 0x00030000
|
2149
2250
|
DOWNSAMPLE_HORIZONTAL_LANCZOS = 0x03000000
|
2251
|
+
|
2252
|
+
RESAMPLE_DEFAULT =
|
2253
|
+
(UPSAMPLE_VERTICAL_DEFAULT | UPSAMPLE_HORIZONTAL_DEFAULT |
|
2254
|
+
DOWNSAMPLE_VERTICAL_DEFAULT | DOWNSAMPLE_HORIZONTAL_DEFAULT)
|
2255
|
+
RESAMPLE_NEAREST =
|
2256
|
+
(UPSAMPLE_VERTICAL_NEAREST | UPSAMPLE_HORIZONTAL_NEAREST |
|
2257
|
+
DOWNSAMPLE_VERTICAL_NEAREST | DOWNSAMPLE_HORIZONTAL_NEAREST)
|
2258
|
+
RESAMPLE_LINEAR =
|
2259
|
+
(UPSAMPLE_VERTICAL_LINEAR | UPSAMPLE_HORIZONTAL_LINEAR |
|
2260
|
+
DOWNSAMPLE_VERTICAL_LINEAR | DOWNSAMPLE_HORIZONTAL_LINEAR)
|
2261
|
+
RESAMPLE_LANCZOS =
|
2262
|
+
(UPSAMPLE_VERTICAL_LANCZOS | UPSAMPLE_HORIZONTAL_LANCZOS |
|
2263
|
+
DOWNSAMPLE_VERTICAL_LANCZOS | DOWNSAMPLE_HORIZONTAL_LANCZOS)
|
2264
|
+
|
2265
|
+
PROJECTION_DEFAULT = 0
|
2266
|
+
PROJECTION_ORTHOGRAPHIC = 1
|
2267
|
+
PROJECTION_PERSPECTIVE = 2
|
2150
2268
|
end
|