cryptopunks 2024.2.29 → 2024.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +0 -1
- data/README.md +33 -29
- data/Rakefile +2 -2
- data/lib/cryptopunks/tool.rb +141 -202
- data/lib/cryptopunks/version.rb +2 -2
- data/lib/cryptopunks.rb +1 -2
- metadata +11 -10
- data/lib/cryptopunks/composite.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fc2a706ce8c4e9ec5947d4bde3a88b4529b1d3af04b092a71de20bbdd28bca6
|
4
|
+
data.tar.gz: 03f0600b6564f8d1d25fccf624adca0bd38b38c52754135aae9dd8b04d63e4b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dced1456b9cb0755cc9ec34c8efede1c6d355ce93ff2b295b0dec2b354f6e0d982ec7390e2a1823377cf6f551519e14786507a24d59b8a297c5d8c80ecedd2b0
|
7
|
+
data.tar.gz: '088061933c9355d88ea903fbc6e679b938d8cce1b4176919ffda66cc750efb53f300bac149bc42c9214934e617d8378d124e491be960aec1d338f6ed0a92ee0c'
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
|
34
34
|
# Crypto Punks
|
35
35
|
|
36
|
-
cryptopunks - generate your own 24×24 pixel punk images (
|
36
|
+
cryptopunks - generate your own 24×24 pixel punk images from text prompts incl. 2x/4x/8x zoom for bigger sizes (or crop 'n' save tiles from all-in-one composites incl. the True Official Matt & John's® Punks sha256-verified original 10 000 unique character collection)
|
37
37
|
|
38
38
|
* home :: [github.com/cryptopunksnotdead/cryptopunks](https://github.com/cryptopunksnotdead/cryptopunks)
|
39
39
|
* bugs :: [github.com/cryptopunksnotdead/cryptopunks/issues](https://github.com/cryptopunksnotdead/cryptopunks/issues)
|
@@ -67,24 +67,23 @@ VERSION
|
|
67
67
|
3.0.0
|
68
68
|
|
69
69
|
GLOBAL OPTIONS
|
70
|
-
-
|
71
|
-
-
|
72
|
-
|
73
|
-
|
74
|
-
--
|
75
|
-
|
76
|
-
|
77
|
-
-z, --zoom=ZOOM - Zoom factor x2, x4, x8, etc. (default: 1)
|
70
|
+
-o, --out, --dir, --outdir=DIR - Output directory (default: .)
|
71
|
+
-f, --file=FILE - All-in-one
|
72
|
+
composite image (default: ./punks.png)
|
73
|
+
--offset=NUM - Start counting at offset (default: 0)
|
74
|
+
--seed=NUM - Seed for random number generation /
|
75
|
+
shuffle (default: 4142)
|
76
|
+
-z, --zoom=NUM - Zoom factor x2, x4, x8, etc. (default: 1)
|
78
77
|
|
79
|
-
--help
|
80
|
-
--version
|
81
|
-
--verbose
|
78
|
+
--help - Show this message
|
79
|
+
--version - Display the program version
|
80
|
+
--verbose - (Debug) Show debug messages
|
82
81
|
|
83
82
|
|
84
83
|
COMMANDS
|
85
|
-
g, gen,
|
84
|
+
g, gen, - Generate punk characters from text attributes (from
|
86
85
|
scratch / zero) via builtin punk spritesheet
|
87
|
-
l, ls
|
86
|
+
l, ls - List all punk archetype and attribute names from builtin
|
88
87
|
punk spritesheet
|
89
88
|
q, query - Query (builtin off-chain) punk contract for punk text
|
90
89
|
attributes by IDs - use 0 to 9999
|
@@ -107,7 +106,7 @@ _Generate punk characters from text attributes (from scratch / zero) via builtin
|
|
107
106
|
Let's try punk #0:
|
108
107
|
|
109
108
|
```
|
110
|
-
$ punk
|
109
|
+
$ punk gen female_2 earring blonde_bob green_eye_shadow
|
111
110
|
```
|
112
111
|
|
113
112
|
resulting in:
|
@@ -117,9 +116,9 @@ resulting in:
|
|
117
116
|
Let's try the `-z/--zoom` factor 2x, 4x, 8x, etc.:
|
118
117
|
|
119
118
|
```
|
120
|
-
$ punk --zoom
|
119
|
+
$ punk --zoom=4 gen female_2 earring blonde_bob green_eye_shadow
|
121
120
|
# -or-
|
122
|
-
$ punk -
|
121
|
+
$ punk -z4 g female_2 earring blonde_bob green_eye_shadow
|
123
122
|
```
|
124
123
|
|
125
124
|
resulting in:
|
@@ -132,8 +131,8 @@ resulting in:
|
|
132
131
|
Let's try never-before-seen super-rare punks:
|
133
132
|
|
134
133
|
```
|
135
|
-
$ punk
|
136
|
-
$ punk
|
134
|
+
$ punk gen demon heart_shades
|
135
|
+
$ punk gen vampire_female wild_hair
|
137
136
|
```
|
138
137
|
|
139
138
|
resulting in:
|
@@ -156,9 +155,9 @@ _List all punk archetype and attribute names from builtin punk spritesheet_
|
|
156
155
|
Let's try:
|
157
156
|
|
158
157
|
```
|
159
|
-
$ punk list
|
160
|
-
# -or-
|
161
158
|
$ punk ls
|
159
|
+
# -or-
|
160
|
+
$ punk l
|
162
161
|
```
|
163
162
|
|
164
163
|
resulting in:
|
@@ -391,7 +390,7 @@ And voila!
|
|
391
390
|
Let's give it a try. Let's save punk #0, #2890, and #8219 in 2x format:
|
392
391
|
|
393
392
|
```
|
394
|
-
$ punk --zoom
|
393
|
+
$ punk --zoom=2 tile 0 2890 8219
|
395
394
|
# -or-
|
396
395
|
$ punk -z2 t 0 2890 8219
|
397
396
|
```
|
@@ -456,7 +455,7 @@ and let's add an offset of 10000
|
|
456
455
|
(to start counting at 10000 instead of 0):
|
457
456
|
|
458
457
|
```
|
459
|
-
$ punk --file
|
458
|
+
$ punk --file=./more-punks-1.png --offset=10000 tile 0 18 40 88
|
460
459
|
```
|
461
460
|
|
462
461
|
printing:
|
@@ -500,7 +499,7 @@ and let's add an offset of 10100
|
|
500
499
|
(to start counting at 10000 plus 100 instead of 0):
|
501
500
|
|
502
501
|
```
|
503
|
-
$ punk --file
|
502
|
+
$ punk --file=./more-punks-2.png --offset=10100 tile 0 79 80 90
|
504
503
|
```
|
505
504
|
|
506
505
|
printing:
|
@@ -550,7 +549,7 @@ all punks. Phree the phunks! Let's give it a try:
|
|
550
549
|
```
|
551
550
|
$ punk flip
|
552
551
|
# - same as -
|
553
|
-
$ punk --file
|
552
|
+
$ punk --file=./punks.png flip
|
554
553
|
```
|
555
554
|
|
556
555
|
printing:
|
@@ -571,7 +570,7 @@ Yes, you can. Use any all-in-one composite image in the 24x24 format. Use the `
|
|
571
570
|
Example - let's flip the 1000 More Punks collection:
|
572
571
|
|
573
572
|
```
|
574
|
-
$ punk --file
|
573
|
+
$ punk --file=./morepunks.png flip
|
575
574
|
```
|
576
575
|
|
577
576
|
And so on.
|
@@ -590,7 +589,7 @@ Let's give it a try:
|
|
590
589
|
```
|
591
590
|
$ punk shuffle
|
592
591
|
# - same as -
|
593
|
-
$ punk --file
|
592
|
+
$ punk --file=./punks.png --seed=4142 shuffle
|
594
593
|
```
|
595
594
|
|
596
595
|
printing:
|
@@ -630,7 +629,7 @@ Yes, you can. Use any all-in-one composite image in the 24x24 format. Use the `
|
|
630
629
|
Example - let's shuffle the 1000 More Punks collection:
|
631
630
|
|
632
631
|
```
|
633
|
-
$ punk --file
|
632
|
+
$ punk --file=./morepunks.png shuffle
|
634
633
|
```
|
635
634
|
|
636
635
|
And so on.
|
@@ -663,4 +662,9 @@ Use it as you please with no restrictions whatsoever.
|
|
663
662
|
|
664
663
|
## Questions? Comments?
|
665
664
|
|
666
|
-
|
665
|
+
Join us in the [Punk Art discord (chat server)]( https://discord.gg/FE3HeXNKRa). Yes you can.
|
666
|
+
Your questions and commentary welcome.
|
667
|
+
|
668
|
+
|
669
|
+
Or post them over at the [Help & Support](https://github.com/geraldb/help) page. Thanks.
|
670
|
+
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ Hoe.spec 'cryptopunks' do
|
|
13
13
|
|
14
14
|
self.version = Pixelart::Module::Cryptopunks::VERSION
|
15
15
|
|
16
|
-
self.summary = "cryptopunks - generate your own 24×24 pixel punk images (
|
16
|
+
self.summary = "cryptopunks - generate your own 24×24 pixel punk images from text prompts incl. 2x/4x/8x zoom for bigger sizes (or crop 'n' save tiles from all-in-one composites incl. the True Official Matt & John's® Punks sha256-verified original 10 000 unique character collection)"
|
17
17
|
self.description = summary
|
18
18
|
|
19
19
|
self.urls = { home: 'https://github.com/cryptopunksnotdead/cryptopunks' }
|
@@ -28,7 +28,7 @@ Hoe.spec 'cryptopunks' do
|
|
28
28
|
self.extra_deps = [
|
29
29
|
['pixelart', '>= 1.3.2'],
|
30
30
|
['punks', '>= 2024.2.29'],
|
31
|
-
['
|
31
|
+
['cmdparse'],
|
32
32
|
]
|
33
33
|
|
34
34
|
self.licenses = ['Public Domain']
|
data/lib/cryptopunks/tool.rb
CHANGED
@@ -1,127 +1,112 @@
|
|
1
1
|
|
2
2
|
module Punk
|
3
3
|
|
4
|
-
|
5
4
|
class Tool
|
6
|
-
def run( args )
|
7
|
-
Toolii.run( args )
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
class Opts
|
14
|
-
def merge_gli_options!( options = {} )
|
15
|
-
# puts " update options:"
|
16
|
-
# puts options.inspect
|
17
|
-
|
18
|
-
@file = options[:file] if options[:file]
|
19
|
-
@outdir = options[:dir] if options[:dir]
|
20
|
-
|
21
|
-
@zoom = options[:zoom] if options[:zoom]
|
22
|
-
@offset = options[:offset] if options[:offset]
|
23
|
-
|
24
|
-
@seed = options[:seed] if options[:seed]
|
25
|
-
|
26
|
-
@verbose = true if options[:verbose] == true
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
def verbose=(boolean) # add: alias for debug ??
|
31
|
-
@verbose = boolean
|
32
|
-
end
|
33
|
-
|
34
|
-
def verbose?
|
35
|
-
return false if @verbose.nil? # default verbose/debug flag is false
|
36
|
-
@verbose == true
|
37
|
-
end
|
38
|
-
|
39
|
-
def file() @file || './punks.png'; end
|
40
|
-
def file?() @file; end ## note: let's you check if file is set (or "untouched")
|
41
|
-
|
42
|
-
def zoom() @zoom || 1; end
|
43
|
-
def zoom?() @zoom; end
|
44
|
-
|
45
|
-
def offset() @offset || 0; end
|
46
|
-
def offset?() @offset; end
|
47
|
-
|
48
|
-
def outdir() @outdir || '.'; end
|
49
|
-
def outdir?() @outdir; end
|
50
|
-
|
51
|
-
### use a standard (default) seed - why? why not?
|
52
|
-
def seed() @seed || 4142; end
|
53
|
-
def seed?() @seed; end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end # class Opts
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
## note: use gli "dsl" inside a class / namespace
|
62
|
-
class Toolii
|
63
|
-
extend GLI::App
|
64
|
-
|
65
|
-
opts = Opts.new
|
66
|
-
|
67
|
-
|
68
|
-
program_desc 'punk (or cryptopunk) command line tool'
|
69
|
-
|
70
|
-
version Pixelart::Module::Cryptopunks::VERSION
|
71
|
-
|
72
|
-
|
73
|
-
desc "Zoom factor x2, x4, x8, etc."
|
74
|
-
arg_name 'ZOOM'
|
75
|
-
default_value opts.zoom
|
76
|
-
flag [:z, :zoom], type: Integer
|
77
|
-
|
78
|
-
desc "Start counting at offset"
|
79
|
-
arg_name 'NUM'
|
80
|
-
default_value opts.offset
|
81
|
-
flag [:offset], type: Integer
|
82
|
-
|
83
|
-
|
84
|
-
desc "Seed for random number generation / shuffle"
|
85
|
-
arg_name 'NUM'
|
86
|
-
default_value opts.seed
|
87
|
-
flag [:seed], type: Integer
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
desc "Output directory"
|
92
|
-
arg_name 'DIR'
|
93
|
-
default_value opts.outdir
|
94
|
-
flag [:d, :dir,
|
95
|
-
:o, :out, :outdir], type: String
|
96
|
-
|
97
|
-
|
98
|
-
### todo/check: move option to -t/--tile command only - why? why not?
|
99
|
-
# desc "True Official Genuine CryptoPunks™ all-in-one composite image"
|
100
|
-
desc "All-in-one composite image"
|
101
|
-
arg_name 'FILE'
|
102
|
-
default_value opts.file
|
103
|
-
flag [:f, :file], type: String
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
### global option (required)
|
108
|
-
## todo: add check that path is valid?? possible?
|
109
|
-
desc '(Debug) Show debug messages'
|
110
|
-
switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
|
111
5
|
|
6
|
+
class Opts ## use nested Opts class (inside Tool) - why? why not?
|
7
|
+
def verbose=(boolean) # add: alias for debug ??
|
8
|
+
@verbose = boolean
|
9
|
+
end
|
10
|
+
|
11
|
+
def verbose?
|
12
|
+
return false if @verbose.nil? # default verbose/debug flag is false
|
13
|
+
@verbose == true
|
14
|
+
end
|
15
|
+
|
16
|
+
def file() @file || './punks.png'; end
|
17
|
+
def file?() @file; end ## note: let's you check if file is set (or "untouched")
|
18
|
+
def file=(file) @file = file; end
|
19
|
+
|
20
|
+
def zoom() @zoom || 1; end
|
21
|
+
def zoom?() @zoom; end
|
22
|
+
def zoom=(num) @zoom = num; end
|
23
|
+
|
24
|
+
def offset() @offset || 0; end
|
25
|
+
def offset?() @offset; end
|
26
|
+
def offset=(num) @offset = num; end
|
27
|
+
|
28
|
+
def outdir() @outdir || '.'; end
|
29
|
+
def outdir?() @outdir; end
|
30
|
+
def outdir=(dir) @outdir = dir; end
|
31
|
+
|
32
|
+
### use a standard (default) seed - why? why not?
|
33
|
+
def seed() @seed || 4142; end
|
34
|
+
def seed?() @seed; end
|
35
|
+
def seed=(num) @seed = num; end
|
36
|
+
end # class Opts
|
37
|
+
|
38
|
+
|
39
|
+
## use def self.run instead of run e.g.
|
40
|
+
## Tool.run( ARGV ) vs Tool.new.run( ARGV )
|
41
|
+
def run( args )
|
42
|
+
opts = Opts.new
|
43
|
+
|
44
|
+
parser = CmdParse::CommandParser.new(handle_exceptions: :no_help)
|
45
|
+
parser.main_options.program_name = 'punk'
|
46
|
+
parser.main_options.banner = 'punk (or cryptopunk) command line tool'
|
47
|
+
parser.main_options.version = Pixelart::Module::Cryptopunks::VERSION
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
parser.global_options do |opt|
|
52
|
+
opt.on( '-z', '--zoom=NUM', Integer,
|
53
|
+
"Zoom factor x2, x4, x8, etc. (default: #{opts.zoom})"
|
54
|
+
) do |num|
|
55
|
+
opts.zoom = num
|
56
|
+
end
|
57
|
+
|
58
|
+
opt.on( '--offset=NUM', Integer,
|
59
|
+
"Start counting at offset (default: #{opts.offset})"
|
60
|
+
) do |num|
|
61
|
+
opts.offset = num
|
62
|
+
end
|
63
|
+
|
64
|
+
## todo - move to shuffle (only used by shuffle) - why? why not?
|
65
|
+
opt.on( '--seed=NUM', Integer,
|
66
|
+
"Seed for random number generation / shuffle (default: #{opts.seed})"
|
67
|
+
) do |num|
|
68
|
+
opts.seed = num
|
69
|
+
end
|
70
|
+
|
71
|
+
# note: remove -d alias (and --dir=DIR) why? why not?
|
72
|
+
opt.on( '-o', '--out=DIR', '--dir=DIR', '--outdir=DIR',
|
73
|
+
"Output directory (default: #{opts.outdir})"
|
74
|
+
) do |dir|
|
75
|
+
opts.outdir = dir
|
76
|
+
end
|
77
|
+
|
78
|
+
### todo/check: move option to -t/--tile command only - why? why not?
|
79
|
+
# desc "True Official Genuine CryptoPunks™ all-in-one composite image"
|
80
|
+
## todo: add check that path is valid?? possible?
|
81
|
+
opt.on( '-f', '--file=FILE',
|
82
|
+
"All-in-one composite image (default: #{opts.file})"
|
83
|
+
) do |file|
|
84
|
+
opts.file = file
|
85
|
+
end
|
86
|
+
|
87
|
+
# note - not used for now - always on
|
88
|
+
## todo: use -w for short form? check ruby interpreter if in use too?
|
89
|
+
# opt.on( '--verbose',
|
90
|
+
# "(Debug) Show debug messages"
|
91
|
+
# ) do
|
92
|
+
# opts.verbose = true
|
93
|
+
# # ## LogUtils::Logger.root.level = :debug
|
94
|
+
# end
|
95
|
+
end
|
112
96
|
|
113
97
|
|
114
|
-
|
115
|
-
|
116
|
-
|
98
|
+
# command - f, flip
|
99
|
+
flip = CmdParse::Command.new('flip', takes_commands: false)
|
100
|
+
flip.short_desc( "Flip (vertically) all punk characters in all-in-one punk series composite (#{opts.file})" )
|
101
|
+
flip.action do
|
117
102
|
puts "==> reading >#{opts.file}<..."
|
118
103
|
punks = ImageComposite.read( opts.file )
|
119
104
|
|
120
105
|
## note: for now always assume 24x24
|
121
|
-
cols = punks.width / 24
|
122
|
-
rows = punks.height / 24
|
123
106
|
tile_width = 24
|
124
107
|
tile_height = 24
|
108
|
+
cols = punks.width / tile_width
|
109
|
+
rows = punks.height / tile_height
|
125
110
|
|
126
111
|
phunks = ImageComposite.new( cols, rows,
|
127
112
|
width: tile_width,
|
@@ -134,28 +119,28 @@ command [:f, :flip] do |c|
|
|
134
119
|
## make sure outdir exits (default is current working dir e.g. .)
|
135
120
|
FileUtils.mkdir_p( opts.outdir ) unless Dir.exist?( opts.outdir )
|
136
121
|
|
137
|
-
## note:
|
122
|
+
## note: always assume .png extension for now
|
138
123
|
basename = File.basename( opts.file, File.extname( opts.file ) )
|
139
124
|
path = "#{opts.outdir}/#{basename}-flipped.png"
|
140
125
|
puts "==> saving phunks flipped one-by-one by hand to >#{path}<..."
|
141
126
|
|
142
127
|
phunks.save( path )
|
143
128
|
puts 'Done.'
|
144
|
-
|
145
|
-
end # command flip
|
129
|
+
end # action
|
146
130
|
|
147
131
|
|
148
|
-
|
149
|
-
|
150
|
-
|
132
|
+
# command - s, shuffle
|
133
|
+
shuffle = CmdParse::Command.new('shuffle', takes_commands: false)
|
134
|
+
shuffle.short_desc( "Shuffle all punk characters (randomly) in all-in-one punk series composite (#{opts.file})" )
|
135
|
+
shuffle.action do
|
151
136
|
puts "==> reading >#{opts.file}<..."
|
152
137
|
punks = ImageComposite.read( opts.file )
|
153
138
|
|
154
139
|
## note: for now always assume 24x24
|
155
|
-
cols = punks.width / 24
|
156
|
-
rows = punks.height / 24
|
157
140
|
tile_width = 24
|
158
141
|
tile_height = 24
|
142
|
+
cols = punks.width / tile_width
|
143
|
+
rows = punks.height / tile_height
|
159
144
|
|
160
145
|
phunks = ImageComposite.new( cols, rows,
|
161
146
|
width: tile_width,
|
@@ -171,7 +156,6 @@ command [:s, :shuffle] do |c|
|
|
171
156
|
# seed 4142 ends in [..., 7566, 828, 8987, 9777]
|
172
157
|
# 333 ends in [..., 6067, 9635, 973, 8172]
|
173
158
|
|
174
|
-
|
175
159
|
indexes.each_with_index do |old_index,new_index|
|
176
160
|
puts " ##{old_index} now ##{new_index}"
|
177
161
|
phunks << punks[old_index]
|
@@ -190,26 +174,16 @@ command [:s, :shuffle] do |c|
|
|
190
174
|
|
191
175
|
phunks.save( path )
|
192
176
|
puts 'Done.'
|
193
|
-
|
194
|
-
end # command shuffle
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
177
|
+
end # action
|
199
178
|
|
200
179
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
# puts "opts:"
|
207
|
-
# puts opts.inspect
|
208
|
-
|
180
|
+
# command - t, tile
|
181
|
+
tile = CmdParse::Command.new('tile', takes_commands: false)
|
182
|
+
tile.short_desc( "Get punk characters via image tiles from all-in-one punk series composite (#{opts.file}) - for IDs use 0 to 9999" )
|
183
|
+
tile.action do |*args|
|
209
184
|
puts "==> reading >#{opts.file}<..."
|
210
185
|
punks = ImageComposite.read( opts.file )
|
211
186
|
|
212
|
-
|
213
187
|
puts " setting zoom to #{opts.zoom}x" if opts.zoom != 1
|
214
188
|
|
215
189
|
## make sure outdir exits (default is current working dir e.g. .)
|
@@ -234,17 +208,16 @@ command [:t, :tile] do |c|
|
|
234
208
|
punk.save( path )
|
235
209
|
end
|
236
210
|
puts 'Done.'
|
237
|
-
|
238
|
-
end # command tile
|
211
|
+
end # action
|
239
212
|
|
240
213
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
214
|
+
# command - g, gen, generate
|
215
|
+
# note: shorten to gen
|
216
|
+
generate = CmdParse::Command.new('gen', takes_commands: false)
|
217
|
+
generate.short_desc( "Generate punk characters from text attributes (from scratch / zero) via builtin punk spritesheet" )
|
218
|
+
generate.action do |*args|
|
246
219
|
puts "==> generating >#{args.join( ' + ' )}<..."
|
247
|
-
punk = Image.generate( *args )
|
220
|
+
punk = Punk::Image.generate( *args )
|
248
221
|
|
249
222
|
puts " setting zoom to #{opts.zoom}x" if opts.zoom != 1
|
250
223
|
|
@@ -265,17 +238,14 @@ command [:g, :gen, :generate] do |c|
|
|
265
238
|
|
266
239
|
punk.save( path )
|
267
240
|
puts 'Done.'
|
268
|
-
|
269
|
-
end # command generate
|
270
|
-
|
241
|
+
end # action
|
271
242
|
|
272
|
-
desc 'Query (builtin off-chain) punk contract for punk text attributes by IDs - use 0 to 9999'
|
273
|
-
command [:q, :query] do |c|
|
274
|
-
c.action do |g,o,args|
|
275
243
|
|
276
|
-
# puts "opts:"
|
277
|
-
# puts opts.inspect
|
278
244
|
|
245
|
+
# command - q, query
|
246
|
+
query = CmdParse::Command.new('query', takes_commands: false)
|
247
|
+
query.short_desc( "Query (builtin off-chain) punk contract for punk text attributes by IDs - use 0 to 9999" )
|
248
|
+
query.action do |*args|
|
279
249
|
args.each_with_index do |arg,index|
|
280
250
|
punk_index = arg.to_i( 10 ) ## assume base 10 decimal
|
281
251
|
|
@@ -292,16 +262,16 @@ command [:q, :query] do |c|
|
|
292
262
|
print "\n"
|
293
263
|
end
|
294
264
|
puts 'Done.'
|
295
|
-
end
|
296
265
|
end
|
297
266
|
|
298
267
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
268
|
+
# command - l, ls # (NOT) list
|
269
|
+
## note: ls (alias) is NOT possible with cmdparse gem!!!!! - ask if workaround?
|
270
|
+
## note: as a workaround use ls for now (not list)!!!
|
271
|
+
list = CmdParse::Command.new('ls', takes_commands: false)
|
272
|
+
list.short_desc( "List all punk archetype and attribute names from builtin punk spritesheet" )
|
273
|
+
list.action do
|
274
|
+
# was: generator = Punk::Image.generator
|
305
275
|
sheet = Punk::Spritesheet.builtin
|
306
276
|
|
307
277
|
puts "==> Archetypes"
|
@@ -330,54 +300,23 @@ command [:l, :ls, :list] do |c|
|
|
330
300
|
puts ""
|
331
301
|
|
332
302
|
puts 'Done.'
|
333
|
-
|
334
|
-
end # command list
|
303
|
+
end # action
|
335
304
|
|
336
305
|
|
306
|
+
parser.add_command(CmdParse::HelpCommand.new, default: true)
|
307
|
+
parser.add_command(CmdParse::VersionCommand.new)
|
308
|
+
parser.add_command( flip )
|
309
|
+
parser.add_command( shuffle )
|
310
|
+
parser.add_command( tile )
|
311
|
+
parser.add_command( generate )
|
312
|
+
parser.add_command( query )
|
313
|
+
parser.add_command( list )
|
337
314
|
|
338
|
-
pre do |g,c,o,args|
|
339
|
-
opts.merge_gli_options!( g )
|
340
|
-
opts.merge_gli_options!( o )
|
341
|
-
|
342
|
-
if opts.verbose?
|
343
|
-
## LogUtils::Logger.root.level = :debug
|
344
|
-
end
|
345
|
-
|
346
|
-
## logger.debug "Executing #{c.name}"
|
347
|
-
true
|
348
|
-
end
|
349
|
-
|
350
|
-
post do |global,c,o,args|
|
351
|
-
## logger.debug "Executed #{c.name}"
|
352
|
-
true
|
353
|
-
end
|
354
|
-
|
355
|
-
|
356
|
-
on_error do |e|
|
357
|
-
|
358
|
-
if opts.verbose?
|
359
|
-
puts e.backtrace
|
360
|
-
end
|
361
|
-
|
362
|
-
if e.is_a?( SystemExit )
|
363
|
-
puts
|
364
|
-
puts "*** error: system exit with status code ( #{e.status} )"
|
365
|
-
exit( e.status ) ## try exit again to make sure error code gets passed along!!!
|
366
|
-
else
|
367
|
-
puts
|
368
|
-
puts "*** error: #{e.message}"
|
369
|
-
end
|
370
|
-
|
371
|
-
## note: was false # skip default error handling
|
372
|
-
|
373
|
-
## note: try true - false WILL SWALLOW exit codes and such
|
374
|
-
## - looks like it's still returning 0 (e.g. on unknown option or such)!!!!
|
375
|
-
true
|
376
|
-
end
|
377
315
|
|
316
|
+
parser.parse( args )
|
317
|
+
end # method run
|
318
|
+
end # class Tool
|
319
|
+
end # moduule Punk
|
378
320
|
|
379
|
-
### exit run(ARGV) ## note: use Toolii.run( ARGV ) outside of class
|
380
|
-
end # class Toolii
|
381
|
-
end # module Punk
|
382
321
|
|
383
322
|
|
data/lib/cryptopunks/version.rb
CHANGED
data/lib/cryptopunks.rb
CHANGED
@@ -6,7 +6,7 @@ require 'punks'
|
|
6
6
|
## extra stdlibs
|
7
7
|
require 'digest' ## move/add to pixelart upstream - why? why not?
|
8
8
|
require 'optparse'
|
9
|
-
require '
|
9
|
+
require 'cmdparse' ## used for command line tool
|
10
10
|
|
11
11
|
|
12
12
|
|
@@ -15,7 +15,6 @@ require 'cryptopunks/version' # note: let version always go first
|
|
15
15
|
|
16
16
|
|
17
17
|
require 'cryptopunks/attributes'
|
18
|
-
require 'cryptopunks/composite'
|
19
18
|
require 'cryptopunks/colors'
|
20
19
|
|
21
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptopunks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2024.2
|
4
|
+
version: 2024.3.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: 2024-02
|
11
|
+
date: 2024-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pixelart
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2024.2.29
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: cmdparse
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -86,9 +86,10 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '4.1'
|
89
|
-
description: cryptopunks - generate your own 24×24 pixel punk images
|
90
|
-
|
91
|
-
|
89
|
+
description: cryptopunks - generate your own 24×24 pixel punk images from text prompts
|
90
|
+
incl. 2x/4x/8x zoom for bigger sizes (or crop 'n' save tiles from all-in-one composites
|
91
|
+
incl. the True Official Matt & John's® Punks sha256-verified original 10 000 unique
|
92
|
+
character collection)
|
92
93
|
email: wwwmake@googlegroups.com
|
93
94
|
executables:
|
94
95
|
- cryptopunk
|
@@ -108,7 +109,6 @@ files:
|
|
108
109
|
- lib/cryptopunks.rb
|
109
110
|
- lib/cryptopunks/attributes.rb
|
110
111
|
- lib/cryptopunks/colors.rb
|
111
|
-
- lib/cryptopunks/composite.rb
|
112
112
|
- lib/cryptopunks/contract/punksdata-assets.rb
|
113
113
|
- lib/cryptopunks/contract/punksdata-contract.rb
|
114
114
|
- lib/cryptopunks/contract/punksdata-meta.rb
|
@@ -138,7 +138,8 @@ requirements: []
|
|
138
138
|
rubygems_version: 3.4.10
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
|
-
summary: cryptopunks - generate your own 24×24 pixel punk images
|
142
|
-
|
143
|
-
|
141
|
+
summary: cryptopunks - generate your own 24×24 pixel punk images from text prompts
|
142
|
+
incl. 2x/4x/8x zoom for bigger sizes (or crop 'n' save tiles from all-in-one composites
|
143
|
+
incl. the True Official Matt & John's® Punks sha256-verified original 10 000 unique
|
144
|
+
character collection)
|
144
145
|
test_files: []
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Punk
|
2
|
-
## note: was Image::Composite
|
3
|
-
class ImageComposite < Pixelart::ImageComposite
|
4
|
-
|
5
|
-
PUNK_HASH = 'ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b'
|
6
|
-
|
7
|
-
def self.sha256( data )
|
8
|
-
## todo/check: or just use Digest::SHA256.hexdigest - why? why not?
|
9
|
-
Digest::SHA256.digest( data ).unpack( 'H*' )[0]
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
PUNK_HEIGHT = 24
|
14
|
-
PUNK_WIDTH = 24
|
15
|
-
|
16
|
-
def self.read( path='./punks.png', width: PUNK_WIDTH, height: PUNK_HEIGHT )
|
17
|
-
data = File.open( path, 'rb' ) { |f| f.read }
|
18
|
-
|
19
|
-
hexdigest = sha256( data ) ## check sha256 checksum
|
20
|
-
if hexdigest == PUNK_HASH
|
21
|
-
puts " >#{hexdigest}< SHA256 hash matching"
|
22
|
-
puts " ✓ True Official Genuine Matt & John's® Punks verified"
|
23
|
-
else
|
24
|
-
puts " ✓ True Official Genuine Yes, You Can! Punk's Not Dead® verified"
|
25
|
-
end
|
26
|
-
|
27
|
-
img = ChunkyPNG::Image.from_blob( data )
|
28
|
-
new( img, width: width, height: height )
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def initialize( *args, width: PUNK_WIDTH,
|
33
|
-
height: PUNK_HEIGHT )
|
34
|
-
super
|
35
|
-
end
|
36
|
-
|
37
|
-
end ## class ImageComposite
|
38
|
-
end ## module Punk
|