bitgen 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +304 -1
- data/Rakefile +1 -1
- data/lib/bitgen.rb +131 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02cf958fb6681cad6283d1face9ec2072ed49b27cb90d2bb32059699a0882c5d
|
4
|
+
data.tar.gz: dc7cfb96e82b7f16c7aa9ff7fcad31e84da8c0cc80dce037a874b1e3cc4c6a18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 910e7cf281efd19756244e6641cef2be923079d5929abf1107181eede076bc340aed09a4838604ea37917f102f61b0da33bcfc7d9f3fd9113c784116f6d78fe5
|
7
|
+
data.tar.gz: 3c76e587ba026d2c076d38d2165d4886030978ce61c3de6e827562d73727105614b8d27c74f872bb400c08fdfd5b3b1cbf9e8a6ce376a34b8f67df25e33d5eb1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,9 +12,312 @@ bitgen - bitcoin (inscription) generative image machinery incl gen-brc721 & co
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
|
15
|
+
### Generative BRC-721 (Gen BRC-721 or GBRC-721)
|
16
16
|
|
17
|
+
(historic) ordinal (bitcoin) protocol by [Jerry Fanelli](https://github.com/jerryfane) proposed / published in mid-May 2023
|
17
18
|
|
19
|
+
- Generative BRC-721 Proposol - <https://github.com/jerryfane/generative-brc-721>
|
20
|
+
- Analytics (Dune) Dashboard - <https://dune.com/j543/generative-brc-721>
|
21
|
+
|
22
|
+
|
23
|
+
note: Gen BRC-721 is ded. Jerry Fanelli proposed BRC-69 as
|
24
|
+
the official successor in July 2023
|
25
|
+
BUT yes, [Ordgen / ORC-721](https://github.com/ordbase/generative-orc-721) may be the better (generative) alternative protocol / winner.
|
26
|
+
|
27
|
+
|
28
|
+
Let's try some (historic) Gen BRC-721 collections...
|
29
|
+
|
30
|
+
|
31
|
+
#### Collection №1 - 1000 Ordibots (32×32px)
|
32
|
+
|
33
|
+
_The world's first gen-brc-721_
|
34
|
+
|
35
|
+
Find the deploy text @ [inscription no 8326719](https://ordinals.com/inscription/b7205d40f3b1b1486567f0d6e53ff2812983db4c03ad7d3606812cd150c64802i0) - May 21, 2023 by Jerry Fanelli.
|
36
|
+
|
37
|
+
|
38
|
+
Let's generate some ulta-rare never-before-seen (do-it-yourself) ordibots.
|
39
|
+
|
40
|
+
``` ruby
|
41
|
+
require 'bitgen'
|
42
|
+
|
43
|
+
## step 1: read in the deploy text (incl the base64-encoded generative images)
|
44
|
+
gen = Bitgen::Generator.read( './ordibots.json' )
|
45
|
+
|
46
|
+
|
47
|
+
## step 2: generate your images
|
48
|
+
bot = gen.generate( accessories: 'antenna',
|
49
|
+
body: 'gold-oval',
|
50
|
+
belly: 'chess',
|
51
|
+
face: 'happy'
|
52
|
+
)
|
53
|
+
|
54
|
+
bot.save( "./bot1.png" )
|
55
|
+
|
56
|
+
|
57
|
+
bot = gen.generate( background: 'bitcoin-orange',
|
58
|
+
accessories: 'rainbow',
|
59
|
+
body: 'standard-square',
|
60
|
+
belly: 'empty',
|
61
|
+
face: 'unimpressed'
|
62
|
+
)
|
63
|
+
|
64
|
+
bot.save( "./bot2.png" )
|
65
|
+
|
66
|
+
|
67
|
+
bot = gen.generate( background: 'bitcoin-orange',
|
68
|
+
accessories: 'rainbow',
|
69
|
+
body: 'black-and-white-triangular',
|
70
|
+
belly: 'square',
|
71
|
+
face: 'happy'
|
72
|
+
)
|
73
|
+
|
74
|
+
bot.save( "./bot3.png" )
|
75
|
+
```
|
76
|
+
|
77
|
+
resulting in:
|
78
|
+
|
79
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/bot1.png)
|
80
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/bot2.png)
|
81
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/bot3.png)
|
82
|
+
|
83
|
+
in 4x:
|
84
|
+
|
85
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/bot1@4x.png)
|
86
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/bot2@4x.png)
|
87
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/bot3@4x.png)
|
88
|
+
|
89
|
+
|
90
|
+
If you wonder what categories and names can I use?
|
91
|
+
Print the cheatsheet returned by `Catalog#cheat`.
|
92
|
+
|
93
|
+
|
94
|
+
``` ruby
|
95
|
+
catalog = Bitgen::Catalog.read( './ordibots.json' )
|
96
|
+
puts catalog.cheat
|
97
|
+
```
|
98
|
+
|
99
|
+
resulting in:
|
100
|
+
|
101
|
+
```
|
102
|
+
0 - background (4)
|
103
|
+
0 - blue
|
104
|
+
1 - bitcoin-orange
|
105
|
+
2 - brown
|
106
|
+
3 - purple
|
107
|
+
1 - accessories (3)
|
108
|
+
0 - antenna
|
109
|
+
1 - none
|
110
|
+
2 - rainbow
|
111
|
+
2 - body (9)
|
112
|
+
0 - standard-triangular
|
113
|
+
1 - standard-square
|
114
|
+
2 - standard-oval
|
115
|
+
3 - gold-oval
|
116
|
+
4 - black-and-white-square
|
117
|
+
5 - black-and-white-oval
|
118
|
+
6 - black-and-white-triangular
|
119
|
+
7 - gold-square
|
120
|
+
8 - gold-triangular
|
121
|
+
3 - belly (3)
|
122
|
+
0 - empty
|
123
|
+
1 - chess
|
124
|
+
2 - square
|
125
|
+
4 - face (7)
|
126
|
+
0 - happy
|
127
|
+
1 - neutral
|
128
|
+
2 - surprised
|
129
|
+
3 - unimpressed
|
130
|
+
4 - angry
|
131
|
+
5 - bored-green
|
132
|
+
6 - bored-red
|
133
|
+
```
|
134
|
+
|
135
|
+
Now if you wonder what do these look in pixels?
|
136
|
+
Export all images (in 1x and 8x) using `Catalog#export` for browsing
|
137
|
+
using your local image viewer / file explorer.
|
138
|
+
|
139
|
+
``` ruby
|
140
|
+
catalog = Bitgen::Catalog.read( './ordibots.json' )
|
141
|
+
catalog.export
|
142
|
+
```
|
143
|
+
|
144
|
+
resulting in:
|
145
|
+
|
146
|
+
```
|
147
|
+
/ordibots
|
148
|
+
+---0_background
|
149
|
+
| 0_blue.png
|
150
|
+
| 1_bitcoin-orange.png
|
151
|
+
| 2_brown.png
|
152
|
+
| 3_purple.png
|
153
|
+
|
|
154
|
+
+---1_accessories
|
155
|
+
| 0_antenna.png
|
156
|
+
| 1_none.png
|
157
|
+
| 2_rainbow.png
|
158
|
+
|
|
159
|
+
+---2_body
|
160
|
+
| 0_standard-triangular.png
|
161
|
+
| 1_standard-square.png
|
162
|
+
| 2_standard-oval.png
|
163
|
+
| 3_gold-oval.png
|
164
|
+
| 4_black-and-white-square.png
|
165
|
+
| 5_black-and-white-oval.png
|
166
|
+
| 6_black-and-white-triangular.png
|
167
|
+
| 7_gold-square.png
|
168
|
+
| 8_gold-triangular.png
|
169
|
+
|
|
170
|
+
+---3_belly
|
171
|
+
| 0_empty.png
|
172
|
+
| 1_chess.png
|
173
|
+
| 2_square.png
|
174
|
+
|
|
175
|
+
\---4_face
|
176
|
+
0_happy.png
|
177
|
+
1_neutral.png
|
178
|
+
2_surprised.png
|
179
|
+
3_unimpressed.png
|
180
|
+
4_angry.png
|
181
|
+
5_bored-green.png
|
182
|
+
6_bored-red.png
|
183
|
+
```
|
184
|
+
|
185
|
+
|
186
|
+
#### Collection №2 - 400 Satoshi's Pets (630×630px = 45×45px@14X)
|
187
|
+
|
188
|
+
_The world's second (?) gen-brc-721_
|
189
|
+
|
190
|
+
Find the deploy text @ [inscription no 9324087](https://ordinals.com/inscription/5a3488d19fec02c6629255a43f0615bfc1f4461d5087d6671a2222803966c871i0) - May 27, 2023 by Miek Brantovskii.
|
191
|
+
|
192
|
+
|
193
|
+
Let's generate some ulta-rare never-before-seen (do-it-yourself) satoshi's pets (cat, dog, mouse, rabbit, monkey).
|
194
|
+
|
195
|
+
``` ruby
|
196
|
+
require 'bitgen'
|
197
|
+
|
198
|
+
## step 1: read in the deploy text (incl the base64-encoded generative images)
|
199
|
+
gen = Bitgen::Generator.read( './satoshipets.json' )
|
200
|
+
|
201
|
+
## step 2: generate your images
|
202
|
+
pet = gen.generate( background: 'aube',
|
203
|
+
pets: 'monkey',
|
204
|
+
stuff: 'star',
|
205
|
+
eyes: 'normal'
|
206
|
+
)
|
207
|
+
|
208
|
+
pet.save( "./pet1.png" )
|
209
|
+
|
210
|
+
|
211
|
+
pet = gen.generate( background: 'twilight',
|
212
|
+
pets: 'rabbit',
|
213
|
+
stuff: 'rainbow',
|
214
|
+
eyes: 'mask'
|
215
|
+
)
|
216
|
+
|
217
|
+
pet.save( "./pet2.png" )
|
218
|
+
|
219
|
+
|
220
|
+
pet = gen.generate( pets: 'monkey',
|
221
|
+
eyes: 'normal'
|
222
|
+
)
|
223
|
+
|
224
|
+
pet.save( "./pet1a.png" )
|
225
|
+
|
226
|
+
|
227
|
+
pet = gen.generate( pets: 'rabbit',
|
228
|
+
eyes: 'mask'
|
229
|
+
)
|
230
|
+
|
231
|
+
pet.save( "./pet2a.png" )
|
232
|
+
```
|
233
|
+
|
234
|
+
resulting in:
|
235
|
+
|
236
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet1.png)
|
237
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet2.png)
|
238
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet1a.png)
|
239
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet2a.png)
|
240
|
+
|
241
|
+
4x
|
242
|
+
|
243
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet1@4x.png)
|
244
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet2@4x.png)
|
245
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet1a@4x.png)
|
246
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/pet2a@4x.png)
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
#### Collection №3 - 20 000 Blooming Flower (80×80px)
|
251
|
+
|
252
|
+
Find the deploy text @ [inscription no 17707699](https://ordinals.com/inscription/1a1427e31c91566fe7fb47d7f5c1b2130bea31219a08e1de794d45512319ee61i0) - July 17, 2023.
|
253
|
+
|
254
|
+
|
255
|
+
Let's generate some ulta-rare never-before-seen (do-it-yourself) blooming flowers.
|
256
|
+
|
257
|
+
``` ruby
|
258
|
+
require 'bitgen'
|
259
|
+
|
260
|
+
## step 1: read in the deploy text (incl the base64-encoded generative images)
|
261
|
+
gen = Bitgen::Generator.read( './blooming-flower.json' )
|
262
|
+
|
263
|
+
## step 2: generate your images
|
264
|
+
flower = gen.generate( background: 'new-moon',
|
265
|
+
window: 'simple-yellow',
|
266
|
+
table: 'metal',
|
267
|
+
flowerpot: 'ceramics-red',
|
268
|
+
rose: 'bud-red'
|
269
|
+
)
|
270
|
+
|
271
|
+
flower.save( "./flower1.png" )
|
272
|
+
|
273
|
+
|
274
|
+
flower = gen.generate( background: 'autumn',
|
275
|
+
window: 'sliding-yellow',
|
276
|
+
table: 'wood',
|
277
|
+
flowerpot: 'ceramics-blue',
|
278
|
+
rose: 'bud-white'
|
279
|
+
)
|
280
|
+
|
281
|
+
flower.save( "./flower2.png" )
|
282
|
+
|
283
|
+
|
284
|
+
flower = gen.generate( flowerpot: 'ceramics-red',
|
285
|
+
rose: 'bud-red'
|
286
|
+
)
|
287
|
+
|
288
|
+
flower.save( "./flower1a.png" )
|
289
|
+
|
290
|
+
|
291
|
+
flower = gen.generate( flowerpot: 'ceramics-blue',
|
292
|
+
rose: 'bud-white'
|
293
|
+
)
|
294
|
+
|
295
|
+
flower.save( "./flower2a.png" )
|
296
|
+
```
|
297
|
+
|
298
|
+
resulting in:
|
299
|
+
|
300
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower1.png)
|
301
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower2.png)
|
302
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower1a.png)
|
303
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower2a.png)
|
304
|
+
|
305
|
+
in 4x:
|
306
|
+
|
307
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower1@4x.png)
|
308
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower2@4x.png)
|
309
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower1a@4x.png)
|
310
|
+
![](https://github.com/ordbase/ordbase/raw/master/bitgen/i/flower2a@4x.png)
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
That's it. For more collections try:
|
316
|
+
|
317
|
+
- 1000 Ordi Bot Mrs (32×32) @ [inscribe no. 9893590](https://ordinals.com/inscription/fd0d94695fc30af6238732c2b71aa4330511c5d2dd0ace2da05660c2ad57076di0) - May 29th, 2023 by Kelvin Liang
|
318
|
+
- 4210 (GBRC721) Bit Punks (24×24) @ [inscribe no. 9950751](https://ordinals.com/inscription/c3915284759eaba761f6e5acf64b50e1089fe62448b595f61a40407d71bfb85ei0) - May 29th, 2023
|
319
|
+
- 690 Ordinals Egg (60×60) @ [inscribe no. 10265255](https://ordinals.com/inscription/15e0a8e0a6adde4388f14d6385db7ac63d55acb1c5a5b67aa4f8de3d5ad5dacci0) - May 31st, 2023
|
320
|
+
- 10 000 Unemployed Artist (24×24) @ [inscribe no. 11673452](https://ordinals.com/inscription/c11e21e4ac155b88d8cc4cb7e11d8c4f66112e95cac04c4cb14e9361d93aac16i0) - June 13th, 2023
|
18
321
|
|
19
322
|
|
20
323
|
|
data/Rakefile
CHANGED
data/lib/bitgen.rb
CHANGED
@@ -1,2 +1,132 @@
|
|
1
|
+
require 'pixelart'
|
2
|
+
|
3
|
+
|
4
|
+
module Bitgen
|
5
|
+
|
6
|
+
class Catalog ## change/rename to Spritesheet / Atlas / Deploy or such - why? why not?
|
7
|
+
def self.read( path )
|
8
|
+
data = read_json( path )
|
9
|
+
# pp data
|
10
|
+
|
11
|
+
meta = {
|
12
|
+
'slug' => data['slug'].downcase, ## note: always downcase slug for now (e.g. OrdinalsEgg => ordinalsegg)
|
13
|
+
'name' => data['name'],
|
14
|
+
'dim' => data['dim']
|
15
|
+
}
|
16
|
+
|
17
|
+
attributes = {}
|
18
|
+
|
19
|
+
## note: use/access via trait_types array
|
20
|
+
## for (restoring insertion) order!!!
|
21
|
+
data['trait_types'].each do |category_name|
|
22
|
+
h = data['traits'][category_name]
|
23
|
+
puts "==> #{category_name} - #{h.size} record(s)..."
|
24
|
+
|
25
|
+
h.each_with_index do |(name, h), i|
|
26
|
+
puts " #{i} - #{name} (#{h['name']}):"
|
27
|
+
|
28
|
+
img = Image.parse_base64( h['base64'] )
|
29
|
+
|
30
|
+
## note: always downcase category_name for now
|
31
|
+
## (e.g. Background => background in OrdinalsEgg for example)
|
32
|
+
cat = attributes[ category_name.downcase ] ||= {}
|
33
|
+
cat[ name ] = img
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
new( meta: meta,
|
39
|
+
attributes: attributes )
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize( meta: {},
|
43
|
+
attributes: {} )
|
44
|
+
@meta = meta
|
45
|
+
@attributes = attributes
|
46
|
+
end
|
47
|
+
|
48
|
+
def name() @meta['name']; end
|
49
|
+
def slug() @meta['slug']; end
|
50
|
+
|
51
|
+
def dim() @meta['dim']; end
|
52
|
+
def width() @meta['dim'] ? @meta['dim'][0] : nil; end
|
53
|
+
def height() @meta['dim'] ? @meta['dim'][1] : nil; end
|
54
|
+
|
55
|
+
|
56
|
+
def categories() @attributes.keys; end
|
57
|
+
def [](name) @attributes[name]; end
|
58
|
+
|
59
|
+
def cheat ## print cheat sheet
|
60
|
+
buf = ''
|
61
|
+
@attributes.each_with_index do |(category_name, cat),i|
|
62
|
+
buf << "#{i} - #{category_name} (#{cat.size})\n"
|
63
|
+
cat.each_with_index do |(attribute_name, _),j|
|
64
|
+
buf << " #{j} - #{attribute_name}\n"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
buf
|
68
|
+
end
|
69
|
+
|
70
|
+
def export
|
71
|
+
@attributes.each_with_index do |(category_name, cat),i|
|
72
|
+
puts "==> #{category_name} - #{cat.size} record(s)..."
|
73
|
+
cat.each_with_index do |(attribute_name, img), j|
|
74
|
+
puts " #{j} - #{attribute_name} (#{img.width}x#{img.height})"
|
75
|
+
|
76
|
+
path = "./tmp/#{slug}/#{i}_#{category_name}/#{j}_#{attribute_name}"
|
77
|
+
puts path
|
78
|
+
|
79
|
+
img.save( path+".png" )
|
80
|
+
## note - only auto-add zoom if width < 100px
|
81
|
+
## e.g. sathoshi's pet is 630px
|
82
|
+
img.zoom(8).save( path+"@8x.png" ) if img.width < 100
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end # method export
|
86
|
+
end # class Catalog
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
class Generator
|
91
|
+
def self.read( path )
|
92
|
+
catalog = Catalog.read( path )
|
93
|
+
new( catalog )
|
94
|
+
end
|
95
|
+
|
96
|
+
attr_reader :catalog
|
97
|
+
|
98
|
+
def initialize( catalog )
|
99
|
+
@catalog = catalog
|
100
|
+
end
|
101
|
+
|
102
|
+
def generate( **kwargs )
|
103
|
+
img = nil
|
104
|
+
kwargs.each do |category, name|
|
105
|
+
cat = @catalog[ category.to_s]
|
106
|
+
attribute_img = cat[name.to_s]
|
107
|
+
|
108
|
+
if attribute_img.nil?
|
109
|
+
puts "!! WARN - attribute >#{name}< in >#{category}< not found; sorry"
|
110
|
+
puts " availbable options in #{category}:"
|
111
|
+
pp cat.keys
|
112
|
+
end
|
113
|
+
|
114
|
+
img = Image.new( attribute_img.width, attribute_img.height ) if img.nil?
|
115
|
+
|
116
|
+
img.compose!( attribute_img )
|
117
|
+
end
|
118
|
+
img
|
119
|
+
end # method generate
|
120
|
+
|
121
|
+
################
|
122
|
+
## more convenience helpers
|
123
|
+
def cheat() @catalog.cheat; end
|
124
|
+
|
125
|
+
end # class Generator
|
126
|
+
|
127
|
+
end # module Bitgen
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
1
132
|
|
2
|
-
puts "hello, bitgen!"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pixelart
|