gray_scott_gtk3 0.5.4 → 0.5.8

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: 2d6144fd61b89a4f478d3551ed4648ce9fe10bba4b6c61b0dcb40aa596c21d82
4
- data.tar.gz: 8cb60d9a0a48f7abbaae085fc11e8d1347d39879108ca904d0d809b464dedef9
3
+ metadata.gz: 977bfb0ebc9dffd914937d8e21d1613d71a014d401ec0410d32409597782d810
4
+ data.tar.gz: ce741a4ec404192dd1a7548576a9cd177f034c441e5912a27ecbe0c359434f73
5
5
  SHA512:
6
- metadata.gz: '099e6543d57bdd095f6ff28ee74291dbca5ab089a07d7b304c9b91afe28583d2f71686fb66f97f8434c3e9b4ddeb5544890b6ac9b710944c8c3c04e0a24887ba'
7
- data.tar.gz: 629899205425c0d7caab3c62f4adeec2e6694d66fa33bd22e6674045c787c02ce40f065855785a42a1515a5803bbf687477843d18b53885036af920c5f54c1a7
6
+ metadata.gz: e400b79c6dd8cf90f0aac55bc13c5932f51d411720b85db205ab71dbc560860c51c17a9bdc32df8e65898c0eb63df00318d644b8af19b9a55ca4814a81746a8b
7
+ data.tar.gz: 366eadb5b58d84a6901ed9d1bb411b1cc2ffcaf39db18856701528b9ab83b7981d079bbaec202e7e787360b768e36d6c14210a55777e2c1fa8177a9892c972e1
@@ -0,0 +1,2 @@
1
+ github: kojix2
2
+ ko_fi: kojix2
@@ -0,0 +1,21 @@
1
+ name: test
2
+ on: [push, pull_request]
3
+ jobs:
4
+ build:
5
+ name: ${{ matrix.os }} Ruby ${{ matrix.ruby }}
6
+ runs-on: ${{ matrix.os }}-latest
7
+ strategy:
8
+ matrix:
9
+ os: [ 'ubuntu' ]
10
+ ruby: [ '2.6', '2.7', '3.0' ]
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: ${{ matrix.ruby }}
16
+ - run: |
17
+ sudo apt install -y xvfb libgtk-3-0
18
+ - run: |
19
+ bundle install
20
+ - run: |
21
+ xvfb-run bundle exec rake spec
data/.gitignore CHANGED
@@ -1,55 +1,7 @@
1
1
  *.gem
2
2
  *.rbc
3
3
  *.glade~
4
- /.config
5
4
  /coverage/
6
- /InstalledFiles
7
- /pkg/
8
- /spec/reports/
9
- /spec/examples.txt
10
- /test/tmp/
11
- /test/version_tmp/
12
5
  /tmp/
13
-
14
- # Used by dotenv library to load environment variables.
15
- # .env
16
-
17
- ## Specific to RubyMotion:
18
- .dat*
19
- .repl_history
20
- build/
21
- *.bridgesupport
22
- build-iPhoneOS/
23
- build-iPhoneSimulator/
24
-
25
- ## Specific to RubyMotion (use of CocoaPods):
26
- #
27
- # We recommend against adding the Pods directory to your .gitignore. However
28
- # you should judge for yourself, the pros and cons are mentioned at:
29
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
30
- #
31
- # vendor/Pods/
32
-
33
- ## Documentation cache and generated files:
34
- /.yardoc/
35
- /_yardoc/
36
- /doc/
37
- /rdoc/
38
-
39
- ## Environment normalization:
40
- /.bundle/
41
- /vendor/bundle
42
- /lib/bundler/man/
43
-
44
- # for a library or gem, you might want to ignore these files since the code is
45
- # intended to run in multiple environments; otherwise, check them in:
46
6
  Gemfile.lock
47
- # .ruby-version
48
- # .ruby-gemset
49
-
50
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
51
- .rvmrc
52
-
53
- # rspec
54
- /spec/reports/
55
7
  .rspec_status
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
- # Gray-Scott
1
+ # gray_scott_gtk3
2
2
 
3
- Ruby implementation of the Reaction diffusion system (Gray-Scott model).
3
+ [![Gem](https://img.shields.io/gem/v/gray_scott_gtk3)](https://rubygems.org/gems/gray_scott_gtk3)
4
+ [![test](https://github.com/kojix2/Gray-Scott/actions/workflows/ci.yml/badge.svg)](https://github.com/kojix2/Gray-Scott/actions/workflows/ci.yml)
5
+ [![DOI](https://zenodo.org/badge/158914232.svg)](https://zenodo.org/badge/latestdoi/158914232)
6
+
7
+ Ruby implementation of the [Reaction diffusion system](https://en.wikipedia.org/wiki/Reaction%E2%80%93diffusion_system) (Gray-Scott model).
4
8
 
5
9
  ![screenshot](https://raw.githubusercontent.com/kojix2/Gray-Scott/screenshot/screenshot/screenshot.gif)
6
10
 
@@ -10,6 +14,8 @@ Ruby implementation of the Reaction diffusion system (Gray-Scott model).
10
14
  gem install gray_scott_gtk3
11
15
  ```
12
16
 
17
+ Support GPGPU with [Cumo](https://github.com/sonots/cumo).
18
+
13
19
  ## Usage
14
20
 
15
21
  ```bash
@@ -31,7 +37,7 @@ NOTE : You can set the width and height of the model, but the width and height o
31
37
  ## Known issue
32
38
 
33
39
  Glib::Timeout.add(number_of_seconds)
34
- If processing can not be completed within the time, it will not be displayed.
40
+ If processing can not be completed within the time, it will not be displayed.
35
41
  In this case, you should increase the number of seconds.
36
42
 
37
43
  ## Contributing
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
data/exe/grayscott CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'optparse'
4
5
 
5
- opt = {}
6
+ opt = { width: 256, height: 256 }
6
7
  OptionParser.new do |op|
7
- op.on('-h val', '--height', 'height of the model') { |v| opt[:height] = v.to_i }
8
- op.on('-w val', '--width', 'width of the model') { |v| opt[:width] = v.to_i }
8
+ op.on('-h val', '--height', 'height of the model', Integer) { |v| opt[:height] = v }
9
+ op.on('-w val', '--width', 'width of the model', Integer) { |v| opt[:width] = v }
9
10
  op.on('-g', '--gpu', 'use GPU(Cumo)') { |v| opt[:gpu] = v }
10
11
  op.parse!(ARGV)
11
12
  end
@@ -19,7 +20,7 @@ module GrayScott
19
20
  class << self
20
21
  def run(opt)
21
22
  xml_path = File.expand_path('../resources/', __dir__)
22
- Controller.new(xml_path, opt)
23
+ Controller.new(xml_path, height: opt[:height], width: opt[:width])
23
24
  Gtk.main
24
25
  end
25
26
  end
@@ -1,6 +1,6 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'gray_scott/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/gray_scott/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'gray_scott_gtk3'
@@ -12,19 +12,17 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Reaction diffusion system (Gray-Scott model).'
13
13
  spec.homepage = 'https://github.com/kojix2/Gray-Scott'
14
14
 
15
- # Specify which files should be added to the gem when it is released.
16
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
15
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
16
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
17
  end
20
18
  spec.bindir = 'exe'
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.executables = ['grayscott']
22
20
  spec.require_paths = ['lib']
23
21
 
24
22
  spec.add_dependency 'gtk3'
25
23
  spec.add_dependency 'numo-narray'
26
24
 
27
- spec.add_development_dependency 'bundler', '~> 2.0'
28
- spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'bundler'
26
+ spec.add_development_dependency 'rake'
29
27
  spec.add_development_dependency 'rspec'
30
28
  end
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrayScott
2
4
  module Color
3
- include XumoShortHand
4
-
5
5
  def colorize(ar, color_type)
6
6
  case color_type
7
7
  when 'colorful'
@@ -37,11 +37,11 @@ module GrayScott
37
37
  def hsv2rgb(h)
38
38
  i = UInt8.cast(h * 6)
39
39
  f = (h * 6.0) - i
40
- p = UInt8.zeros *h.shape
40
+ p = UInt8.zeros(*h.shape)
41
41
  v = UInt8.new(*h.shape).fill 255
42
42
  q = (1.0 - f) * 256
43
43
  t = f * 256
44
- rgb = UInt8.zeros *h.shape, 3
44
+ rgb = UInt8.zeros(*h.shape, 3)
45
45
  t = UInt8.cast(t)
46
46
  i = uInt8_dstack([i, i, i])
47
47
  rgb[i.eq 0] = uInt8_dstack([v, t, p])[i.eq 0]
@@ -79,7 +79,7 @@ module GrayScott
79
79
 
80
80
  def grayscale(ar)
81
81
  d = ar * 255
82
- UInt8.dstack([d, d, d])
82
+ uInt8_dstack([d, d, d])
83
83
  end
84
84
 
85
85
  private
@@ -1,14 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrayScott
2
4
  class Controller
3
5
  class AboutDialog
4
6
  def initialize(resource_dir)
5
- @a = Gtk::AboutDialog.new
6
- @a.program_name = 'Gray-Scott'
7
- @a.logo = GdkPixbuf::Pixbuf.new(file: File.join(resource_dir, 'about_icon.png'))
8
- @a.authors = ['kojix2']
9
- @a.version = GrayScott::VERSION
10
- @a.run
11
- @a.destroy
7
+ Gtk::AboutDialog.new.tap do |d|
8
+ d.program_name = 'Gray-Scott'
9
+ d.comments = 'Reaction diffusion system'
10
+ d.logo = GdkPixbuf::Pixbuf.new(file: File.join(resource_dir, 'about_icon.png'))
11
+ d.copyright = 'Copyright (C) kojix2'
12
+ d.authors = ['kojix2']
13
+ d.version = GrayScott::VERSION
14
+ d.website = 'https://github.com/kojix2/gray_scott_gtk3'
15
+ d.website_label = 'Github kojix2/gray_scott_gtk3'
16
+ d.run
17
+ d.destroy
18
+ end
12
19
  end
13
20
  end
14
21
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'controller/aboutdialog'
2
4
 
3
5
  module GrayScott
4
6
  class Controller
5
7
  include Color
6
- include XumoShortHand
7
8
  attr_accessor :resource_dir, :height, :width, :model, :color
8
9
 
9
10
  def initialize(dir, height: 256, width: 256)
@@ -13,14 +14,14 @@ module GrayScott
13
14
  @model = Model.new(height: height, width: width)
14
15
  @show_u = false
15
16
  @color = 'colorful'
16
- @frames = 1
17
+ @frames = 5
17
18
  @msec = 40
18
19
 
19
20
  builder = Gtk::Builder.new
20
21
  builder.add_from_file File.join(resource_dir, 'gray_scott.glade')
21
22
 
22
23
  %w[win execute_button gimage legend_image uv_combobox pen_density pen_radius].each do |s|
23
- instance_variable_set('@' + s, builder.get_object(s))
24
+ instance_variable_set("@#{s}", builder.get_object(s))
24
25
  end
25
26
 
26
27
  builder.connect_signals { |handler| method(handler) }
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrayScott
2
4
  # Gray-Scott model
3
5
  class Model
4
- include XumoShortHand
5
-
6
6
  Dx = 0.01
7
7
 
8
8
  # Delta t is the change in time for each iteration
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrayScott
2
4
  module Utils
3
5
  module Math
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GrayScott
2
- VERSION = '0.5.4'.freeze
4
+ VERSION = '0.5.8'
3
5
  end
data/lib/gray_scott.rb CHANGED
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gtk3'
2
4
 
5
+ # Support for Cumo
3
6
  if Object.const_defined? :Cumo
4
7
  Xumo = Cumo
5
8
  else
@@ -7,13 +10,14 @@ else
7
10
  Xumo = Numo
8
11
  end
9
12
 
10
- module XumoShortHand
11
- class Xumo::SFloat
13
+ # Monkey patch
14
+ module Xumo
15
+ class SFloat
12
16
  alias _ inplace
13
17
  end
14
- SFloat = Xumo::SFloat
15
- UInt8 = Xumo::UInt8
16
18
  end
19
+ SFloat = Xumo::SFloat
20
+ UInt8 = Xumo::UInt8
17
21
 
18
22
  require 'gray_scott/model'
19
23
  require 'gray_scott/color'