artbase 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 549b31d6f628fcb714c22fd03f179b75fd9b99e9c2bbe8532b1e79660e4f1ade
4
- data.tar.gz: aadb6b67430375da20a83e94362562405dfca370dac2b8cfe514086a926ff2df
3
+ metadata.gz: 28781910e6461bf7c03b8c27a1845633c07681798180edd50f873ec029b9921f
4
+ data.tar.gz: c19bf7185dfbfe51c0f7ab14b25f4dbecd29314b0ca6088660ab55b4a4c5d40c
5
5
  SHA512:
6
- metadata.gz: c7d1a745322df0250841c03975135d35f0f4ab4a9b8258e36482258e14b1847cece236b09755fd8962b6e942b21ed1ee5b28449c0d0b4d32f9f3c7c08e508533
7
- data.tar.gz: 735c9079a101dd5aea55d5cb8458256082864e07bcaef81dff178cdeabb583df381ff9880d6aca7871c094a7f529342a9a206f4a4d877efe9c9b6b6b2600c27f
6
+ metadata.gz: 17b24d4328ba8fac495134954a686b59324e7f635d878c2b1ce1c085ad9b21a3a767f87773d7dfccdb7516c47a9cf57621bec10e11daab16ae8610c2670f7ed3
7
+ data.tar.gz: e009b91051805e13358b6cb172e32ce256f04d03d0eda912dc7f6b73c35a58c6d556c4e9cb301ac8f4f88aa8d9d6e43bf6b376e2509ae856689d7224584f6bee
@@ -34,11 +34,17 @@ end
34
34
 
35
35
 
36
36
 
37
- def make_composite
37
+ def make_composite( limit: nil,
38
+ mirror: false )
38
39
  ### use well-known / pre-defined (default) grids
39
40
  ## (cols x rows) for now - why? why not?
40
41
 
41
- composite_count = @count - @excludes.size
42
+ composite_count = if limit
43
+ limit
44
+ else
45
+ @count - @excludes.size
46
+ end
47
+
42
48
  cols, rows = case composite_count
43
49
  when 99 then [10, 10]
44
50
  when 100 then [10, 10]
@@ -59,6 +65,7 @@ def make_composite
59
65
  when 6666 then [100, 67] # 6700 (34 left empty)
60
66
  when 6688 then [100, 67] # 6700 (12 left empty)
61
67
  when 6969 then [100, 70] # 7000 (31 left empty)
68
+ when 7500 then [100, 75]
62
69
  when 8888 then [100, 89]
63
70
  when 9969 then [100,100]
64
71
  when 10000 then [100,100]
@@ -70,17 +77,33 @@ def make_composite
70
77
  width: @width,
71
78
  height: @height )
72
79
 
80
+
81
+ count = 0
73
82
  each_image do |img, id|
74
83
  puts "==> #{id}"
75
- composite << img
84
+ composite << if mirror
85
+ img.mirror
86
+ else
87
+ img
88
+ end
89
+
90
+ count += 1
91
+ break if limit && count >= limit
76
92
  end
77
93
 
78
94
 
95
+ slug = "#{@slug}"
96
+ slug += "#{limit}" if limit
97
+ slug += "_left" if mirror
79
98
 
80
- composite.save( "./#{@slug}/tmp/#{@slug}-#{@width}x#{@height}.png" )
99
+ path = "./#{@slug}/tmp/#{slug}-#{@width}x#{@height}.png"
100
+ puts " saving #{path}..."
101
+ composite.save( path )
81
102
 
82
103
  if composite_count < 1000
83
- composite.zoom(2).save( "./#{@slug}/tmp/#{@slug}-#{@width}x#{@height}@2x.png" )
104
+ path = "./#{@slug}/tmp/#{slug}-#{@width}x#{@height}@2x.png"
105
+ puts " saving 2x #{path}..."
106
+ composite.zoom(2).save( path )
84
107
  end
85
108
  end
86
109
 
@@ -177,7 +177,8 @@ end
177
177
  def pixelate( range=_range, exclude: true,
178
178
  force: false,
179
179
  debug: false,
180
- zoom: nil )
180
+ zoom: nil,
181
+ faster: false )
181
182
 
182
183
  range.each do |id|
183
184
 
@@ -197,6 +198,32 @@ end
197
198
 
198
199
 
199
200
  puts "==> #{id} - reading / decoding #{id} ..."
201
+
202
+
203
+ if faster
204
+ ## note: faster for now only supports
205
+ ## single /one source format
206
+ ## always will use first source format from array for now
207
+ cmd = "./pixelator "
208
+ cmd << "./#{@slug}/token-i/#{id}.png"
209
+ cmd << " " + @sources[0][0].to_s
210
+ cmd << " " + @sources[0][1].to_s
211
+ cmd << " " + outpath
212
+ cmd << " " + @width.to_s
213
+ cmd << " " + @height.to_s
214
+ puts "==> #{cmd}..."
215
+ ret = system( cmd )
216
+ if ret
217
+ puts "OK"
218
+ else
219
+ puts "!! FAIL"
220
+ if ret.nil?
221
+ puts " command not found"
222
+ else
223
+ puts " exit code: #{$?}"
224
+ end
225
+ end
226
+ else
200
227
  start = Time.now
201
228
 
202
229
  img = Image.read( "./#{@slug}/token-i/#{id}.png" )
@@ -246,6 +273,7 @@ end
246
273
  exit 1
247
274
  end
248
275
  end
276
+ end
249
277
  end
250
278
 
251
279
 
data/lib/artbase/tool.rb CHANGED
@@ -16,7 +16,11 @@ class Tool
16
16
  puts "==> welcome to collection tool with args:"
17
17
  pp args
18
18
 
19
- options = { }
19
+
20
+ options = { faster: false,
21
+ mirror: false,
22
+ }
23
+
20
24
  parser = OptionParser.new do |opts|
21
25
 
22
26
  opts.on("--offset NUM", Integer,
@@ -35,6 +39,15 @@ class Tool
35
39
  ## options[ :range] = range
36
40
  ## end
37
41
 
42
+ opts.on( "--faster", "Use faster (optional) pixelate binary (default: false)") do
43
+ options[ :faster ] = true
44
+ end
45
+
46
+ opts.on( "--mirror", "Mirror (or flip) images (default: false)" ) do
47
+ options[ :mirror ] = true
48
+ end
49
+
50
+
38
51
  opts.on("-h", "--help", "Prints this help") do
39
52
  puts opts
40
53
  exit
@@ -58,23 +71,41 @@ class Tool
58
71
  command = args[1]
59
72
  subcommand = args[2]
60
73
 
61
-
62
- path = if File.exist?( "./#{name}/config.rb" )
63
- "./#{name}/config.rb"
64
- else
65
- "./#{name}/collection.rb"
66
- end
67
- puts "==> reading collection config >#{path}<..."
68
-
69
- ## note: assume for now global const COLLECTION gets set/defined!!!
70
- ## use/change to a script/dsl loader/eval later!!!
71
- load( path )
72
-
73
- ## pp COLLECTION
74
-
75
- ## configure collection (note: requires self)
76
- self.collection = COLLECTION
77
-
74
+ if File.exist?( "./#{name}/collection.yml" )
75
+ path = "./#{name}/collection.yml"
76
+ puts "==> reading collection config >#{path}<..."
77
+ config = read_yaml( path )
78
+
79
+ ## todo - use TokenCollection.read( ) or such -- why? why not?
80
+ ## or TokenCollection.build( hash ) ?? - why? why not?
81
+ self.collection = TokenCollection.new(
82
+ config['slug'],
83
+ config['count'],
84
+ token_base: config['token_base'],
85
+ image_base: config['image_base'],
86
+ format: config['format'],
87
+ source: config['source'],
88
+ offset: config['offset'] || 0
89
+ )
90
+ else
91
+ ## todo/check: keep config.rb alternate name - why? why not?
92
+ ## or use collection.rb only ???
93
+ path = if File.exist?( "./#{name}/config.rb" )
94
+ "./#{name}/config.rb"
95
+ else
96
+ "./#{name}/collection.rb"
97
+ end
98
+ puts "==> reading collection config >#{path}<..."
99
+
100
+ ## note: assume for now global const COLLECTION gets set/defined!!!
101
+ ## use/change to a script/dsl loader/eval later!!!
102
+ load( path )
103
+
104
+ ## pp COLLECTION
105
+
106
+ ## configure collection (note: requires self)
107
+ self.collection = COLLECTION
108
+ end
78
109
 
79
110
  if ['d','dl','down', 'download'].include?( command )
80
111
  if subcommand
@@ -88,7 +119,8 @@ class Tool
88
119
  download_images
89
120
  end
90
121
  elsif ['p', 'px', 'pix', 'pixel', 'pixelate'].include?( command )
91
- pixelate( offset: options[ :offset] )
122
+ pixelate( offset: options[ :offset],
123
+ faster: options[ :faster] )
92
124
  elsif ['m', 'meta'].include?( command )
93
125
  download_meta( offset: options[ :offset] )
94
126
  elsif ['i', 'img', 'image', 'images'].include?( command )
@@ -100,7 +132,8 @@ class Tool
100
132
  elsif ['x', 'exp', 'export'].include?( command )
101
133
  export_attributes
102
134
  elsif ['c', 'composite'].include?( command )
103
- make_composite
135
+ make_composite( limit: options[ :limit],
136
+ mirror: options[ :mirror ])
104
137
  elsif ['strip'].include?( command )
105
138
  make_strip
106
139
  elsif ['t', 'test'].include?( command )
@@ -112,9 +145,9 @@ class Tool
112
145
  puts "bye"
113
146
  end
114
147
 
115
- def self.make_composite
148
+ def self.make_composite( limit: nil, mirror: false )
116
149
  puts "==> make composite"
117
- @collection.make_composite
150
+ @collection.make_composite( limit: limit, mirror: mirror )
118
151
  end
119
152
 
120
153
  def self.convert_images
@@ -165,7 +198,9 @@ class Tool
165
198
  @collection.download_images( range )
166
199
  end
167
200
 
168
- def self.pixelate( offset: )
201
+
202
+ def self.pixelate( offset:,
203
+ faster: )
169
204
  puts "==> pixelate"
170
205
 
171
206
  range = if offset
@@ -174,7 +209,7 @@ class Tool
174
209
  @collection._range
175
210
  end
176
211
 
177
- @collection.pixelate( range )
212
+ @collection.pixelate( range, faster: faster )
178
213
  end
179
214
  end # class Tool
180
215
 
@@ -3,7 +3,7 @@
3
3
  module Artbase
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- PATCH = 1
6
+ PATCH = 2
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos