ruby_spriter 0.6.7.1 → 0.7.0.1
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/.rspec +3 -3
- data/CHANGELOG.md +1035 -524
- data/Gemfile +17 -17
- data/LICENSE +21 -21
- data/README.md +183 -950
- data/bin/ruby_spriter +20 -20
- data/lib/ruby_spriter/background_sampler.rb +140 -0
- data/lib/ruby_spriter/batch_processor.rb +268 -214
- data/lib/ruby_spriter/cell_cleanup_config.rb +21 -0
- data/lib/ruby_spriter/cell_cleanup_gimp_script.rb +123 -0
- data/lib/ruby_spriter/cell_cleanup_processor.rb +230 -0
- data/lib/ruby_spriter/cli.rb +676 -612
- data/lib/ruby_spriter/compression_manager.rb +101 -101
- data/lib/ruby_spriter/consolidator.rb +179 -179
- data/lib/ruby_spriter/dependency_checker.rb +224 -224
- data/lib/ruby_spriter/ghost_edge_cleaner.rb +164 -0
- data/lib/ruby_spriter/gimp_processor.rb +1188 -1058
- data/lib/ruby_spriter/metadata_manager.rb +117 -116
- data/lib/ruby_spriter/platform.rb +137 -137
- data/lib/ruby_spriter/processor.rb +1230 -891
- data/lib/ruby_spriter/smoke_detector.rb +223 -0
- data/lib/ruby_spriter/threshold_stepper.rb +227 -0
- data/lib/ruby_spriter/utils/file_helper.rb +82 -82
- data/lib/ruby_spriter/utils/image_helper.rb +16 -0
- data/lib/ruby_spriter/utils/output_formatter.rb +65 -65
- data/lib/ruby_spriter/utils/path_helper.rb +59 -59
- data/lib/ruby_spriter/utils/spritesheet_splitter.rb +86 -86
- data/lib/ruby_spriter/version.rb +6 -7
- data/lib/ruby_spriter/video_processor.rb +357 -139
- data/lib/ruby_spriter.rb +38 -34
- data/ruby_spriter.gemspec +44 -42
- data/spec/fixtures/centered_sprite_with_inner_bg.png +0 -0
- data/spec/fixtures/centered_sprite_with_inner_bg_inner_removed.png +0 -0
- data/spec/fixtures/centered_sprite_with_inner_bg_threshold_stepped.png +0 -0
- data/spec/fixtures/complex_background_sprite.png +0 -0
- data/spec/fixtures/death - bloodborne rekconing.mp4 +0 -0
- data/spec/fixtures/death - bloodborne rekconing_spritesheet-nobg-global.png +0 -0
- data/spec/fixtures/death - bloodborne rekconing_spritesheet.png +0 -0
- data/spec/fixtures/death - bloodborne rekconing_spritesheet_20251110_185027_431-nobg-global.png +0 -0
- data/spec/fixtures/death - bloodborne rekconing_spritesheet_20251110_185027_431.png +0 -0
- data/spec/fixtures/death - bloodborne rekconing_spritesheet_20251110_185125_738-nobg-global.png +0 -0
- data/spec/fixtures/death - bloodborne rekconing_spritesheet_20251110_185125_738.png +0 -0
- data/spec/fixtures/has_inner_bg.png +0 -0
- data/spec/fixtures/has_small_inner_bg.png +0 -0
- data/spec/fixtures/smoke_effect_sprite.png +0 -0
- data/spec/fixtures/spritesheet_with_metadata.png +0 -0
- data/spec/fixtures/test_sprite.png +0 -0
- data/spec/fixtures/test_sprite_smoke_processed.png +0 -0
- data/spec/fixtures/test_video_spritesheet.png +0 -0
- data/spec/fixtures/transparent_bg_sprite.png +0 -0
- data/spec/fixtures/walk_north_sprite-sheet.png +0 -0
- data/spec/integration/no_fuzzy_mode_spec.rb +100 -0
- data/spec/ruby_spriter/batch_processor_spec.rb +509 -200
- data/spec/ruby_spriter/cli_spec.rb +2026 -1892
- data/spec/ruby_spriter/compression_manager_spec.rb +157 -157
- data/spec/ruby_spriter/consolidator_spec.rb +538 -538
- data/spec/ruby_spriter/gimp_processor_spec.rb +523 -425
- data/spec/ruby_spriter/platform_spec.rb +92 -92
- data/spec/ruby_spriter/processor_spec.rb +911 -735
- data/spec/ruby_spriter/utils/file_helper_spec.rb +150 -150
- data/spec/ruby_spriter/utils/path_helper_spec.rb +78 -78
- data/spec/ruby_spriter/utils/spritesheet_splitter_spec.rb +104 -104
- data/spec/ruby_spriter/video_processor_spec.rb +346 -29
- data/spec/spec_helper.rb +41 -41
- data/spec/tmp/cli_test_output.png +0 -0
- data/spec/tmp/cli_test_output_20251105_114647_395.png +0 -0
- data/spec/tmp/combined_test.png +0 -0
- data/spec/tmp/compat_test.png +0 -0
- data/spec/tmp/compat_test_20251030_174233_361.png +0 -0
- data/spec/tmp/final_all_features.png +0 -0
- data/spec/tmp/final_test_all_features.png +0 -0
- data/spec/tmp/full_pipeline_test.png +0 -0
- data/spec/tmp/inner_test.png +0 -0
- data/spec/tmp/integration_test.png +0 -0
- data/spec/tmp/validation_test.png +0 -0
- data/spec/unit/background_sampler_spec.rb +132 -0
- data/spec/unit/cell_cleanup_config_spec.rb +32 -0
- data/spec/unit/cell_cleanup_gimp_script_spec.rb +59 -0
- data/spec/unit/cell_cleanup_processor_spec.rb +261 -0
- data/spec/unit/ghost_edge_cleaner_spec.rb +223 -0
- data/spec/unit/gimp_processor_single_point_selection_spec.rb +81 -0
- data/spec/unit/smoke_detector_spec.rb +246 -0
- data/spec/unit/threshold_stepper_spec.rb +195 -0
- metadata +56 -10
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/spec/fixtures/death - bloodborne rekconing_spritesheet_20251110_185027_431-nobg-global.png
ADDED
|
Binary file
|
|
Binary file
|
data/spec/fixtures/death - bloodborne rekconing_spritesheet_20251110_185125_738-nobg-global.png
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'ruby_spriter/gimp_processor'
|
|
3
|
+
require 'ruby_spriter/background_sampler'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'No-Fuzzy Mode Integration' do
|
|
6
|
+
let(:gimp_path) { 'gimp-console' }
|
|
7
|
+
let(:input_file) { 'spec/fixtures/walk_north_sprite-sheet.png' }
|
|
8
|
+
let(:output_file) { 'spec/tmp/no_fuzzy_output.png' }
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
FileUtils.mkdir_p(File.dirname(output_file))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
after do
|
|
15
|
+
FileUtils.rm_f(output_file) if File.exist?(output_file)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'GimpProcessor with --no-fuzzy mode' do
|
|
19
|
+
it 'generates script with global select at (5,5) plus additional background colors' do
|
|
20
|
+
options = {
|
|
21
|
+
remove_bg: true,
|
|
22
|
+
fuzzy_select: false,
|
|
23
|
+
bg_sample_offset: 5,
|
|
24
|
+
bg_sample_count: 10
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
processor = RubySpriter::GimpProcessor.new(gimp_path, options)
|
|
28
|
+
|
|
29
|
+
# Collect background colors
|
|
30
|
+
sampler = RubySpriter::BackgroundSampler.new(input_file, 5, 10, 20)
|
|
31
|
+
background_colors = sampler.collect_unique_colors
|
|
32
|
+
|
|
33
|
+
expect(background_colors).not_to be_empty
|
|
34
|
+
|
|
35
|
+
# Generate script with background colors
|
|
36
|
+
script = processor.send(:generate_remove_bg_script, input_file, output_file, background_colors)
|
|
37
|
+
|
|
38
|
+
# Should include single-point global select at (5,5)
|
|
39
|
+
expect(script).to include('x = 5')
|
|
40
|
+
expect(script).to include('y = 5')
|
|
41
|
+
expect(script).to include('gimp-image-select-color')
|
|
42
|
+
|
|
43
|
+
# Should include global color select for inner backgrounds
|
|
44
|
+
expect(script).to include('Selecting inner background colors')
|
|
45
|
+
expect(script).to include('gimp-image-select-color')
|
|
46
|
+
expect(script).to include('Gimp.ChannelOps.ADD')
|
|
47
|
+
|
|
48
|
+
# Should include the background colors in Python dict format
|
|
49
|
+
colors_pattern = background_colors.map { |c| "{'r': #{c[:r]}, 'g': #{c[:g]}, 'b': #{c[:b]}}" }.join(', ')
|
|
50
|
+
expect(script).to include("[#{colors_pattern}]")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'does not include global select when fuzzy_select is true' do
|
|
54
|
+
options = {
|
|
55
|
+
remove_bg: true,
|
|
56
|
+
fuzzy_select: true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
processor = RubySpriter::GimpProcessor.new(gimp_path, options)
|
|
60
|
+
script = processor.send(:generate_remove_bg_script, input_file, output_file, nil)
|
|
61
|
+
|
|
62
|
+
# Should include fuzzy select
|
|
63
|
+
expect(script).to include('gimp-image-select-contiguous-color')
|
|
64
|
+
|
|
65
|
+
# Should NOT include global color select for inner backgrounds
|
|
66
|
+
expect(script).not_to include('Selecting inner background colors')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'handles empty background_colors array gracefully' do
|
|
70
|
+
options = {
|
|
71
|
+
remove_bg: true,
|
|
72
|
+
fuzzy_select: false
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
processor = RubySpriter::GimpProcessor.new(gimp_path, options)
|
|
76
|
+
script = processor.send(:generate_remove_bg_script, input_file, output_file, [])
|
|
77
|
+
|
|
78
|
+
# Should still work with just global select at (5,5)
|
|
79
|
+
expect(script).to include('gimp-image-select-color')
|
|
80
|
+
expect(script).not_to include('Selecting inner background colors')
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe 'BackgroundSampler integration' do
|
|
85
|
+
it 'collects colors from the test image' do
|
|
86
|
+
sampler = RubySpriter::BackgroundSampler.new(input_file, 5, 10, 20)
|
|
87
|
+
colors = sampler.collect_unique_colors
|
|
88
|
+
|
|
89
|
+
expect(colors).to be_an(Array)
|
|
90
|
+
expect(colors.length).to be > 0
|
|
91
|
+
expect(colors.length).to be <= 10
|
|
92
|
+
|
|
93
|
+
colors.each do |color|
|
|
94
|
+
expect(color).to have_key(:r)
|
|
95
|
+
expect(color).to have_key(:g)
|
|
96
|
+
expect(color).to have_key(:b)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|