shattered_machine 0.0.8 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{CHANGELOG → CHANGELOG.md} +24 -0
- data/README.md +18 -0
- data/doc/ShatteredMachine/Brush.html +2 -2
- data/doc/ShatteredMachine/ChangeByte.html +1 -1
- data/doc/ShatteredMachine/Converter.html +2 -2
- data/doc/ShatteredMachine/Defect.html +1 -1
- data/doc/ShatteredMachine/Exchange.html +1 -1
- data/doc/ShatteredMachine/Glitcher.html +13 -13
- data/doc/ShatteredMachine/Io/Paths.html +1 -187
- data/doc/ShatteredMachine/Io.html +23 -44
- data/doc/ShatteredMachine/PixelSorter.html +2 -2
- data/doc/ShatteredMachine/ProgressivePixelSorter.html +318 -0
- data/doc/ShatteredMachine/Sampler.html +14 -29
- data/doc/ShatteredMachine/Slim.html +3 -3
- data/doc/ShatteredMachine/Transpose.html +1 -1
- data/doc/ShatteredMachine/WrongFilter.html +1 -1
- data/doc/ShatteredMachine.html +5 -7
- data/doc/_index.html +5 -13
- data/doc/class_list.html +1 -1
- data/doc/index.html +50 -17
- data/doc/method_list.html +48 -48
- data/doc/top-level-namespace.html +1 -1
- data/lib/shattered_machine/pixel_sorter.rb +1 -1
- data/lib/shattered_machine/progressive_pixel_sorter.rb +66 -0
- data/lib/shattered_machine/sampler.rb +4 -5
- data/lib/shattered_machine/slim.rb +4 -2
- data/lib/shattered_machine.rb +2 -1
- data/shattered_machine.gemspec +4 -3
- metadata +24 -8
data/doc/index.html
CHANGED
@@ -61,6 +61,11 @@
|
|
61
61
|
|
62
62
|
<p>The Shattered Machine is a gem that aim to create glitched png images easily.</p>
|
63
63
|
|
64
|
+
<ul>
|
65
|
+
<li><a href="https://rubygems.org/gems/shattered_machine">Rubygems page</a></li>
|
66
|
+
<li><a href="https://www.rubydoc.info/gems/shattered_machine">Documentation</a></li>
|
67
|
+
</ul>
|
68
|
+
|
64
69
|
<h2 id="features">Features</h2>
|
65
70
|
|
66
71
|
<ul>
|
@@ -71,34 +76,44 @@
|
|
71
76
|
</ul>
|
72
77
|
|
73
78
|
<h2 id="usageexamples">Usage/Examples</h2>
|
74
|
-
<p>### Glitcher</p>
|
75
79
|
|
76
|
-
<
|
77
|
-
|
80
|
+
<h3 id="glitcher">Glitcher</h3>
|
81
|
+
|
82
|
+
<p>```ruby</p>
|
83
|
+
|
84
|
+
<p>require ‘shattered_machine’</p>
|
78
85
|
|
79
|
-
<p>io = ShatteredMachine::Io.new(
|
80
|
-
ShatteredMachine::Glitcher.new(‘Slim’, io).call
|
81
|
-
|
86
|
+
<p>io = ShatteredMachine::Io.new(‘input_image.png’, ‘output_folder’, ‘output_filename’)
|
87
|
+
ShatteredMachine::Glitcher.new(‘Slim’, io).call</p>
|
88
|
+
|
89
|
+
<p>```</p>
|
82
90
|
|
83
91
|
<h3 id="sampler">Sampler</h3>
|
84
92
|
|
85
|
-
<p>```ruby
|
86
|
-
|
93
|
+
<p>```ruby</p>
|
94
|
+
|
95
|
+
<p>require ‘shattered_machine’</p>
|
96
|
+
|
97
|
+
<p>io = ShatteredMachine::Io.new(‘input_image.png’, ‘output_folder’, ‘output_filename’)
|
98
|
+
ShatteredMachine::Sampler.new(io).call</p>
|
87
99
|
|
88
|
-
<p>
|
89
|
-
ShatteredMachine::Sampler.new(io).call
|
90
|
-
```</p>
|
100
|
+
<p>```</p>
|
91
101
|
|
92
102
|
<h3 id="converter">Converter</h3>
|
93
103
|
|
94
|
-
<p>```ruby
|
95
|
-
|
104
|
+
<p>```ruby</p>
|
105
|
+
|
106
|
+
<p>require ‘shattered_machine’</p>
|
107
|
+
|
108
|
+
<p>io = ShatteredMachine::Io.new(‘input_image.jpg’, ‘output_folder’, ‘output_filename’)
|
109
|
+
ShatteredMachine::Converter.new(io).call</p>
|
96
110
|
|
97
|
-
<p>
|
98
|
-
ShatteredMachine::Converter.new(io).call
|
99
|
-
```</p>
|
111
|
+
<p>```</p>
|
100
112
|
|
101
113
|
<h2 id="development">Development</h2>
|
114
|
+
|
115
|
+
<h3 id="install-locally">Install locally</h3>
|
116
|
+
|
102
117
|
<p>The Shattered Machine using two main libraries for glitching :
|
103
118
|
- <a href="https://github.com/ucnv/pnglitch">pnglitch</a>
|
104
119
|
- <a href="https://framagit.org/Radoteur/rusty_engine">rusty engine</a></p>
|
@@ -108,12 +123,30 @@ To install the needed dependencies you need to install the <a href="https://www.
|
|
108
123
|
|
109
124
|
<p>Then run <code>bundle install</code> to fetch the needed gems.</p>
|
110
125
|
|
126
|
+
<h3 id="create-new-version">Create new version</h3>
|
127
|
+
|
128
|
+
<ul>
|
129
|
+
<li>Fill the CHANGELOG with the changes contained in the new version</li>
|
130
|
+
<li>Ensure the specs are green</li>
|
131
|
+
<li>Change the versions in <code>lib/shattered_machine.rb</code> and <code>shattered_machine.gemspec</code></li>
|
132
|
+
<li>Create git tag</li>
|
133
|
+
<li>Compile the gem : <code>gem build shattered_machine.gemspec</code></li>
|
134
|
+
<li>Push the new version : <code>gem push shattered_machine-x.x.x.gem</code></li>
|
135
|
+
</ul>
|
136
|
+
|
111
137
|
<h3 id="specs">Specs</h3>
|
138
|
+
|
112
139
|
<p>This project uses <a href="https://rspec.info/">Rspec</a> for writting specs, to run them simply run <code>bundle rspec</code></p>
|
140
|
+
|
141
|
+
<h2 id="acknowledgements">Acknowledgements</h2>
|
142
|
+
|
143
|
+
<p>This gem is relying heavily on the <a href="https://github.com/ucnv/pnglitch">pnglitch gem</a> and the <a href="https://framagit.org/Radoteur/rusty_engine">rusty engine gem</a>.
|
144
|
+
The png image used in the specs has been created with <a href="https://100r.co/site/ronin.html">Ronin</a> while the jpg one is painting from Karl Wiener.
|
145
|
+
Icons made by <a href="http://www.freepik.com/">Freepik</a> from <a href="https://www.flaticon.com/">www.flaticon.com</a></p>
|
113
146
|
</div></div>
|
114
147
|
|
115
148
|
<div id="footer">
|
116
|
-
Generated on
|
149
|
+
Generated on Fri Aug 6 17:15:03 2021 by
|
117
150
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
118
151
|
0.9.26 (ruby-2.6.6).
|
119
152
|
</div>
|
data/doc/method_list.html
CHANGED
@@ -46,101 +46,109 @@
|
|
46
46
|
|
47
47
|
<li class="odd ">
|
48
48
|
<div class="item">
|
49
|
-
<span class='object_link'><a href="ShatteredMachine/
|
50
|
-
<small>ShatteredMachine::
|
49
|
+
<span class='object_link'><a href="ShatteredMachine/Sampler.html#call-instance_method" title="ShatteredMachine::Sampler#call (method)">#call</a></span>
|
50
|
+
<small>ShatteredMachine::Sampler</small>
|
51
51
|
</div>
|
52
52
|
</li>
|
53
53
|
|
54
54
|
|
55
55
|
<li class="even ">
|
56
56
|
<div class="item">
|
57
|
-
<span class='object_link'><a href="ShatteredMachine/
|
58
|
-
<small>ShatteredMachine::
|
57
|
+
<span class='object_link'><a href="ShatteredMachine/Exchange.html#call-instance_method" title="ShatteredMachine::Exchange#call (method)">#call</a></span>
|
58
|
+
<small>ShatteredMachine::Exchange</small>
|
59
59
|
</div>
|
60
60
|
</li>
|
61
61
|
|
62
62
|
|
63
63
|
<li class="odd ">
|
64
64
|
<div class="item">
|
65
|
-
<span class='object_link'><a href="ShatteredMachine/
|
66
|
-
<small>ShatteredMachine::
|
65
|
+
<span class='object_link'><a href="ShatteredMachine/PixelSorter.html#call-instance_method" title="ShatteredMachine::PixelSorter#call (method)">#call</a></span>
|
66
|
+
<small>ShatteredMachine::PixelSorter</small>
|
67
67
|
</div>
|
68
68
|
</li>
|
69
69
|
|
70
70
|
|
71
71
|
<li class="even ">
|
72
72
|
<div class="item">
|
73
|
-
<span class='object_link'><a href="ShatteredMachine/
|
74
|
-
<small>ShatteredMachine::
|
73
|
+
<span class='object_link'><a href="ShatteredMachine/Glitcher.html#call-instance_method" title="ShatteredMachine::Glitcher#call (method)">#call</a></span>
|
74
|
+
<small>ShatteredMachine::Glitcher</small>
|
75
75
|
</div>
|
76
76
|
</li>
|
77
77
|
|
78
78
|
|
79
79
|
<li class="odd ">
|
80
80
|
<div class="item">
|
81
|
-
<span class='object_link'><a href="ShatteredMachine/
|
82
|
-
<small>ShatteredMachine::
|
81
|
+
<span class='object_link'><a href="ShatteredMachine/Brush.html#call-instance_method" title="ShatteredMachine::Brush#call (method)">#call</a></span>
|
82
|
+
<small>ShatteredMachine::Brush</small>
|
83
83
|
</div>
|
84
84
|
</li>
|
85
85
|
|
86
86
|
|
87
87
|
<li class="even ">
|
88
88
|
<div class="item">
|
89
|
-
<span class='object_link'><a href="ShatteredMachine/
|
90
|
-
<small>ShatteredMachine::
|
89
|
+
<span class='object_link'><a href="ShatteredMachine/Converter.html#call-instance_method" title="ShatteredMachine::Converter#call (method)">#call</a></span>
|
90
|
+
<small>ShatteredMachine::Converter</small>
|
91
91
|
</div>
|
92
92
|
</li>
|
93
93
|
|
94
94
|
|
95
95
|
<li class="odd ">
|
96
96
|
<div class="item">
|
97
|
-
<span class='object_link'><a href="ShatteredMachine/
|
98
|
-
<small>ShatteredMachine::
|
97
|
+
<span class='object_link'><a href="ShatteredMachine/ProgressivePixelSorter.html#call-instance_method" title="ShatteredMachine::ProgressivePixelSorter#call (method)">#call</a></span>
|
98
|
+
<small>ShatteredMachine::ProgressivePixelSorter</small>
|
99
99
|
</div>
|
100
100
|
</li>
|
101
101
|
|
102
102
|
|
103
103
|
<li class="even ">
|
104
104
|
<div class="item">
|
105
|
-
<span class='object_link'><a href="ShatteredMachine/
|
106
|
-
<small>ShatteredMachine::
|
105
|
+
<span class='object_link'><a href="ShatteredMachine/Transpose.html#call-instance_method" title="ShatteredMachine::Transpose#call (method)">#call</a></span>
|
106
|
+
<small>ShatteredMachine::Transpose</small>
|
107
107
|
</div>
|
108
108
|
</li>
|
109
109
|
|
110
110
|
|
111
111
|
<li class="odd ">
|
112
112
|
<div class="item">
|
113
|
-
<span class='object_link'><a href="ShatteredMachine/
|
114
|
-
<small>ShatteredMachine::
|
113
|
+
<span class='object_link'><a href="ShatteredMachine/Defect.html#call-instance_method" title="ShatteredMachine::Defect#call (method)">#call</a></span>
|
114
|
+
<small>ShatteredMachine::Defect</small>
|
115
115
|
</div>
|
116
116
|
</li>
|
117
117
|
|
118
118
|
|
119
119
|
<li class="even ">
|
120
120
|
<div class="item">
|
121
|
-
<span class='object_link'><a href="ShatteredMachine/
|
122
|
-
<small>ShatteredMachine::
|
121
|
+
<span class='object_link'><a href="ShatteredMachine/ChangeByte.html#call-instance_method" title="ShatteredMachine::ChangeByte#call (method)">#call</a></span>
|
122
|
+
<small>ShatteredMachine::ChangeByte</small>
|
123
123
|
</div>
|
124
124
|
</li>
|
125
125
|
|
126
126
|
|
127
127
|
<li class="odd ">
|
128
128
|
<div class="item">
|
129
|
-
<span class='object_link'><a href="ShatteredMachine/
|
130
|
-
<small>ShatteredMachine::
|
129
|
+
<span class='object_link'><a href="ShatteredMachine/Slim.html#call-instance_method" title="ShatteredMachine::Slim#call (method)">#call</a></span>
|
130
|
+
<small>ShatteredMachine::Slim</small>
|
131
131
|
</div>
|
132
132
|
</li>
|
133
133
|
|
134
134
|
|
135
135
|
<li class="even ">
|
136
136
|
<div class="item">
|
137
|
-
<span class='object_link'><a href="ShatteredMachine/
|
138
|
-
<small>ShatteredMachine::
|
137
|
+
<span class='object_link'><a href="ShatteredMachine/WrongFilter.html#call-instance_method" title="ShatteredMachine::WrongFilter#call (method)">#call</a></span>
|
138
|
+
<small>ShatteredMachine::WrongFilter</small>
|
139
139
|
</div>
|
140
140
|
</li>
|
141
141
|
|
142
142
|
|
143
143
|
<li class="odd ">
|
144
|
+
<div class="item">
|
145
|
+
<span class='object_link'><a href="ShatteredMachine/Glitcher.html#initialize-instance_method" title="ShatteredMachine::Glitcher#initialize (method)">#initialize</a></span>
|
146
|
+
<small>ShatteredMachine::Glitcher</small>
|
147
|
+
</div>
|
148
|
+
</li>
|
149
|
+
|
150
|
+
|
151
|
+
<li class="even ">
|
144
152
|
<div class="item">
|
145
153
|
<span class='object_link'><a href="ShatteredMachine/Io.html#initialize-instance_method" title="ShatteredMachine::Io#initialize (method)">#initialize</a></span>
|
146
154
|
<small>ShatteredMachine::Io</small>
|
@@ -148,7 +156,7 @@
|
|
148
156
|
</li>
|
149
157
|
|
150
158
|
|
151
|
-
<li class="
|
159
|
+
<li class="odd ">
|
152
160
|
<div class="item">
|
153
161
|
<span class='object_link'><a href="ShatteredMachine/Slim.html#initialize-instance_method" title="ShatteredMachine::Slim#initialize (method)">#initialize</a></span>
|
154
162
|
<small>ShatteredMachine::Slim</small>
|
@@ -156,7 +164,7 @@
|
|
156
164
|
</li>
|
157
165
|
|
158
166
|
|
159
|
-
<li class="
|
167
|
+
<li class="even ">
|
160
168
|
<div class="item">
|
161
169
|
<span class='object_link'><a href="ShatteredMachine/Brush.html#initialize-instance_method" title="ShatteredMachine::Brush#initialize (method)">#initialize</a></span>
|
162
170
|
<small>ShatteredMachine::Brush</small>
|
@@ -164,7 +172,7 @@
|
|
164
172
|
</li>
|
165
173
|
|
166
174
|
|
167
|
-
<li class="
|
175
|
+
<li class="odd ">
|
168
176
|
<div class="item">
|
169
177
|
<span class='object_link'><a href="ShatteredMachine/Defect.html#initialize-instance_method" title="ShatteredMachine::Defect#initialize (method)">#initialize</a></span>
|
170
178
|
<small>ShatteredMachine::Defect</small>
|
@@ -172,7 +180,7 @@
|
|
172
180
|
</li>
|
173
181
|
|
174
182
|
|
175
|
-
<li class="
|
183
|
+
<li class="even ">
|
176
184
|
<div class="item">
|
177
185
|
<span class='object_link'><a href="ShatteredMachine/Sampler.html#initialize-instance_method" title="ShatteredMachine::Sampler#initialize (method)">#initialize</a></span>
|
178
186
|
<small>ShatteredMachine::Sampler</small>
|
@@ -180,15 +188,15 @@
|
|
180
188
|
</li>
|
181
189
|
|
182
190
|
|
183
|
-
<li class="
|
191
|
+
<li class="odd ">
|
184
192
|
<div class="item">
|
185
|
-
<span class='object_link'><a href="ShatteredMachine/
|
186
|
-
<small>ShatteredMachine::
|
193
|
+
<span class='object_link'><a href="ShatteredMachine/Exchange.html#initialize-instance_method" title="ShatteredMachine::Exchange#initialize (method)">#initialize</a></span>
|
194
|
+
<small>ShatteredMachine::Exchange</small>
|
187
195
|
</div>
|
188
196
|
</li>
|
189
197
|
|
190
198
|
|
191
|
-
<li class="
|
199
|
+
<li class="even ">
|
192
200
|
<div class="item">
|
193
201
|
<span class='object_link'><a href="ShatteredMachine/Converter.html#initialize-instance_method" title="ShatteredMachine::Converter#initialize (method)">#initialize</a></span>
|
194
202
|
<small>ShatteredMachine::Converter</small>
|
@@ -196,7 +204,7 @@
|
|
196
204
|
</li>
|
197
205
|
|
198
206
|
|
199
|
-
<li class="
|
207
|
+
<li class="odd ">
|
200
208
|
<div class="item">
|
201
209
|
<span class='object_link'><a href="ShatteredMachine/Transpose.html#initialize-instance_method" title="ShatteredMachine::Transpose#initialize (method)">#initialize</a></span>
|
202
210
|
<small>ShatteredMachine::Transpose</small>
|
@@ -204,7 +212,7 @@
|
|
204
212
|
</li>
|
205
213
|
|
206
214
|
|
207
|
-
<li class="
|
215
|
+
<li class="even ">
|
208
216
|
<div class="item">
|
209
217
|
<span class='object_link'><a href="ShatteredMachine/ChangeByte.html#initialize-instance_method" title="ShatteredMachine::ChangeByte#initialize (method)">#initialize</a></span>
|
210
218
|
<small>ShatteredMachine::ChangeByte</small>
|
@@ -212,7 +220,7 @@
|
|
212
220
|
</li>
|
213
221
|
|
214
222
|
|
215
|
-
<li class="
|
223
|
+
<li class="odd ">
|
216
224
|
<div class="item">
|
217
225
|
<span class='object_link'><a href="ShatteredMachine/PixelSorter.html#initialize-instance_method" title="ShatteredMachine::PixelSorter#initialize (method)">#initialize</a></span>
|
218
226
|
<small>ShatteredMachine::PixelSorter</small>
|
@@ -220,7 +228,7 @@
|
|
220
228
|
</li>
|
221
229
|
|
222
230
|
|
223
|
-
<li class="
|
231
|
+
<li class="even ">
|
224
232
|
<div class="item">
|
225
233
|
<span class='object_link'><a href="ShatteredMachine/WrongFilter.html#initialize-instance_method" title="ShatteredMachine::WrongFilter#initialize (method)">#initialize</a></span>
|
226
234
|
<small>ShatteredMachine::WrongFilter</small>
|
@@ -228,26 +236,18 @@
|
|
228
236
|
</li>
|
229
237
|
|
230
238
|
|
231
|
-
<li class="even ">
|
232
|
-
<div class="item">
|
233
|
-
<span class='object_link'><a href="ShatteredMachine/Io/Paths.html#input-instance_method" title="ShatteredMachine::Io::Paths#input (method)">#input</a></span>
|
234
|
-
<small>ShatteredMachine::Io::Paths</small>
|
235
|
-
</div>
|
236
|
-
</li>
|
237
|
-
|
238
|
-
|
239
239
|
<li class="odd ">
|
240
240
|
<div class="item">
|
241
|
-
<span class='object_link'><a href="ShatteredMachine/
|
242
|
-
<small>ShatteredMachine::
|
241
|
+
<span class='object_link'><a href="ShatteredMachine/ProgressivePixelSorter.html#initialize-instance_method" title="ShatteredMachine::ProgressivePixelSorter#initialize (method)">#initialize</a></span>
|
242
|
+
<small>ShatteredMachine::ProgressivePixelSorter</small>
|
243
243
|
</div>
|
244
244
|
</li>
|
245
245
|
|
246
246
|
|
247
247
|
<li class="even ">
|
248
248
|
<div class="item">
|
249
|
-
<span class='object_link'><a href="ShatteredMachine/Io
|
250
|
-
<small>ShatteredMachine::Io
|
249
|
+
<span class='object_link'><a href="ShatteredMachine/Io.html#jpg_images-instance_method" title="ShatteredMachine::Io#jpg_images (method)">#jpg_images</a></span>
|
250
|
+
<small>ShatteredMachine::Io</small>
|
251
251
|
</div>
|
252
252
|
</li>
|
253
253
|
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Fri Aug 6 17:15:03 2021 by
|
104
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.26 (ruby-2.6.6).
|
106
106
|
</div>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'pixel_sorter'
|
4
|
+
module ShatteredMachine
|
5
|
+
# Call the pixel sorter multiple time in steps for given png image(s)
|
6
|
+
class ProgressivePixelSorter
|
7
|
+
# @param io [ShatteredMachine::Io] Io containing paths for images to glitch
|
8
|
+
# @param options [Hash] options for the pixel sorting algorithm
|
9
|
+
def initialize(io, options)
|
10
|
+
@io = io
|
11
|
+
@options = options
|
12
|
+
@images_count = @io.png_images.count
|
13
|
+
@steps = define_steps
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
@io.png_images.sort_by { |path| [path.input[/\d+/].to_i, path.input] }.each_with_index do |item, index|
|
18
|
+
PixelSorter.new(sorter_options(index)).call(item.input, item.output)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def sorter_options(index)
|
25
|
+
return @options unless @options[:smart_sorting]
|
26
|
+
|
27
|
+
step_options = @options.clone
|
28
|
+
step_options[:multiple_ranges] = false
|
29
|
+
step_options[:detection_min] = (define_new_min_limit(index)).round.to_s
|
30
|
+
step_options[:detection_max] = (define_new_max_limit(index)).round.to_s
|
31
|
+
step_options
|
32
|
+
end
|
33
|
+
|
34
|
+
def define_steps
|
35
|
+
{ min: min_step, max: max_step }
|
36
|
+
end
|
37
|
+
|
38
|
+
def min_step
|
39
|
+
positive_subtraction(@options[:detection_min].to_f, @options[:detection_min_two].to_f) / (@images_count - 1)
|
40
|
+
end
|
41
|
+
|
42
|
+
def max_step
|
43
|
+
positive_subtraction(@options[:detection_max].to_f, @options[:detection_max_two].to_f) / (@images_count - 1)
|
44
|
+
end
|
45
|
+
|
46
|
+
def positive_subtraction(value1, value2)
|
47
|
+
value1 > value2 ? value1 - value2 : value2 - value1
|
48
|
+
end
|
49
|
+
|
50
|
+
def define_new_min_limit(index)
|
51
|
+
if @options[:detection_min].to_f > @options[:detection_min_two].to_f
|
52
|
+
(@options[:detection_min].to_f - (index * @steps[:min]))
|
53
|
+
else
|
54
|
+
(@options[:detection_min].to_f + (index * @steps[:min]))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def define_new_max_limit(index)
|
59
|
+
if @options[:detection_max].to_f > @options[:detection_max_two].to_f
|
60
|
+
(@options[:detection_max].to_f - (index * @steps[:max]))
|
61
|
+
else
|
62
|
+
(@options[:detection_max].to_f + (index * @steps[:max]))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -11,7 +11,7 @@ module ShatteredMachine
|
|
11
11
|
# @param options [Hash] options for specifying which
|
12
12
|
def initialize(io, options = {})
|
13
13
|
@io = io
|
14
|
-
@base_output_filename = io.output_filename
|
14
|
+
@base_output_filename = io.output_filename.empty? ? 'sample' : io.output_filename
|
15
15
|
@algorithms_to_sample = options[:algorithms_to_sample] || ALL_ALGORITHMS
|
16
16
|
end
|
17
17
|
|
@@ -30,8 +30,7 @@ module ShatteredMachine
|
|
30
30
|
private
|
31
31
|
|
32
32
|
FILTERS = %w[none sub up average paeth].freeze
|
33
|
-
|
34
|
-
BRUSH_DIRECTION = %w[vertical vertical_inverted horizontal horizontal_inverted].freeze
|
33
|
+
DIRECTION = %w[vertical vertical_inverted horizontal horizontal_inverted].freeze
|
35
34
|
|
36
35
|
def update_io(output_filename_appendix)
|
37
36
|
@io.output_filename = "#{@base_output_filename}_#{output_filename_appendix}"
|
@@ -65,7 +64,7 @@ module ShatteredMachine
|
|
65
64
|
def sample_slim
|
66
65
|
return unless @algorithms_to_sample.include? 'slim'
|
67
66
|
|
68
|
-
|
67
|
+
DIRECTION.each do |direction|
|
69
68
|
update_io("slim_#{direction}")
|
70
69
|
slim_options = { direction: direction.to_sym }
|
71
70
|
Glitcher.new('Slim', @io, slim_options).call
|
@@ -75,7 +74,7 @@ module ShatteredMachine
|
|
75
74
|
def sample_brush
|
76
75
|
return unless @algorithms_to_sample.include? 'brush'
|
77
76
|
|
78
|
-
|
77
|
+
DIRECTION.each do |direction|
|
79
78
|
update_io("brush_#{direction}")
|
80
79
|
brush_options = { direction: direction.to_sym }
|
81
80
|
Glitcher.new('Brush', @io, brush_options).call
|
@@ -11,7 +11,7 @@ module ShatteredMachine
|
|
11
11
|
# @param options [Hash] options for slim algorithm
|
12
12
|
def initialize(options = {})
|
13
13
|
@colors = options[:colors] || ALL_COLORS
|
14
|
-
@direction = options[:direction] || :
|
14
|
+
@direction = options[:direction] || :vertical_inverted
|
15
15
|
@probability = (options[:probability] || 95).to_s
|
16
16
|
@probability_area = options[:probability_area] || 'global'
|
17
17
|
@colors_with_proba = colors_with_proba(options[:colors_with_proba])
|
@@ -38,7 +38,9 @@ module ShatteredMachine
|
|
38
38
|
|
39
39
|
def rust_formatted_direction
|
40
40
|
ruby_to_rust_directions = { up_to_down: '1', down_to_up: '2',
|
41
|
-
left_to_right: '3', right_to_left: '4'
|
41
|
+
left_to_right: '3', right_to_left: '4',
|
42
|
+
vertical: '1', vertical_inverted: '2',
|
43
|
+
horizontal: '3', horizontal_inverted: '4' }
|
42
44
|
ruby_to_rust_directions[@direction]
|
43
45
|
end
|
44
46
|
|
data/lib/shattered_machine.rb
CHANGED
@@ -3,11 +3,12 @@
|
|
3
3
|
require 'shattered_machine/converter'
|
4
4
|
require 'shattered_machine/glitcher'
|
5
5
|
require 'shattered_machine/io'
|
6
|
+
require 'shattered_machine/progressive_pixel_sorter'
|
6
7
|
require 'shattered_machine/sampler'
|
7
8
|
|
8
9
|
# main file for ShatteredMachine gem
|
9
10
|
module ShatteredMachine
|
10
|
-
VERSION = '0.
|
11
|
+
VERSION = '0.1.1'
|
11
12
|
|
12
13
|
class << self
|
13
14
|
end
|
data/shattered_machine.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'English'
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'shattered_machine'
|
7
|
-
s.version = '0.
|
7
|
+
s.version = '0.1.2'
|
8
8
|
s.required_ruby_version = '>= 2.0.0'
|
9
9
|
s.required_rubygems_version = '>= 1.8.11'
|
10
10
|
s.summary = 'Shattered Machine core engine'
|
@@ -17,9 +17,10 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = ['spec']
|
18
18
|
s.require_paths = ['lib']
|
19
19
|
s.homepage =
|
20
|
-
'https://
|
20
|
+
'https://gitlab.com/girflo/shattered-machine'
|
21
21
|
s.license = 'MIT'
|
22
|
-
s.add_dependency '
|
22
|
+
s.add_dependency 'pnglitch', '~> 0.0.5'
|
23
|
+
s.add_dependency 'rusty_engine_ffi', '~> 0.1.0'
|
23
24
|
s.add_development_dependency('rspec', '~> 3')
|
24
25
|
s.add_development_dependency('yard', '~> 0.9')
|
25
26
|
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shattered_machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flo Girardo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pnglitch
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.5
|
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.5
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rusty_engine_ffi
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0
|
33
|
+
version: 0.1.0
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0
|
40
|
+
version: 0.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,7 +75,7 @@ extra_rdoc_files: []
|
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
63
77
|
- ".rspec"
|
64
|
-
- CHANGELOG
|
78
|
+
- CHANGELOG.md
|
65
79
|
- Gemfile
|
66
80
|
- LICENSE
|
67
81
|
- README.md
|
@@ -75,6 +89,7 @@ files:
|
|
75
89
|
- doc/ShatteredMachine/Io.html
|
76
90
|
- doc/ShatteredMachine/Io/Paths.html
|
77
91
|
- doc/ShatteredMachine/PixelSorter.html
|
92
|
+
- doc/ShatteredMachine/ProgressivePixelSorter.html
|
78
93
|
- doc/ShatteredMachine/Sampler.html
|
79
94
|
- doc/ShatteredMachine/Slim.html
|
80
95
|
- doc/ShatteredMachine/Transpose.html
|
@@ -103,12 +118,13 @@ files:
|
|
103
118
|
- lib/shattered_machine/glitcher.rb
|
104
119
|
- lib/shattered_machine/io.rb
|
105
120
|
- lib/shattered_machine/pixel_sorter.rb
|
121
|
+
- lib/shattered_machine/progressive_pixel_sorter.rb
|
106
122
|
- lib/shattered_machine/sampler.rb
|
107
123
|
- lib/shattered_machine/slim.rb
|
108
124
|
- lib/shattered_machine/transpose.rb
|
109
125
|
- lib/shattered_machine/wrong_filter.rb
|
110
126
|
- shattered_machine.gemspec
|
111
|
-
homepage: https://
|
127
|
+
homepage: https://gitlab.com/girflo/shattered-machine
|
112
128
|
licenses:
|
113
129
|
- MIT
|
114
130
|
metadata: {}
|