shattered_machine 0.0.2 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG +40 -0
  4. data/Gemfile +1 -0
  5. data/README.md +14 -4
  6. data/lib/shattered_machine.rb +2 -1
  7. data/lib/shattered_machine/brush.rb +1 -1
  8. data/lib/shattered_machine/converter.rb +1 -1
  9. data/lib/shattered_machine/glitcher.rb +8 -0
  10. data/lib/shattered_machine/io.rb +4 -4
  11. data/lib/shattered_machine/pixel_sorter.rb +1 -1
  12. data/lib/shattered_machine/sampler.rb +5 -4
  13. data/lib/shattered_machine/slim.rb +1 -1
  14. data/lib/shattered_machine/transpose.rb +2 -2
  15. data/shattered_machine.gemspec +11 -2
  16. metadata +20 -35
  17. data/.yardoc/checksums +0 -14
  18. data/.yardoc/complete +0 -0
  19. data/.yardoc/object_types +0 -0
  20. data/.yardoc/objects/root.dat +0 -0
  21. data/.yardoc/proxy_types +0 -0
  22. data/doc/ShatteredMachine/RustyEngine.html +0 -122
  23. data/lib/rusty_engine/librusty_engine.dll +0 -0
  24. data/lib/rusty_engine/librusty_engine.dylib +0 -0
  25. data/lib/rusty_engine/librusty_engine.so +0 -0
  26. data/lib/rusty_engine/rusty_engine.rb +0 -43
  27. data/spec/brush_spec.rb +0 -25
  28. data/spec/change_byte_spec.rb +0 -25
  29. data/spec/converter_spec.rb +0 -23
  30. data/spec/defect_spec.rb +0 -25
  31. data/spec/exchange_spec.rb +0 -25
  32. data/spec/glitcher_spec.rb +0 -25
  33. data/spec/images/bar.PNG +0 -0
  34. data/spec/images/bar.jpeg +0 -0
  35. data/spec/images/foo.jpg +0 -0
  36. data/spec/images/foo.png +0 -0
  37. data/spec/images/fuzz.JPG +0 -0
  38. data/spec/images/pouet.JPEG +0 -0
  39. data/spec/io_spec.rb +0 -73
  40. data/spec/lib/rusty_engine_spec.rb +0 -19
  41. data/spec/pixel_sorter_spec.rb +0 -25
  42. data/spec/sampler_spec.rb +0 -37
  43. data/spec/slim_spec.rb +0 -25
  44. data/spec/spec_helper.rb +0 -28
  45. data/spec/transpose_spec.rb +0 -25
  46. data/spec/wrong_filter_spec.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 270e23322ce44e6a921c93d0b88dbeb982b4eb28b37a2f33ac3abe38b32e6dad
4
- data.tar.gz: 3b1804b2f89d4f930841858d90b45a9de764d864038cdcf8c6b82c26d98196e4
3
+ metadata.gz: d1af0eb48cdbdeed165f788af1db525ed3f788c0f2d71376d38f3f37180886b2
4
+ data.tar.gz: 1cdc7f160e8e187eb8f793df4467272d6062fa9189824f4560c6bc27944c1cfb
5
5
  SHA512:
6
- metadata.gz: 3c7af5d305304c1fff124c87e770a82bc9b1ca1851eb595e3d4ba413a7355117815a7310a9614dc118815d0751c172e14f3f07014713329c2008b8f0dcc07773
7
- data.tar.gz: 02c3e621bcb430b1dde66fb232af088f70a26a564d3d761db8a92c7a606f04f6aad16fceb5811ee0d74050e61aa8f960639168d23ca0f3c6887b71d7ee6f5a47
6
+ metadata.gz: e13ad0eaf2df4857bc23f71c2b133a72db20be76623709f57508a1b5fc0259286e3ce2faaa3fb69563a1201616e1112ba66de4e6f73d90b6dcc86754cfd2b836
7
+ data.tar.gz: 52d29279379feddf29b7964b51c3a70c838b472e1df1507646df36045e6a8723df4031fe2aa512a0727303dfa64800227c00522b765209e6efb454ef5b8127a2
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ Gemfile.lock
9
9
  coverage
10
10
  doc/file.README.html
11
11
  *.gem
12
+ .yardoc/
data/CHANGELOG ADDED
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.0.7] - 2021-06-06
10
+ ### Changed
11
+ - Privatise PNG_EXTENSIONS, JPG_EXTENSIONS and Paths in Io
12
+
13
+ ### Fixed
14
+ - Transpose algorithm
15
+ - Include missing required files in glitcher
16
+
17
+ ### Removed
18
+ - Spec files from the gem
19
+
20
+ ## [0.0.6] - 2021-05-28
21
+ ### Added
22
+ - Add Sampler in the main lib
23
+
24
+ ## [0.0.5] - 2021-05-28
25
+ ### Added
26
+ - Rusty Engine dependency in gemspec file
27
+
28
+ ## [0.0.4] - 2021-05-28
29
+ ### Added
30
+ - Acknowledgements section in README
31
+
32
+ ### Changed
33
+ - The following Sampler constant are not publically available anymore : FILTERS, SLIM_DIRECTION and BRUSH_DIRECTION
34
+
35
+ ### Fixed
36
+ - By default the Sampler now also run the Brush algorithm
37
+
38
+ ## [0.0.3] - 2021-05-26
39
+ ### Changed
40
+ - Replaces Rusty Engine library with the gem encapsulating those files
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'ffi'
4
4
  gem 'pnglitch'
5
+ gem 'rusty_engine_ffi', '~> 0.0.3'
5
6
 
6
7
  group :test do
7
8
  gem 'rspec'
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Shattered Machine
2
2
 
3
- The Shattered Machine is a gem that aim to create glitched png images easily.
3
+ The Shattered Machine is a gem that aim to create glitched png images easily.
4
4
 
5
+ * [Rubygems page](https://rubygems.org/gems/shattered_machine)
6
+ * [Documentation](https://www.rubydoc.info/gems/shattered_machine)
5
7
  ## Features
6
8
 
7
9
  - Converter : Convert a single jpg images or a directory full of jpg image into png
@@ -15,7 +17,7 @@ The Shattered Machine is a gem that aim to create glitched png images easily.
15
17
  ```ruby
16
18
  require 'shattered_machine'
17
19
 
18
- io = ShatteredMachine::Io.new( 'input_image.png', 'output_folder', 'output_filename')
20
+ io = ShatteredMachine::Io.new('input_image.png', 'output_folder', 'output_filename')
19
21
  ShatteredMachine::Glitcher.new('Slim', io).call
20
22
  ```
21
23
 
@@ -24,7 +26,7 @@ ShatteredMachine::Glitcher.new('Slim', io).call
24
26
  ```ruby
25
27
  require 'shattered_machine'
26
28
 
27
- io = ShatteredMachine::Io.new( 'input_image.png', 'output_folder', 'output_filename')
29
+ io = ShatteredMachine::Io.new('input_image.png', 'output_folder', 'output_filename')
28
30
  ShatteredMachine::Sampler.new(io).call
29
31
  ```
30
32
 
@@ -33,11 +35,13 @@ ShatteredMachine::Sampler.new(io).call
33
35
  ```ruby
34
36
  require 'shattered_machine'
35
37
 
36
- io = ShatteredMachine::Io.new( 'input_image.jpg', 'output_folder', 'output_filename')
38
+ io = ShatteredMachine::Io.new('input_image.jpg', 'output_folder', 'output_filename')
37
39
  ShatteredMachine::Converter.new(io).call
38
40
  ```
39
41
 
40
42
  ## Development
43
+ ### Install locally
44
+
41
45
  The Shattered Machine using two main libraries for glitching :
42
46
  - [pnglitch](https://github.com/ucnv/pnglitch)
43
47
  - [rusty engine](https://framagit.org/Radoteur/rusty_engine)
@@ -48,4 +52,10 @@ To install the needed dependencies you need to install the [Ruby language](https
48
52
  Then run `bundle install` to fetch the needed gems.
49
53
 
50
54
  ### Specs
55
+
51
56
  This project uses [Rspec](https://rspec.info/) for writting specs, to run them simply run `bundle rspec`
57
+
58
+ ## Acknowledgements
59
+
60
+ This gem is relying heavily on the [pnglitch gem](https://github.com/ucnv/pnglitch) and the [rusty engine gem](https://framagit.org/Radoteur/rusty_engine).
61
+ The png image used in the specs has been created with [Ronin](https://100r.co/site/ronin.html) while the jpg one is painting from Karl Wiener.
@@ -3,10 +3,11 @@
3
3
  require 'shattered_machine/converter'
4
4
  require 'shattered_machine/glitcher'
5
5
  require 'shattered_machine/io'
6
+ require 'shattered_machine/sampler'
6
7
 
7
8
  # main file for ShatteredMachine gem
8
9
  module ShatteredMachine
9
- VERSION = '0.0.2'
10
+ VERSION = '0.0.7'
10
11
 
11
12
  class << self
12
13
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../rusty_engine/rusty_engine'
3
+ require 'rusty_engine'
4
4
 
5
5
  module ShatteredMachine
6
6
  # Brush pixels of a given png image.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../rusty_engine/rusty_engine'
3
+ require 'rusty_engine'
4
4
 
5
5
  module ShatteredMachine
6
6
  # Convert jpg image in png image
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'brush'
4
+ require_relative 'change_byte'
5
+ require_relative 'defect'
6
+ require_relative 'exchange'
7
+ require_relative 'pixel_sorter'
8
+ require_relative 'slim'
9
+ require_relative 'transpose'
10
+ require_relative 'wrong_filter'
3
11
  module ShatteredMachine
4
12
  # Main class to call from glitching image.
5
13
  class Glitcher
@@ -6,10 +6,6 @@ module ShatteredMachine
6
6
  class Io
7
7
  attr_accessor :output_filename
8
8
 
9
- PNG_EXTENSIONS = ['.png', '.PNG'].freeze
10
- JPG_EXTENSIONS = ['.jpg', '.jpeg', '.JPG', '.JPEG'].freeze
11
- Paths = Struct.new(:input, :output)
12
-
13
9
  # @param input_path [string] input file or directory
14
10
  # @param output_folder [string] output directory
15
11
  # @param output_filename [string] output file name
@@ -39,6 +35,10 @@ module ShatteredMachine
39
35
 
40
36
  private
41
37
 
38
+ PNG_EXTENSIONS = ['.png', '.PNG'].freeze
39
+ JPG_EXTENSIONS = ['.jpg', '.jpeg', '.JPG', '.JPEG'].freeze
40
+ Paths = Struct.new(:input, :output)
41
+
42
42
  def single_image_io
43
43
  [Paths.new(@input_path, generate_output_filename)]
44
44
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../rusty_engine/rusty_engine'
3
+ require 'rusty_engine'
4
4
 
5
5
  module ShatteredMachine
6
6
  # Sort pixels of a given png image.
@@ -5,10 +5,7 @@ module ShatteredMachine
5
5
  # A simple weay ro run one, many or all glitch algotirhm on one specific image.
6
6
  # This create a quick overview of the effect of each algo for the given image.
7
7
  class Sampler
8
- FILTERS = %w[none sub up average paeth].freeze
9
- SLIM_DIRECTION = %w[up_to_down down_to_up left_to_right right_to_left].freeze
10
- BRUSH_DIRECTION = %w[vertical vertical_inverted horizontal horizontal_inverted].freeze
11
- ALL_ALGORITHMS = %w[exchange transpose wrong_filter slim brus change_byte defect].freeze
8
+ ALL_ALGORITHMS = %w[brush change_byte defect exchange slim transpose wrong_filter].freeze
12
9
 
13
10
  # @param io [ShatteredMachine::Io] Io containing paths for images to sample
14
11
  # @param options [Hash] options for specifying which
@@ -32,6 +29,10 @@ module ShatteredMachine
32
29
 
33
30
  private
34
31
 
32
+ FILTERS = %w[none sub up average paeth].freeze
33
+ SLIM_DIRECTION = %w[up_to_down down_to_up left_to_right right_to_left].freeze
34
+ BRUSH_DIRECTION = %w[vertical vertical_inverted horizontal horizontal_inverted].freeze
35
+
35
36
  def update_io(output_filename_appendix)
36
37
  @io.output_filename = "#{@base_output_filename}_#{output_filename_appendix}"
37
38
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../rusty_engine/rusty_engine'
3
+ require 'rusty_engine'
4
4
 
5
5
  module ShatteredMachine
6
6
  # Repeat pixels of a given png image.
@@ -47,11 +47,11 @@ module ShatteredMachine
47
47
  end
48
48
 
49
49
  def half_transpose(data, qis)
50
- data[0, qis] + data[qis * 2, qis] + data[qis * 1, qis] + data[qis * 3..]
50
+ data[0, qis] + data[qis * 2, qis] + data[qis * 1, qis] + data[qis * 3..-1]
51
51
  end
52
52
 
53
53
  def full_transpose(data, qis)
54
- data[qis * 2, qis] + data[0, qis] + data[qis * 3..] + data[qis * 1, qis]
54
+ data[qis * 2, qis] + data[0, qis] + data[qis * 3..-1] + data[qis * 1, qis]
55
55
  end
56
56
  end
57
57
  end
@@ -1,16 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
4
+
1
5
  Gem::Specification.new do |s|
2
6
  s.name = 'shattered_machine'
3
- s.version = '0.0.2'
7
+ s.version = '0.0.7'
8
+ s.required_ruby_version = '>= 2.0.0'
9
+ s.required_rubygems_version = '>= 1.8.11'
4
10
  s.summary = 'Shattered Machine core engine'
5
11
  s.description = 'Shattered Machine is an easy way to glitch PNG images using different algorithms'
6
12
  s.authors = ['Flo Girardo']
7
13
  s.email = 'florian@barbrousse.net'
8
- s.files = `git ls-files`.split($/)
14
+ s.files = `git ls-files`.split($RS).reject do |file|
15
+ file =~ %r{^spec/}
16
+ end
9
17
  s.test_files = ['spec']
10
18
  s.require_paths = ['lib']
11
19
  s.homepage =
12
20
  'https://framagit.org/Radoteur/shattered-machine'
13
21
  s.license = 'MIT'
22
+ s.add_dependency 'rusty_engine_ffi', '>=0.0.2'
14
23
  s.add_development_dependency('rspec', '~> 3')
15
24
  s.add_development_dependency('yard', '~> 0.9')
16
25
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shattered_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flo Girardo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-23 00:00:00.000000000 Z
11
+ date: 2021-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rusty_engine_ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -47,11 +61,7 @@ extra_rdoc_files: []
47
61
  files:
48
62
  - ".gitignore"
49
63
  - ".rspec"
50
- - ".yardoc/checksums"
51
- - ".yardoc/complete"
52
- - ".yardoc/object_types"
53
- - ".yardoc/objects/root.dat"
54
- - ".yardoc/proxy_types"
64
+ - CHANGELOG
55
65
  - Gemfile
56
66
  - LICENSE
57
67
  - README.md
@@ -65,7 +75,6 @@ files:
65
75
  - doc/ShatteredMachine/Io.html
66
76
  - doc/ShatteredMachine/Io/Paths.html
67
77
  - doc/ShatteredMachine/PixelSorter.html
68
- - doc/ShatteredMachine/RustyEngine.html
69
78
  - doc/ShatteredMachine/Sampler.html
70
79
  - doc/ShatteredMachine/Slim.html
71
80
  - doc/ShatteredMachine/Transpose.html
@@ -83,10 +92,6 @@ files:
83
92
  - doc/js/jquery.js
84
93
  - doc/method_list.html
85
94
  - doc/top-level-namespace.html
86
- - lib/rusty_engine/librusty_engine.dll
87
- - lib/rusty_engine/librusty_engine.dylib
88
- - lib/rusty_engine/librusty_engine.so
89
- - lib/rusty_engine/rusty_engine.rb
90
95
  - lib/shattered_machine.rb
91
96
  - lib/shattered_machine/brush.rb
92
97
  - lib/shattered_machine/change_byte.rb
@@ -101,26 +106,6 @@ files:
101
106
  - lib/shattered_machine/transpose.rb
102
107
  - lib/shattered_machine/wrong_filter.rb
103
108
  - shattered_machine.gemspec
104
- - spec/brush_spec.rb
105
- - spec/change_byte_spec.rb
106
- - spec/converter_spec.rb
107
- - spec/defect_spec.rb
108
- - spec/exchange_spec.rb
109
- - spec/glitcher_spec.rb
110
- - spec/images/bar.PNG
111
- - spec/images/bar.jpeg
112
- - spec/images/foo.jpg
113
- - spec/images/foo.png
114
- - spec/images/fuzz.JPG
115
- - spec/images/pouet.JPEG
116
- - spec/io_spec.rb
117
- - spec/lib/rusty_engine_spec.rb
118
- - spec/pixel_sorter_spec.rb
119
- - spec/sampler_spec.rb
120
- - spec/slim_spec.rb
121
- - spec/spec_helper.rb
122
- - spec/transpose_spec.rb
123
- - spec/wrong_filter_spec.rb
124
109
  homepage: https://framagit.org/Radoteur/shattered-machine
125
110
  licenses:
126
111
  - MIT
@@ -133,14 +118,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
118
  requirements:
134
119
  - - ">="
135
120
  - !ruby/object:Gem::Version
136
- version: '0'
121
+ version: 2.0.0
137
122
  required_rubygems_version: !ruby/object:Gem::Requirement
138
123
  requirements:
139
124
  - - ">="
140
125
  - !ruby/object:Gem::Version
141
- version: '0'
126
+ version: 1.8.11
142
127
  requirements: []
143
- rubygems_version: 3.1.4
128
+ rubygems_version: 3.2.18
144
129
  signing_key:
145
130
  specification_version: 4
146
131
  summary: Shattered Machine core engine
data/.yardoc/checksums DELETED
@@ -1,14 +0,0 @@
1
- lib/shattered_machine.rb e5d8db3b105d5d0409ff7211617ea36044986a0a
2
- lib/shattered_machine/io.rb 02fface2a883b962a3c27ffba497af8aad184993
3
- lib/shattered_machine/slim.rb 1f0def79e7f6631d6b9b239d5d11f512d761815f
4
- lib/shattered_machine/brush.rb d0c27748daffefd4b40ecee2feff395d1dd3a1da
5
- lib/shattered_machine/defect.rb b2402bad054d51847fd3b83d597014e8e97a2fe8
6
- lib/rusty_engine/rusty_engine.rb 530c6563814f0c230f14606e96468962d2ae88c3
7
- lib/shattered_machine/sampler.rb 51823b7678fd9da8868a2c6e847727b2d51d24b3
8
- lib/shattered_machine/exchange.rb d230bc77bb9dfc34ea89e55892a6a33ec028d4b6
9
- lib/shattered_machine/glitcher.rb 071744286d68720fe47d7dfae2e033fdcff1cf69
10
- lib/shattered_machine/converter.rb da5eeda73917386592612d0834a7c4d4467d5df2
11
- lib/shattered_machine/transpose.rb 412ae07a4bf92dd8ba7383bce7558b85ad369e6a
12
- lib/shattered_machine/change_byte.rb 445fc0f28fe02eaf83e711e1d616862128a86be4
13
- lib/shattered_machine/pixel_sorter.rb 8670ff9c56a769797654ebd41f358ce48cd72962
14
- lib/shattered_machine/wrong_filter.rb a71a6b72cd152d3106e266e4736369cff7fdb6b1
data/.yardoc/complete DELETED
File without changes
data/.yardoc/object_types DELETED
Binary file
Binary file
data/.yardoc/proxy_types DELETED
Binary file
@@ -1,122 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Module: ShatteredMachine::RustyEngine
8
-
9
- &mdash; Documentation by YARD 0.9.26
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "ShatteredMachine::RustyEngine";
19
- relpath = '../';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="../class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="../_index.html">Index (R)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../ShatteredMachine.html" title="ShatteredMachine (module)">ShatteredMachine</a></span></span>
41
- &raquo;
42
- <span class="title">RustyEngine</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="../class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Module: ShatteredMachine::RustyEngine
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
- <dl>
73
- <dt>Extended by:</dt>
74
- <dd>FFI::Library</dd>
75
- </dl>
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
- <dl>
85
- <dt>Defined in:</dt>
86
- <dd>lib/rusty_engine/rusty_engine.rb</dd>
87
- </dl>
88
-
89
- </div>
90
-
91
- <h2>Overview</h2><div class="docstring">
92
- <div class="discussion">
93
-
94
- <p>Add the following functions from the <a href="https://framagit.org/Radoteur/rusty_engine" target="_parent" title="Optional Rusty Engine">Optional Rusty Engine</a> using FFI : convert, brush, slim, sort.</p>
95
-
96
-
97
- </div>
98
- </div>
99
- <div class="tags">
100
-
101
-
102
- </div>
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
- </div>
113
-
114
- <div id="footer">
115
- Generated on Sun May 23 18:36:58 2021 by
116
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
117
- 0.9.26 (ruby-2.6.6).
118
- </div>
119
-
120
- </div>
121
- </body>
122
- </html>
Binary file
Binary file
Binary file
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ffi'
4
-
5
- module ShatteredMachine
6
- # Add the following functions from the {https://framagit.org/Radoteur/rusty_engine Optional Rusty Engine} using FFI :
7
- # convert, brush, slim, sort.
8
- module RustyEngine
9
- extend FFI::Library
10
- lib_name = "librusty_engine.#{FFI::Platform::LIBSUFFIX}"
11
- ffi_lib File.expand_path(lib_name, __dir__)
12
-
13
- # Params : input output
14
- attach_function :convert, %i[string string], :void, { blocking: true }
15
-
16
- # Params : input output proba min max direction
17
- # Directions : 1 -> horizontal
18
- # 2 -> vertical
19
- # 3 -> horizontal_inverted
20
- # 4 -> vertical_inverted
21
- attach_function :brush, %i[string string string string string string], :void, { blocking: true }
22
-
23
- # Params : input, output, proba, probability_area, direction, colors, color_with_proba
24
- # Directions : 1 -> up_to_down
25
- # 2 -> down_to_up
26
- # 3 -> left_to_right
27
- # 4 -> right_to_left
28
- attach_function :slim, %i[string string string string string string string], :void, { blocking: true }
29
-
30
- # Params : input, output, direction, smart_sorting, detection_type, min, max, multiple_range, min_2, max_2,
31
- # sorting_by
32
- # directions : 0 -> up_to_down
33
- # 1 -> down_to_up
34
- # 2 -> left_to_right
35
- # 3 -> right_to_left
36
- # detection_type : 0 -> hues
37
- # 1 -> colors
38
- # sorting_by : 0 -> hue
39
- # 1 -> saturation
40
- attach_function :sort, %i[string string string string string string string string string string string],
41
- :void, { blocking: true }
42
- end
43
- end
data/spec/brush_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Brush do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/brush.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'brush')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Brush.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'brush image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::ChangeByte do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/change_byte.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'change_byte')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::ChangeByte.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'change byte on image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Converter do
6
- describe '#call' do
7
- let(:converted_file) { 'spec/images/converted.png' }
8
- let(:input_file) { 'spec/images/foo.jpg' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'converted')
11
- end
12
- subject { ShatteredMachine::Converter.new(io).call }
13
-
14
- after do
15
- File.delete(converted_file) if File.exist?(converted_file)
16
- end
17
-
18
- it 'convert image' do
19
- subject
20
- expect(File.exist?(converted_file)).to be true
21
- end
22
- end
23
- end
data/spec/defect_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Defect do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/defect.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'defect')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Defect.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'defect image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Exchange do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/exchange.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'exchange')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Exchange.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'exchange image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Glitcher do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/glitch.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'glitch')
11
- end
12
- subject do
13
- ShatteredMachine::Glitcher.new('Slim', io).call
14
- end
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'slim image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
data/spec/images/bar.PNG DELETED
Binary file
data/spec/images/bar.jpeg DELETED
Binary file
data/spec/images/foo.jpg DELETED
Binary file
data/spec/images/foo.png DELETED
Binary file
data/spec/images/fuzz.JPG DELETED
Binary file
Binary file
data/spec/io_spec.rb DELETED
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Io do
6
- describe '#png_images' do
7
- subject do
8
- ShatteredMachine::Io.new(input_path, 'spec/images', output_filename).png_images
9
- end
10
-
11
- context 'input path is a directory' do
12
- let(:input_path) { 'spec/images' }
13
- let(:output_filename) { 'pif' }
14
-
15
- it 'find two png images' do
16
- expect(subject.count).to eq(2)
17
- expect(subject.first.input).to eq('spec/images/foo.png')
18
- expect(subject.first.output).to eq('spec/images/piffoo.png')
19
- end
20
- end
21
-
22
- context 'input path is an image' do
23
- context 'output path is available' do
24
- let(:input_path) { 'spec/images/foo.png' }
25
- let(:output_filename) { 'paf' }
26
-
27
- it 'find the correct png image' do
28
- expect(subject.count).to eq(1)
29
- expect(subject.first.input).to eq('spec/images/foo.png')
30
- expect(subject.first.output).to eq('spec/images/paf.png')
31
- end
32
- end
33
-
34
- context 'output path is not available' do
35
- let(:input_path) { 'spec/images/foo.png' }
36
- let(:output_filename) { 'foo' }
37
-
38
- it 'find the correct png image' do
39
- expect(subject.count).to eq(1)
40
- expect(subject.first.output).to match %r(spec/images/foo_(\d{8})_(\d{6}).png)
41
- end
42
- end
43
- end
44
- end
45
-
46
- describe '#jpg_images' do
47
- subject do
48
- ShatteredMachine::Io.new(input_path, 'spec/images', output_filename).jpg_images
49
- end
50
-
51
- context 'input path is a directory' do
52
- let(:input_path) { 'spec/images' }
53
- let(:output_filename) { 'pouf' }
54
-
55
- it 'find four jpg images' do
56
- expect(subject.count).to eq(4)
57
- expect(subject.first.input).to eq('spec/images/fuzz.JPG')
58
- expect(subject.first.output).to eq('spec/images/pouffuzz.png')
59
- end
60
- end
61
-
62
- context 'input path is an image' do
63
- let(:input_path) { 'spec/images/foo.jpg' }
64
- let(:output_filename) { 'pouet' }
65
-
66
- it 'find the correct jpg image' do
67
- expect(subject.count).to eq(1)
68
- expect(subject.first.input).to eq('spec/images/foo.jpg')
69
- expect(subject.first.output).to eq('spec/images/pouet.png')
70
- end
71
- end
72
- end
73
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::RustyEngine do
6
- describe '.convert' do
7
- let(:converted_file) { 'spec/images/converted.png' }
8
- subject { ShatteredMachine::RustyEngine.convert('spec/images/foo.jpg', converted_file) }
9
-
10
- after do
11
- File.delete(converted_file) if File.exist?(converted_file)
12
- end
13
-
14
- it 'convert image' do
15
- subject
16
- expect(File.exist?(converted_file)).to be true
17
- end
18
- end
19
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::PixelSorter do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/sorter.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'sorter')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::PixelSorter.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'sort image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
data/spec/sampler_spec.rb DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Sampler do
6
- describe '#call' do
7
- let(:created_files) do
8
- %w[sample_exchange_average.png sample_exchange_up.png sample_slim_up_to_down.png sample_transpose_sub.png
9
- sample_wrong_filter_paeth.png sample_exchange_none.png sample_slim_down_to_up.png sample_transpose_average.png
10
- sample_transpose_up.png sample_wrong_filter_sub.png sample_change_byte.png sample_exchange_paeth.png
11
- sample_slim_left_to_right.png sample_transpose_none.png sample_wrong_filter_average.png
12
- sample_wrong_filter_up.png sample_defect.png sample_exchange_sub.png sample_slim_right_to_left.png
13
- sample_transpose_paeth.png sample_wrong_filter_none.png]
14
- end
15
- let(:output_file) { 'spec/images/sample.png' }
16
- let(:input_file) { 'spec/images/foo.png' }
17
- let(:io) { ShatteredMachine::Io.new(input_file, 'spec/images', 'sample') }
18
- subject { ShatteredMachine::Sampler.new(io).call }
19
-
20
- def output_image_full_path(file)
21
- "spec/images/#{file}"
22
- end
23
-
24
- after do
25
- created_files.each do |file|
26
- File.delete(output_image_full_path(file)) if File.exist?(output_image_full_path(file))
27
- end
28
- end
29
-
30
- it 'call sampler' do
31
- subject
32
- created_files.each do |file|
33
- expect(File.exist?(output_image_full_path(file))).to be true
34
- end
35
- end
36
- end
37
- end
data/spec/slim_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Slim do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/slim.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'slim')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Slim.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'slim image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
data/spec/spec_helper.rb DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.expect_with :rspec do |expectations|
5
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
- end
7
-
8
- config.mock_with :rspec do |mocks|
9
- mocks.verify_partial_doubles = true
10
- end
11
-
12
- config.shared_context_metadata_behavior = :apply_to_host_groups
13
-
14
- $LOAD_PATH.unshift File.expand_path('..', __dir__)
15
- require 'lib/rusty_engine/rusty_engine'
16
- require 'lib/shattered_machine/converter'
17
- require 'lib/shattered_machine/brush'
18
- require 'lib/shattered_machine/change_byte'
19
- require 'lib/shattered_machine/defect'
20
- require 'lib/shattered_machine/exchange'
21
- require 'lib/shattered_machine/io'
22
- require 'lib/shattered_machine/glitcher'
23
- require 'lib/shattered_machine/pixel_sorter'
24
- require 'lib/shattered_machine/sampler'
25
- require 'lib/shattered_machine/slim'
26
- require 'lib/shattered_machine/transpose'
27
- require 'lib/shattered_machine/wrong_filter'
28
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::Transpose do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/transpose.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'transpose')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::Transpose.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'transpose image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ShatteredMachine::WrongFilter do
6
- describe '#call' do
7
- let(:output_file) { 'spec/images/wrong_filter.png' }
8
- let(:input_file) { 'spec/images/foo.png' }
9
- let(:io) do
10
- ShatteredMachine::Io.new(input_file, 'spec/images', 'wrong_filter')
11
- end
12
- let(:in_img) { io.png_images.first.input }
13
- let(:out_img) { io.png_images.first.output }
14
- subject { ShatteredMachine::WrongFilter.new.call(in_img, out_img) }
15
-
16
- after do
17
- File.delete(output_file) if File.exist?(output_file)
18
- end
19
-
20
- it 'wrong filter image' do
21
- subject
22
- expect(File.exist?(output_file)).to be true
23
- end
24
- end
25
- end