shattered_machine 0.0.1 → 0.0.6
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/.gitignore +2 -1
- data/CHANGELOG +27 -0
- data/Gemfile +1 -0
- data/README.md +14 -4
- data/doc/ShatteredMachine.html +13 -2
- data/doc/ShatteredMachine/Brush.html +1 -1
- data/doc/ShatteredMachine/ChangeByte.html +1 -1
- data/doc/ShatteredMachine/Converter.html +1 -1
- data/doc/ShatteredMachine/Defect.html +1 -1
- data/doc/ShatteredMachine/Exchange.html +25 -9
- data/doc/ShatteredMachine/Glitcher.html +1 -1
- data/doc/ShatteredMachine/Io.html +1 -1
- data/doc/ShatteredMachine/Io/Paths.html +1 -1
- data/doc/ShatteredMachine/PixelSorter.html +4 -4
- data/doc/ShatteredMachine/Sampler.html +2 -2
- data/doc/ShatteredMachine/Slim.html +2 -2
- data/doc/ShatteredMachine/Transpose.html +25 -9
- data/doc/ShatteredMachine/WrongFilter.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/shattered_machine.rb +5 -2
- data/lib/shattered_machine/brush.rb +1 -1
- data/lib/shattered_machine/converter.rb +1 -1
- data/lib/shattered_machine/exchange.rb +3 -2
- data/lib/shattered_machine/pixel_sorter.rb +4 -4
- data/lib/shattered_machine/sampler.rb +7 -6
- data/lib/shattered_machine/slim.rb +2 -2
- data/lib/shattered_machine/transpose.rb +15 -8
- data/lib/shattered_machine/wrong_filter.rb +1 -1
- data/shattered_machine.gemspec +5 -2
- data/spec/brush_spec.rb +0 -3
- data/spec/change_byte_spec.rb +0 -1
- data/spec/converter_spec.rb +0 -1
- data/spec/defect_spec.rb +0 -1
- data/spec/exchange_spec.rb +0 -1
- data/spec/glitcher_spec.rb +0 -1
- data/spec/io_spec.rb +0 -1
- data/spec/pixel_sorter_spec.rb +0 -1
- data/spec/sampler_spec.rb +9 -1
- data/spec/slim_spec.rb +0 -1
- data/spec/spec_helper.rb +2 -36
- data/spec/transpose_spec.rb +0 -1
- data/spec/wrong_filter_spec.rb +0 -1
- metadata +21 -17
- data/.yardoc/checksums +0 -14
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/doc/ShatteredMachine/RustyEngine.html +0 -111
- data/lib/rusty_engine/librusty_engine.dll +0 -0
- data/lib/rusty_engine/librusty_engine.dylib +0 -0
- data/lib/rusty_engine/librusty_engine.so +0 -0
- data/lib/rusty_engine/rusty_engine.rb +0 -39
- data/spec/lib/rusty_engine_spec.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: acdc50f794c42c05f8189c39e6cda49cc8123225c1905ada71432c35aa860146
|
|
4
|
+
data.tar.gz: b4f426c40b8e86768de129b8d04bb84e377ea7c094f15d8ca296fb17f9188dbd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 494b39fbf8754277a62163ef19d4cb4e08064dfa321223c98269e26d9a79da4be91e6acbb46a4b0cc455b105f34a3297f48d6534413deb01d7f019c782a5d9ee
|
|
7
|
+
data.tar.gz: c0de26aed202aab4a31b3335f9a6eccd02e0bf4d81e8ad5c19ff8a36ec430ee946b1a6bab7c515071f61b788ce1cad70a7902aa0e323e0f0ccf97bfdbcb1c38f
|
data/.gitignore
CHANGED
data/CHANGELOG
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
## [0.0.6] - 2021-05-28
|
|
8
|
+
### Added
|
|
9
|
+
- Add Sampler in the main lib
|
|
10
|
+
|
|
11
|
+
## [0.0.5] - 2021-05-28
|
|
12
|
+
### Added
|
|
13
|
+
- Rusty Engine dependency in gemspec file
|
|
14
|
+
|
|
15
|
+
## [0.0.4] - 2021-05-28
|
|
16
|
+
### Added
|
|
17
|
+
- Acknowledgements section in README
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
- The following Sampler constant are not publically available anymore : FILTERS, SLIM_DIRECTION and BRUSH_DIRECTION
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- By default the Sampler now also run the Brush algorithm
|
|
24
|
+
|
|
25
|
+
## [0.0.3] - 2021-05-26
|
|
26
|
+
### Changed
|
|
27
|
+
- Replaces Rusty Engine library with the gem encapsulating those files
|
data/Gemfile
CHANGED
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(
|
|
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(
|
|
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(
|
|
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.
|
data/doc/ShatteredMachine.html
CHANGED
|
@@ -85,7 +85,18 @@
|
|
|
85
85
|
|
|
86
86
|
</div>
|
|
87
87
|
|
|
88
|
-
<h2>
|
|
88
|
+
<h2>Overview</h2><div class="docstring">
|
|
89
|
+
<div class="discussion">
|
|
90
|
+
|
|
91
|
+
<p>main file for ShatteredMachine gem</p>
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="tags">
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
</div><h2>Defined Under Namespace</h2>
|
|
89
100
|
<p class="children">
|
|
90
101
|
|
|
91
102
|
|
|
@@ -125,7 +136,7 @@
|
|
|
125
136
|
</div>
|
|
126
137
|
|
|
127
138
|
<div id="footer">
|
|
128
|
-
Generated on Sun May 23
|
|
139
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
129
140
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
130
141
|
0.9.26 (ruby-2.6.6).
|
|
131
142
|
</div>
|
|
@@ -365,7 +365,7 @@
|
|
|
365
365
|
</div>
|
|
366
366
|
|
|
367
367
|
<div id="footer">
|
|
368
|
-
Generated on Sun May 23
|
|
368
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
369
369
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
370
370
|
0.9.26 (ruby-2.6.6).
|
|
371
371
|
</div>
|
|
@@ -357,7 +357,7 @@
|
|
|
357
357
|
</div>
|
|
358
358
|
|
|
359
359
|
<div id="footer">
|
|
360
|
-
Generated on Sun May 23
|
|
360
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
361
361
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
362
362
|
0.9.26 (ruby-2.6.6).
|
|
363
363
|
</div>
|
|
@@ -317,7 +317,7 @@
|
|
|
317
317
|
</div>
|
|
318
318
|
|
|
319
319
|
<div id="footer">
|
|
320
|
-
Generated on Sun May 23
|
|
320
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
321
321
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
322
322
|
0.9.26 (ruby-2.6.6).
|
|
323
323
|
</div>
|
|
@@ -359,7 +359,7 @@
|
|
|
359
359
|
</div>
|
|
360
360
|
|
|
361
361
|
<div id="footer">
|
|
362
|
-
Generated on Sun May 23
|
|
362
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
363
363
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
364
364
|
0.9.26 (ruby-2.6.6).
|
|
365
365
|
</div>
|
|
@@ -111,6 +111,22 @@
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
</div>
|
|
114
|
+
|
|
115
|
+
<h2>
|
|
116
|
+
Constant Summary
|
|
117
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
|
118
|
+
</h2>
|
|
119
|
+
|
|
120
|
+
<dl class="constants">
|
|
121
|
+
|
|
122
|
+
<dt id="ALL_FILTERS-constant" class="">ALL_FILTERS =
|
|
123
|
+
|
|
124
|
+
</dt>
|
|
125
|
+
<dd><pre class="code"><span class='qwords_beg'>%w[</span><span class='tstring_content'>none</span><span class='words_sep'> </span><span class='tstring_content'>sub</span><span class='words_sep'> </span><span class='tstring_content'>up</span><span class='words_sep'> </span><span class='tstring_content'>average</span><span class='words_sep'> </span><span class='tstring_content'>paeth</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
126
|
+
|
|
127
|
+
</dl>
|
|
128
|
+
|
|
129
|
+
|
|
114
130
|
|
|
115
131
|
|
|
116
132
|
|
|
@@ -229,15 +245,15 @@
|
|
|
229
245
|
<pre class="lines">
|
|
230
246
|
|
|
231
247
|
|
|
232
|
-
8
|
|
233
|
-
9
|
|
234
248
|
10
|
|
235
249
|
11
|
|
236
250
|
12
|
|
237
|
-
13
|
|
251
|
+
13
|
|
252
|
+
14
|
|
253
|
+
15</pre>
|
|
238
254
|
</td>
|
|
239
255
|
<td>
|
|
240
|
-
<pre class="code"><span class="info file"># File 'lib/shattered_machine/exchange.rb', line
|
|
256
|
+
<pre class="code"><span class="info file"># File 'lib/shattered_machine/exchange.rb', line 10</span>
|
|
241
257
|
|
|
242
258
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
243
259
|
<span class='ivar'>@filter</span> <span class='op'>=</span> <span class='id identifier rubyid_define_filter'>define_filter</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:filter</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>average</span><span class='tstring_end'>'</span></span>
|
|
@@ -337,15 +353,15 @@
|
|
|
337
353
|
<pre class="lines">
|
|
338
354
|
|
|
339
355
|
|
|
340
|
-
18
|
|
341
|
-
19
|
|
342
356
|
20
|
|
343
357
|
21
|
|
344
358
|
22
|
|
345
|
-
23
|
|
359
|
+
23
|
|
360
|
+
24
|
|
361
|
+
25</pre>
|
|
346
362
|
</td>
|
|
347
363
|
<td>
|
|
348
|
-
<pre class="code"><span class="info file"># File 'lib/shattered_machine/exchange.rb', line
|
|
364
|
+
<pre class="code"><span class="info file"># File 'lib/shattered_machine/exchange.rb', line 20</span>
|
|
349
365
|
|
|
350
366
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_input_image'>input_image</span><span class='comma'>,</span> <span class='id identifier rubyid_output_image'>output_image</span><span class='rparen'>)</span>
|
|
351
367
|
<span class='const'>PNGlitch</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_input_image'>input_image</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_png'>png</span><span class='op'>|</span>
|
|
@@ -363,7 +379,7 @@
|
|
|
363
379
|
</div>
|
|
364
380
|
|
|
365
381
|
<div id="footer">
|
|
366
|
-
Generated on Sun May 23
|
|
382
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
367
383
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
368
384
|
0.9.26 (ruby-2.6.6).
|
|
369
385
|
</div>
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
</div>
|
|
356
356
|
|
|
357
357
|
<div id="footer">
|
|
358
|
-
Generated on Sun May 23
|
|
358
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
359
359
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
360
360
|
0.9.26 (ruby-2.6.6).
|
|
361
361
|
</div>
|
|
@@ -559,7 +559,7 @@
|
|
|
559
559
|
</div>
|
|
560
560
|
|
|
561
561
|
<div id="footer">
|
|
562
|
-
Generated on Sun May 23
|
|
562
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
563
563
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
564
564
|
0.9.26 (ruby-2.6.6).
|
|
565
565
|
</div>
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
</div>
|
|
301
301
|
|
|
302
302
|
<div id="footer">
|
|
303
|
-
Generated on Sun May 23
|
|
303
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
304
304
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
305
305
|
0.9.26 (ruby-2.6.6).
|
|
306
306
|
</div>
|
|
@@ -251,8 +251,8 @@
|
|
|
251
251
|
<span class='ivar'>@detection_min</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:detection_min</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>45</span><span class='tstring_end'>'</span></span>
|
|
252
252
|
<span class='ivar'>@detection_max</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:detection_max</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>60</span><span class='tstring_end'>'</span></span>
|
|
253
253
|
<span class='ivar'>@multiple_ranges</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:multiple_ranges</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
|
254
|
-
<span class='ivar'>@
|
|
255
|
-
<span class='ivar'>@
|
|
254
|
+
<span class='ivar'>@detection_min_two</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:detection_min_two</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>75</span><span class='tstring_end'>'</span></span>
|
|
255
|
+
<span class='ivar'>@detection_max_two</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:detection_max_two</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>90</span><span class='tstring_end'>'</span></span>
|
|
256
256
|
<span class='ivar'>@sorting_by</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:sorting_by</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='symbol'>:hue</span>
|
|
257
257
|
<span class='kw'>end</span></pre>
|
|
258
258
|
</td>
|
|
@@ -359,7 +359,7 @@
|
|
|
359
359
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_input_image'>input_image</span><span class='comma'>,</span> <span class='id identifier rubyid_output_image'>output_image</span><span class='rparen'>)</span>
|
|
360
360
|
<span class='const'><span class='object_link'><a href="RustyEngine.html" title="ShatteredMachine::RustyEngine (module)">RustyEngine</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='id identifier rubyid_input_image'>input_image</span><span class='comma'>,</span> <span class='id identifier rubyid_output_image'>output_image</span><span class='comma'>,</span> <span class='id identifier rubyid_rust_formatted_direction'>rust_formatted_direction</span><span class='comma'>,</span> <span class='ivar'>@smart_sorting</span><span class='comma'>,</span>
|
|
361
361
|
<span class='id identifier rubyid_rust_formatted_detection_type'>rust_formatted_detection_type</span><span class='comma'>,</span> <span class='ivar'>@detection_min</span><span class='comma'>,</span> <span class='ivar'>@detection_max</span><span class='comma'>,</span> <span class='ivar'>@multiple_ranges</span><span class='comma'>,</span>
|
|
362
|
-
<span class='ivar'>@
|
|
362
|
+
<span class='ivar'>@detection_min_two</span><span class='comma'>,</span> <span class='ivar'>@detection_max_two</span><span class='comma'>,</span> <span class='id identifier rubyid_rust_formatted_sorting_by'>rust_formatted_sorting_by</span><span class='rparen'>)</span>
|
|
363
363
|
<span class='kw'>end</span></pre>
|
|
364
364
|
</td>
|
|
365
365
|
</tr>
|
|
@@ -371,7 +371,7 @@
|
|
|
371
371
|
</div>
|
|
372
372
|
|
|
373
373
|
<div id="footer">
|
|
374
|
-
Generated on Sun May 23
|
|
374
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
375
375
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
376
376
|
0.9.26 (ruby-2.6.6).
|
|
377
377
|
</div>
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
<dt id="ALL_ALGORITHMS-constant" class="">ALL_ALGORITHMS =
|
|
138
138
|
|
|
139
139
|
</dt>
|
|
140
|
-
<dd><pre class="code"><span class='qwords_beg'>%w[</span><span class='tstring_content'>exchange</span><span class='words_sep'> </span><span class='tstring_content'>transpose</span><span class='words_sep'> </span><span class='tstring_content'>wrong_filter</span><span class='words_sep'> </span><span class='tstring_content'>slim</span><span class='words_sep'> </span><span class='tstring_content'>brus</span><span class='words_sep'> </span><span class='tstring_content'>change_byte</span><span class='words_sep'> </span><span class='tstring_content'>defect</span><span class='tstring_end'>]</span></span></pre></dd>
|
|
140
|
+
<dd><pre class="code"><span class='qwords_beg'>%w[</span><span class='tstring_content'>exchange</span><span class='words_sep'> </span><span class='tstring_content'>transpose</span><span class='words_sep'> </span><span class='tstring_content'>wrong_filter</span><span class='words_sep'> </span><span class='tstring_content'>slim</span><span class='words_sep'> </span><span class='tstring_content'>brus</span><span class='words_sep'> </span><span class='tstring_content'>change_byte</span><span class='words_sep'> </span><span class='tstring_content'>defect</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
141
141
|
|
|
142
142
|
</dl>
|
|
143
143
|
|
|
@@ -351,7 +351,7 @@
|
|
|
351
351
|
</div>
|
|
352
352
|
|
|
353
353
|
<div id="footer">
|
|
354
|
-
Generated on Sun May 23
|
|
354
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
355
355
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
356
356
|
0.9.26 (ruby-2.6.6).
|
|
357
357
|
</div>
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
<dt id="ALL_COLORS-constant" class="">ALL_COLORS =
|
|
123
123
|
|
|
124
124
|
</dt>
|
|
125
|
-
<dd><pre class="code"><span class='qsymbols_beg'>%i
|
|
125
|
+
<dd><pre class="code"><span class='qsymbols_beg'>%i[</span><span class='tstring_content'>white</span><span class='words_sep'> </span><span class='tstring_content'>black</span><span class='words_sep'> </span><span class='tstring_content'>grey</span><span class='words_sep'> </span><span class='tstring_content'>red</span><span class='words_sep'> </span><span class='tstring_content'>green</span><span class='words_sep'> </span><span class='tstring_content'>blue</span><span class='words_sep'> </span><span class='tstring_content'>cyan</span><span class='words_sep'> </span><span class='tstring_content'>yellow</span><span class='words_sep'> </span><span class='tstring_content'>magenta</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
126
126
|
|
|
127
127
|
</dl>
|
|
128
128
|
|
|
@@ -379,7 +379,7 @@
|
|
|
379
379
|
</div>
|
|
380
380
|
|
|
381
381
|
<div id="footer">
|
|
382
|
-
Generated on Sun May 23
|
|
382
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
383
383
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
384
384
|
0.9.26 (ruby-2.6.6).
|
|
385
385
|
</div>
|
|
@@ -111,6 +111,22 @@
|
|
|
111
111
|
|
|
112
112
|
|
|
113
113
|
</div>
|
|
114
|
+
|
|
115
|
+
<h2>
|
|
116
|
+
Constant Summary
|
|
117
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
|
118
|
+
</h2>
|
|
119
|
+
|
|
120
|
+
<dl class="constants">
|
|
121
|
+
|
|
122
|
+
<dt id="ALL_FILTERS-constant" class="">ALL_FILTERS =
|
|
123
|
+
|
|
124
|
+
</dt>
|
|
125
|
+
<dd><pre class="code"><span class='qwords_beg'>%w[</span><span class='tstring_content'>none</span><span class='words_sep'> </span><span class='tstring_content'>sub</span><span class='words_sep'> </span><span class='tstring_content'>up</span><span class='words_sep'> </span><span class='tstring_content'>average</span><span class='words_sep'> </span><span class='tstring_content'>paeth</span><span class='tstring_end'>]</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
|
126
|
+
|
|
127
|
+
</dl>
|
|
128
|
+
|
|
129
|
+
|
|
114
130
|
|
|
115
131
|
|
|
116
132
|
|
|
@@ -229,13 +245,13 @@
|
|
|
229
245
|
<pre class="lines">
|
|
230
246
|
|
|
231
247
|
|
|
232
|
-
8
|
|
233
|
-
9
|
|
234
248
|
10
|
|
235
|
-
11
|
|
249
|
+
11
|
|
250
|
+
12
|
|
251
|
+
13</pre>
|
|
236
252
|
</td>
|
|
237
253
|
<td>
|
|
238
|
-
<pre class="code"><span class="info file"># File 'lib/shattered_machine/transpose.rb', line
|
|
254
|
+
<pre class="code"><span class="info file"># File 'lib/shattered_machine/transpose.rb', line 10</span>
|
|
239
255
|
|
|
240
256
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
241
257
|
<span class='ivar'>@filter</span> <span class='op'>=</span> <span class='id identifier rubyid_define_filter'>define_filter</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:filter</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>average</span><span class='tstring_end'>'</span></span>
|
|
@@ -333,15 +349,15 @@
|
|
|
333
349
|
<pre class="lines">
|
|
334
350
|
|
|
335
351
|
|
|
336
|
-
16
|
|
337
|
-
17
|
|
338
352
|
18
|
|
339
353
|
19
|
|
340
354
|
20
|
|
341
|
-
21
|
|
355
|
+
21
|
|
356
|
+
22
|
|
357
|
+
23</pre>
|
|
342
358
|
</td>
|
|
343
359
|
<td>
|
|
344
|
-
<pre class="code"><span class="info file"># File 'lib/shattered_machine/transpose.rb', line
|
|
360
|
+
<pre class="code"><span class="info file"># File 'lib/shattered_machine/transpose.rb', line 18</span>
|
|
345
361
|
|
|
346
362
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_input_image'>input_image</span><span class='comma'>,</span> <span class='id identifier rubyid_output_image'>output_image</span><span class='rparen'>)</span>
|
|
347
363
|
<span class='const'>PNGlitch</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_input_image'>input_image</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_png'>png</span><span class='op'>|</span>
|
|
@@ -359,7 +375,7 @@
|
|
|
359
375
|
</div>
|
|
360
376
|
|
|
361
377
|
<div id="footer">
|
|
362
|
-
Generated on Sun May 23
|
|
378
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
363
379
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
364
380
|
0.9.26 (ruby-2.6.6).
|
|
365
381
|
</div>
|
|
@@ -357,7 +357,7 @@
|
|
|
357
357
|
</div>
|
|
358
358
|
|
|
359
359
|
<div id="footer">
|
|
360
|
-
Generated on Sun May 23
|
|
360
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
361
361
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
362
362
|
0.9.26 (ruby-2.6.6).
|
|
363
363
|
</div>
|
data/doc/_index.html
CHANGED
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
</div>
|
|
279
279
|
|
|
280
280
|
<div id="footer">
|
|
281
|
-
Generated on Sun May 23
|
|
281
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
282
282
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
283
283
|
0.9.26 (ruby-2.6.6).
|
|
284
284
|
</div>
|
data/doc/index.html
CHANGED
|
@@ -113,7 +113,7 @@ To install the needed dependencies you need to install the <a href="https://www.
|
|
|
113
113
|
</div></div>
|
|
114
114
|
|
|
115
115
|
<div id="footer">
|
|
116
|
-
Generated on Sun May 23
|
|
116
|
+
Generated on Sun May 23 18:36:58 2021 by
|
|
117
117
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
118
118
|
0.9.26 (ruby-2.6.6).
|
|
119
119
|
</div>
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
</div>
|
|
101
101
|
|
|
102
102
|
<div id="footer">
|
|
103
|
-
Generated on Sun May 23
|
|
103
|
+
Generated on Sun May 23 18:36:58 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>
|
data/lib/shattered_machine.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'shattered_machine/converter'
|
|
3
4
|
require 'shattered_machine/glitcher'
|
|
4
5
|
require 'shattered_machine/io'
|
|
6
|
+
require 'shattered_machine/sampler'
|
|
5
7
|
|
|
8
|
+
# main file for ShatteredMachine gem
|
|
6
9
|
module ShatteredMachine
|
|
7
|
-
VERSION = '0.0.
|
|
10
|
+
VERSION = '0.0.6'
|
|
8
11
|
|
|
9
12
|
class << self
|
|
10
13
|
end
|
|
@@ -4,6 +4,8 @@ require 'pnglitch'
|
|
|
4
4
|
module ShatteredMachine
|
|
5
5
|
# Use the exchange algorithm from pnglitch on a given png image.
|
|
6
6
|
class Exchange
|
|
7
|
+
ALL_FILTERS = %w[none sub up average paeth].freeze
|
|
8
|
+
|
|
7
9
|
# @param options [Hash] options for exchange algorithm
|
|
8
10
|
def initialize(options = {})
|
|
9
11
|
@filter = define_filter(options[:filter]) || 'average'
|
|
@@ -27,8 +29,7 @@ module ShatteredMachine
|
|
|
27
29
|
def define_filter(filter_from_options)
|
|
28
30
|
return filter_from_options unless filter_from_options == 'random'
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
available_filters[rand(5)]
|
|
32
|
+
ALL_FILTERS[rand(5)]
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def give_me_a_letter(index = rand(26))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require 'rusty_engine'
|
|
4
4
|
|
|
5
5
|
module ShatteredMachine
|
|
6
6
|
# Sort pixels of a given png image.
|
|
@@ -14,8 +14,8 @@ module ShatteredMachine
|
|
|
14
14
|
@detection_min = options[:detection_min] || '45'
|
|
15
15
|
@detection_max = options[:detection_max] || '60'
|
|
16
16
|
@multiple_ranges = (options[:multiple_ranges] || false).to_s
|
|
17
|
-
@
|
|
18
|
-
@
|
|
17
|
+
@detection_min_two = options[:detection_min_two] || '75'
|
|
18
|
+
@detection_max_two = options[:detection_max_two] || '90'
|
|
19
19
|
@sorting_by = options[:sorting_by] || :hue
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -25,7 +25,7 @@ module ShatteredMachine
|
|
|
25
25
|
def call(input_image, output_image)
|
|
26
26
|
RustyEngine.sort(input_image, output_image, rust_formatted_direction, @smart_sorting,
|
|
27
27
|
rust_formatted_detection_type, @detection_min, @detection_max, @multiple_ranges,
|
|
28
|
-
@
|
|
28
|
+
@detection_min_two, @detection_max_two, rust_formatted_sorting_by)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
private
|
|
@@ -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
|
-
|
|
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]
|
|
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
|
|
@@ -84,7 +85,7 @@ module ShatteredMachine
|
|
|
84
85
|
def sample_change_byte
|
|
85
86
|
return unless @algorithms_to_sample.include? 'change_byte'
|
|
86
87
|
|
|
87
|
-
update_io(
|
|
88
|
+
update_io('change_byte')
|
|
88
89
|
change_byte_options = { algorithm: 'change_byte' }
|
|
89
90
|
Glitcher.new('ChangeByte', @io, change_byte_options).call
|
|
90
91
|
end
|
|
@@ -92,7 +93,7 @@ module ShatteredMachine
|
|
|
92
93
|
def sample_defect
|
|
93
94
|
return unless @algorithms_to_sample.include? 'defect'
|
|
94
95
|
|
|
95
|
-
update_io(
|
|
96
|
+
update_io('defect')
|
|
96
97
|
defect_options = { random: true, iterations: 10 }
|
|
97
98
|
Glitcher.new('Defect', @io, defect_options).call
|
|
98
99
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require 'rusty_engine'
|
|
4
4
|
|
|
5
5
|
module ShatteredMachine
|
|
6
6
|
# Repeat pixels of a given png image.
|
|
7
7
|
# The logic for the pixel sorter come from the Rusty Engine.
|
|
8
8
|
class Slim
|
|
9
|
-
ALL_COLORS = %i
|
|
9
|
+
ALL_COLORS = %i[white black grey red green blue cyan yellow magenta].freeze
|
|
10
10
|
|
|
11
11
|
# @param options [Hash] options for slim algorithm
|
|
12
12
|
def initialize(options = {})
|
|
@@ -4,6 +4,8 @@ require 'pnglitch'
|
|
|
4
4
|
module ShatteredMachine
|
|
5
5
|
# Use the transpose algorithm from pnglitch on a given png image.
|
|
6
6
|
class Transpose
|
|
7
|
+
ALL_FILTERS = %w[none sub up average paeth].freeze
|
|
8
|
+
|
|
7
9
|
# @param options [Hash] options for transpose algorithm
|
|
8
10
|
def initialize(options = {})
|
|
9
11
|
@filter = define_filter(options[:filter]) || 'average'
|
|
@@ -25,8 +27,7 @@ module ShatteredMachine
|
|
|
25
27
|
def define_filter(filter_from_options)
|
|
26
28
|
return filter_from_options unless filter_from_options == 'random'
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
available_filters[rand(5)]
|
|
30
|
+
ALL_FILTERS[rand(5)]
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def filtered_glitch(png, custom_filter)
|
|
@@ -39,12 +40,18 @@ module ShatteredMachine
|
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def transpose_data(data)
|
|
42
|
-
|
|
43
|
-
if @transpose_force == 'half'
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
quarter_image_size = data.size / 4
|
|
44
|
+
return half_transpose(data, quarter_image_size) if @transpose_force == 'half'
|
|
45
|
+
|
|
46
|
+
full_transpose(data, quarter_image_size)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def half_transpose(data, qis)
|
|
50
|
+
data[0, qis] + data[qis * 2, qis] + data[qis * 1, qis] + data[qis * 3..]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def full_transpose(data, qis)
|
|
54
|
+
data[qis * 2, qis] + data[0, qis] + data[qis * 3..] + data[qis * 1, qis]
|
|
48
55
|
end
|
|
49
56
|
end
|
|
50
57
|
end
|
data/shattered_machine.gemspec
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'shattered_machine'
|
|
3
|
-
s.version = '0.0.
|
|
3
|
+
s.version = '0.0.6'
|
|
4
|
+
s.required_ruby_version = '>= 2.0.0'
|
|
5
|
+
s.required_rubygems_version = '>= 1.8.11'
|
|
4
6
|
s.summary = 'Shattered Machine core engine'
|
|
5
7
|
s.description = 'Shattered Machine is an easy way to glitch PNG images using different algorithms'
|
|
6
8
|
s.authors = ['Flo Girardo']
|
|
@@ -9,8 +11,9 @@ Gem::Specification.new do |s|
|
|
|
9
11
|
s.test_files = ['spec']
|
|
10
12
|
s.require_paths = ['lib']
|
|
11
13
|
s.homepage =
|
|
12
|
-
'https://
|
|
14
|
+
'https://framagit.org/Radoteur/shattered-machine'
|
|
13
15
|
s.license = 'MIT'
|
|
16
|
+
s.add_dependency 'rusty_engine_ffi', '>=0.0.2'
|
|
14
17
|
s.add_development_dependency('rspec', '~> 3')
|
|
15
18
|
s.add_development_dependency('yard', '~> 0.9')
|
|
16
19
|
end
|
data/spec/brush_spec.rb
CHANGED
data/spec/change_byte_spec.rb
CHANGED
data/spec/converter_spec.rb
CHANGED
data/spec/defect_spec.rb
CHANGED
data/spec/exchange_spec.rb
CHANGED
data/spec/glitcher_spec.rb
CHANGED
data/spec/io_spec.rb
CHANGED
data/spec/pixel_sorter_spec.rb
CHANGED
data/spec/sampler_spec.rb
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
RSpec.describe ShatteredMachine::Sampler do
|
|
6
|
+
describe 'ALL_ALGORITHMS' do
|
|
7
|
+
subject { ShatteredMachine::Sampler::ALL_ALGORITHMS }
|
|
8
|
+
it 'returns all algorithm available in sampler' do
|
|
9
|
+
expect(subject).to eq ['brush', 'change_byte', 'defect', 'exchange', 'slim', 'transpose', 'wrong_filter']
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
6
13
|
describe '#call' do
|
|
7
14
|
let(:created_files) do
|
|
8
15
|
%w[sample_exchange_average.png sample_exchange_up.png sample_slim_up_to_down.png sample_transpose_sub.png
|
|
@@ -10,7 +17,8 @@ RSpec.describe ShatteredMachine::Sampler do
|
|
|
10
17
|
sample_transpose_up.png sample_wrong_filter_sub.png sample_change_byte.png sample_exchange_paeth.png
|
|
11
18
|
sample_slim_left_to_right.png sample_transpose_none.png sample_wrong_filter_average.png
|
|
12
19
|
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
|
|
20
|
+
sample_transpose_paeth.png sample_wrong_filter_none.png sample_brush_horizontal_inverted.png
|
|
21
|
+
sample_brush_horizontal.png sample_brush_vertical_inverted.png sample_brush_vertical.png]
|
|
14
22
|
end
|
|
15
23
|
let(:output_file) { 'spec/images/sample.png' }
|
|
16
24
|
let(:input_file) { 'spec/images/foo.png' }
|
data/spec/slim_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -1,51 +1,17 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
|
4
|
-
# this file to always be loaded, without a need to explicitly require it in any
|
|
5
|
-
# files.
|
|
6
|
-
#
|
|
7
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
|
8
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
9
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
10
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
|
11
|
-
# a separate helper file that requires the additional dependencies and performs
|
|
12
|
-
# the additional setup, and require it from the spec files that actually need
|
|
13
|
-
# it.
|
|
14
|
-
#
|
|
15
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
16
3
|
RSpec.configure do |config|
|
|
17
|
-
# rspec-expectations config goes here. You can use an alternate
|
|
18
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
19
|
-
# assertions if you prefer.
|
|
20
4
|
config.expect_with :rspec do |expectations|
|
|
21
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
22
|
-
# and `failure_message` of custom matchers include text for helper methods
|
|
23
|
-
# defined using `chain`, e.g.:
|
|
24
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
|
25
|
-
# # => "be bigger than 2 and smaller than 4"
|
|
26
|
-
# ...rather than:
|
|
27
|
-
# # => "be bigger than 2"
|
|
28
5
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
29
6
|
end
|
|
30
7
|
|
|
31
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
|
32
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
33
8
|
config.mock_with :rspec do |mocks|
|
|
34
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
|
35
|
-
# a real object. This is generally recommended, and will default to
|
|
36
|
-
# `true` in RSpec 4.
|
|
37
9
|
mocks.verify_partial_doubles = true
|
|
38
10
|
end
|
|
39
11
|
|
|
40
|
-
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
|
41
|
-
# have no way to turn it off -- the option exists only for backwards
|
|
42
|
-
# compatibility in RSpec 3). It causes shared context metadata to be
|
|
43
|
-
# inherited by the metadata hash of host groups and examples, rather than
|
|
44
|
-
# triggering implicit auto-inclusion in groups with matching metadata.
|
|
45
12
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
46
13
|
|
|
47
14
|
$LOAD_PATH.unshift File.expand_path('..', __dir__)
|
|
48
|
-
require 'lib/rusty_engine/rusty_engine'
|
|
49
15
|
require 'lib/shattered_machine/converter'
|
|
50
16
|
require 'lib/shattered_machine/brush'
|
|
51
17
|
require 'lib/shattered_machine/change_byte'
|
data/spec/transpose_spec.rb
CHANGED
data/spec/wrong_filter_spec.rb
CHANGED
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.
|
|
4
|
+
version: 0.0.6
|
|
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-
|
|
11
|
+
date: 2021-05-28 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
|
-
-
|
|
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
|
|
@@ -114,14 +119,13 @@ files:
|
|
|
114
119
|
- spec/images/fuzz.JPG
|
|
115
120
|
- spec/images/pouet.JPEG
|
|
116
121
|
- spec/io_spec.rb
|
|
117
|
-
- spec/lib/rusty_engine_spec.rb
|
|
118
122
|
- spec/pixel_sorter_spec.rb
|
|
119
123
|
- spec/sampler_spec.rb
|
|
120
124
|
- spec/slim_spec.rb
|
|
121
125
|
- spec/spec_helper.rb
|
|
122
126
|
- spec/transpose_spec.rb
|
|
123
127
|
- spec/wrong_filter_spec.rb
|
|
124
|
-
homepage: https://
|
|
128
|
+
homepage: https://framagit.org/Radoteur/shattered-machine
|
|
125
129
|
licenses:
|
|
126
130
|
- MIT
|
|
127
131
|
metadata: {}
|
|
@@ -133,14 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
133
137
|
requirements:
|
|
134
138
|
- - ">="
|
|
135
139
|
- !ruby/object:Gem::Version
|
|
136
|
-
version:
|
|
140
|
+
version: 2.0.0
|
|
137
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
142
|
requirements:
|
|
139
143
|
- - ">="
|
|
140
144
|
- !ruby/object:Gem::Version
|
|
141
|
-
version:
|
|
145
|
+
version: 1.8.11
|
|
142
146
|
requirements: []
|
|
143
|
-
rubygems_version: 3.
|
|
147
|
+
rubygems_version: 3.2.18
|
|
144
148
|
signing_key:
|
|
145
149
|
specification_version: 4
|
|
146
150
|
summary: Shattered Machine core engine
|
data/.yardoc/checksums
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
lib/shattered_machine.rb 5501f4ff757917169b063b04806ee16c0aa5ab2c
|
|
2
|
-
lib/shattered_machine/io.rb 02fface2a883b962a3c27ffba497af8aad184993
|
|
3
|
-
lib/shattered_machine/slim.rb 071024bd045684c8fcaa81499e924156f4b4df78
|
|
4
|
-
lib/shattered_machine/brush.rb d0c27748daffefd4b40ecee2feff395d1dd3a1da
|
|
5
|
-
lib/shattered_machine/defect.rb b2402bad054d51847fd3b83d597014e8e97a2fe8
|
|
6
|
-
lib/rusty_engine/rusty_engine.rb 17b075a2fc7fe87c63721eab953059b26ce01210
|
|
7
|
-
lib/shattered_machine/sampler.rb 7bf247a9ef6b34836cd45920f66122a786095a9e
|
|
8
|
-
lib/shattered_machine/exchange.rb fad77d3d75ee0652ec0ba2166f2ace56ef533bd3
|
|
9
|
-
lib/shattered_machine/glitcher.rb 071744286d68720fe47d7dfae2e033fdcff1cf69
|
|
10
|
-
lib/shattered_machine/converter.rb da5eeda73917386592612d0834a7c4d4467d5df2
|
|
11
|
-
lib/shattered_machine/transpose.rb 48a77c39cca754c222dd7719b4febc110da63c7a
|
|
12
|
-
lib/shattered_machine/change_byte.rb 445fc0f28fe02eaf83e711e1d616862128a86be4
|
|
13
|
-
lib/shattered_machine/pixel_sorter.rb 383dcd25a9f9253ce15b1849ae849ea94144757c
|
|
14
|
-
lib/shattered_machine/wrong_filter.rb 22131fb22b4bcda10b1251f3266801770e71861f
|
data/.yardoc/complete
DELETED
|
File without changes
|
data/.yardoc/object_types
DELETED
|
Binary file
|
data/.yardoc/objects/root.dat
DELETED
|
Binary file
|
data/.yardoc/proxy_types
DELETED
|
Binary file
|
|
@@ -1,111 +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
|
-
— 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> »
|
|
40
|
-
<span class='title'><span class='object_link'><a href="../ShatteredMachine.html" title="ShatteredMachine (module)">ShatteredMachine</a></span></span>
|
|
41
|
-
»
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
</div>
|
|
102
|
-
|
|
103
|
-
<div id="footer">
|
|
104
|
-
Generated on Sun May 23 13:30:10 2021 by
|
|
105
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
106
|
-
0.9.26 (ruby-2.6.6).
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
</div>
|
|
110
|
-
</body>
|
|
111
|
-
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ffi'
|
|
4
|
-
|
|
5
|
-
module ShatteredMachine
|
|
6
|
-
module RustyEngine
|
|
7
|
-
extend FFI::Library
|
|
8
|
-
lib_name = "librusty_engine.#{FFI::Platform::LIBSUFFIX}"
|
|
9
|
-
ffi_lib File.expand_path(lib_name, __dir__)
|
|
10
|
-
|
|
11
|
-
# Params : input output
|
|
12
|
-
attach_function :convert, %i[string string], :void, { blocking: true }
|
|
13
|
-
|
|
14
|
-
# Params : input output proba min max direction
|
|
15
|
-
# Directions : 1 -> horizontal
|
|
16
|
-
# 2 -> vertical
|
|
17
|
-
# 3 -> horizontal_inverted
|
|
18
|
-
# 4 -> vertical_inverted
|
|
19
|
-
attach_function :brush, %i[string string string string string string], :void, { blocking: true }
|
|
20
|
-
|
|
21
|
-
# Params : input, output, proba, probability_area, direction, colors, color_with_proba
|
|
22
|
-
# Directions : 1 -> up_to_down
|
|
23
|
-
# 2 -> down_to_up
|
|
24
|
-
# 3 -> left_to_right
|
|
25
|
-
# 4 -> right_to_left
|
|
26
|
-
attach_function :slim, %i[string string string string string string string], :void, { blocking: true }
|
|
27
|
-
|
|
28
|
-
# Params : input, output, direction, smart_sorting, detection_type, min, max, multiple_range, min_2, max_2, sorting_by
|
|
29
|
-
# directions : 0 -> up_to_down
|
|
30
|
-
# 1 -> down_to_up
|
|
31
|
-
# 2 -> left_to_right
|
|
32
|
-
# 3 -> right_to_left
|
|
33
|
-
# detection_type : 0 -> hues
|
|
34
|
-
# 1 -> colors
|
|
35
|
-
# sorting_by : 0 -> hue
|
|
36
|
-
# 1 -> saturation
|
|
37
|
-
attach_function :sort, %i[string string string string string string string string string string string], :void, { blocking: true }
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# rusty_engine.rb
|
|
4
|
-
require 'spec_helper'
|
|
5
|
-
|
|
6
|
-
RSpec.describe ShatteredMachine::RustyEngine do
|
|
7
|
-
describe '.convert' do
|
|
8
|
-
let(:converted_file) { 'spec/images/converted.png' }
|
|
9
|
-
subject { ShatteredMachine::RustyEngine.convert('spec/images/foo.jpg', converted_file) }
|
|
10
|
-
|
|
11
|
-
after do
|
|
12
|
-
File.delete(converted_file) if File.exist?(converted_file)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'convert image' do
|
|
16
|
-
subject
|
|
17
|
-
expect(File.exist?(converted_file)).to be true
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|