gray_scott_gtk3 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50d93fc72f36cfab2aabfff3052cca7a883c0468a0e3c0bad1eae5388b631226
4
- data.tar.gz: d4db2736b6d9df5a90d0c8bdba039d1963119b4c19a9185f4b50de0fb9672b8e
3
+ metadata.gz: f1d2097bd2f581e81bd6b0dd71f30b84b27e95d7fc97fa3dfbb88b08e182681a
4
+ data.tar.gz: 5d97e06aec54b53863c1b64c9435fde1a087166c5d13d93778f6931f85106f98
5
5
  SHA512:
6
- metadata.gz: 946f28c50936f2760d78d434ca12a04a3caa43eac48337bb4dcc9c111bddea702fc917f9890cdee36082c8737b93fc497b655949cfefd6e6f0f4dba8abffb64b
7
- data.tar.gz: 56f9f746991c82f9d6d91b80da81db1b44b2376670a00be39dec7b720ec6ad81b2504eb5c8d3677c12a86bd04b467e90036e6f2df6cb35e15a73624424c3f4e1
6
+ metadata.gz: 3d95033c5ea8482b263e145e22dae974483846f186f9cba771a3a3aa4a6513bd2a222bb7dc207a53dc5b4596f30a2059fc9e10f13eeef5749c1c6b79a81fee87
7
+ data.tar.gz: 8f272262554650f1dbbfbe71067bd34cac48badbac81b6d0d9dffb2c89a88fbf9c514a1fd3423e4b71c89e4309d4907e16a74ef5116200682fccd50901a046e6
data/README.md CHANGED
@@ -10,11 +10,35 @@
10
10
 
11
11
  ## Installation
12
12
 
13
- $ gem install gray_scott_gtk3
13
+ $ gem install gray_scott_gtk3
14
14
 
15
15
  ## Usage
16
16
 
17
- $ grayscott 40 # msec
17
+ $ grayscott 40 # msec
18
+
19
+ $ grayscott 40 -w 256 -h 256 # size of model. display is fixed to 512 x 512 pixels.
20
+
21
+ ## Usage with terminal(example)
22
+
23
+ $ bundle install
24
+ $ bundle exec bin/console
25
+
26
+ ```ruby
27
+ GrayScottGtk3::Controller::MSEC = 50
28
+ c = GrayScottGtk3::Controller.new 'resources/', width:1024, height:1024
29
+
30
+ # custom feed / kill ratio
31
+ na = Numo::SFloat.new(1024,1).seq + 10 # avoid zero
32
+ na = na * Numo::SFloat.ones(1, 1024)
33
+ na = na / na.max
34
+ f = na * 0.05
35
+ k = na.transpose * 0.06 + 0.01
36
+ c.model.f = f
37
+ c.model.k = k
38
+ c.model.v.rand(0.0, 0.15)
39
+ c.color = 'green' # colorful is slow.
40
+ Gtk.main
41
+ ```
18
42
 
19
43
  ## Known issue
20
44
 
data/exe/grayscott CHANGED
@@ -26,6 +26,7 @@ module GrayScottGtk3
26
26
  def run(opt)
27
27
  xml_path = File.expand_path('../resources/', __dir__)
28
28
  Controller.new(xml_path, opt)
29
+ Gtk.main
29
30
  end
30
31
  end
31
32
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ['2xijok@gmail.com']
10
10
 
11
11
  spec.summary = 'Gray-Scott model.'
12
- spec.description = 'Reaction diffusion system (Gray-Scott model).'
12
+ spec.description = 'Reaction diffusion system (Gray-Scott model). screenshot: https://bit.ly/2rvKErd'
13
13
  spec.homepage = 'https://github.com/kojix2/Gray-Scott'
14
14
 
15
15
  # Specify which files should be added to the gem when it is released.
@@ -3,7 +3,7 @@ require_relative 'controller/aboutdialog'
3
3
  module GrayScottGtk3
4
4
  class Controller
5
5
  include ShortNumo
6
- attr_accessor :resource_dir, :height, :width, :model
6
+ attr_accessor :resource_dir, :height, :width, :model, :color
7
7
 
8
8
  def initialize(dir, height: 256, width: 256)
9
9
  @resource_dir = dir
@@ -16,7 +16,7 @@ module GrayScottGtk3
16
16
  builder = Gtk::Builder.new
17
17
  builder.add_from_file File.join(resource_dir, 'gray_scott.glade')
18
18
 
19
- %w[win gimage legend_image uv_combobox pen_density pen_radius].each do |s|
19
+ %w[win execute_button gimage legend_image uv_combobox pen_density pen_radius].each do |s|
20
20
  instance_variable_set('@' + s, builder.get_object(s))
21
21
  end
22
22
 
@@ -24,7 +24,6 @@ module GrayScottGtk3
24
24
 
25
25
  @win.show_all # window
26
26
  on_new_clicked
27
- Gtk.main
28
27
  end
29
28
 
30
29
  def show_about
@@ -68,9 +67,13 @@ module GrayScottGtk3
68
67
  end
69
68
  end
70
69
 
71
- def on_save_clicked
70
+ def stop
72
71
  @doing_now = false
72
+ @execute_button.active = false
73
+ end
73
74
 
75
+ def on_save_clicked
76
+ stop if doing_now?
74
77
  dialog = Gtk::FileChooserDialog.new(title: 'PNG画像を保存',
75
78
  action: :save,
76
79
  buttons: [%i[save accept], %i[cancel cancel]])
@@ -170,5 +173,23 @@ module GrayScottGtk3
170
173
  def doing_now?
171
174
  @doing_now
172
175
  end
176
+
177
+ private
178
+ def debug_p_u
179
+ p model.u
180
+ end
181
+
182
+ def debug_p_v
183
+ p model.v
184
+ end
185
+
186
+ def debug_p_f
187
+ p model.f
188
+ end
189
+
190
+ def debug_p_k
191
+ p model.k
192
+ end
193
+
173
194
  end
174
195
  end
@@ -34,6 +34,12 @@ module GrayScottGtk3
34
34
  dvdt = Dv * l_v + uvv - (f + k) * v
35
35
  u._ + (Dt * dudt)
36
36
  v._ + (Dt * dvdt)
37
+ immune_surveillance
38
+ end
39
+
40
+ def immune_surveillance
41
+ @u._.clip(0.00001, 1)
42
+ @v._.clip(0.00001, 1)
37
43
  end
38
44
  end
39
45
  end
@@ -1,3 +1,3 @@
1
1
  module GrayScottGtk3
2
- VERSION = '0.3.3'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -121,6 +121,56 @@
121
121
  </child>
122
122
  </object>
123
123
  </child>
124
+ <child>
125
+ <object class="GtkMenuItem">
126
+ <property name="visible">True</property>
127
+ <property name="can_focus">False</property>
128
+ <property name="label" translatable="yes">Debug</property>
129
+ <property name="use_underline">True</property>
130
+ <child type="submenu">
131
+ <object class="GtkMenu">
132
+ <property name="visible">True</property>
133
+ <property name="can_focus">False</property>
134
+ <child>
135
+ <object class="GtkMenuItem">
136
+ <property name="visible">True</property>
137
+ <property name="can_focus">False</property>
138
+ <property name="label" translatable="yes">p @u</property>
139
+ <property name="use_underline">True</property>
140
+ <signal name="activate" handler="debug_p_u" swapped="no"/>
141
+ </object>
142
+ </child>
143
+ <child>
144
+ <object class="GtkMenuItem">
145
+ <property name="visible">True</property>
146
+ <property name="can_focus">False</property>
147
+ <property name="label" translatable="yes">p @v</property>
148
+ <property name="use_underline">True</property>
149
+ <signal name="activate" handler="debug_p_v" swapped="no"/>
150
+ </object>
151
+ </child>
152
+ <child>
153
+ <object class="GtkMenuItem">
154
+ <property name="visible">True</property>
155
+ <property name="can_focus">False</property>
156
+ <property name="label" translatable="yes">p @f</property>
157
+ <property name="use_underline">True</property>
158
+ <signal name="activate" handler="debug_p_f" swapped="no"/>
159
+ </object>
160
+ </child>
161
+ <child>
162
+ <object class="GtkMenuItem">
163
+ <property name="visible">True</property>
164
+ <property name="can_focus">False</property>
165
+ <property name="label" translatable="yes">p @k</property>
166
+ <property name="use_underline">True</property>
167
+ <signal name="activate" handler="debug_p_k" swapped="no"/>
168
+ </object>
169
+ </child>
170
+ </object>
171
+ </child>
172
+ </object>
173
+ </child>
124
174
  </object>
125
175
  <packing>
126
176
  <property name="expand">False</property>
@@ -256,7 +306,7 @@
256
306
  </packing>
257
307
  </child>
258
308
  <child>
259
- <object class="GtkToggleButton" id="execute">
309
+ <object class="GtkToggleButton" id="execute_button">
260
310
  <property name="label">gtk-execute</property>
261
311
  <property name="visible">True</property>
262
312
  <property name="can_focus">True</property>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gray_scott_gtk3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2018-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numo-narray
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Reaction diffusion system (Gray-Scott model).
83
+ description: 'Reaction diffusion system (Gray-Scott model). screenshot: https://bit.ly/2rvKErd'
84
84
  email:
85
85
  - 2xijok@gmail.com
86
86
  executables: