cryptopunks 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +9 -0
- data/README.md +1 -4
- data/Rakefile +1 -0
- data/config/spritesheet.csv +237 -0
- data/config/spritesheet.png +0 -0
- data/lib/cryptopunks/colors.rb +162 -0
- data/lib/cryptopunks/composite.rb +19 -43
- data/lib/cryptopunks/contract/punksdata-assets.rb +338 -0
- data/lib/cryptopunks/contract/punksdata-contract.rb +55 -0
- data/lib/cryptopunks/contract/punksdata-meta.rb +2107 -0
- data/lib/cryptopunks/generator.rb +207 -0
- data/lib/cryptopunks/image.rb +33 -0
- data/lib/cryptopunks/structs.rb +19 -6
- data/lib/cryptopunks/tool.rb +264 -0
- data/lib/cryptopunks/version.rb +2 -2
- data/lib/cryptopunks.rb +65 -68
- metadata +25 -2
data/lib/cryptopunks.rb
CHANGED
@@ -1,112 +1,109 @@
|
|
1
1
|
## 3rd party
|
2
|
-
require 'pixelart'
|
2
|
+
require 'pixelart/base'
|
3
3
|
require 'csvreader'
|
4
4
|
|
5
5
|
|
6
6
|
|
7
7
|
## extra stdlibs
|
8
|
-
require 'digest'
|
8
|
+
require 'digest' ## move/add to pixelart upstream - why? why not?
|
9
9
|
require 'optparse'
|
10
|
+
require 'gli' ## used for command line tool
|
10
11
|
|
11
12
|
|
12
13
|
|
13
14
|
## our own code
|
14
15
|
require 'cryptopunks/version' # note: let version always go first
|
16
|
+
|
17
|
+
## forward define superclass for image
|
18
|
+
module Cryptopunks
|
19
|
+
class Image < Pixelart::Image; end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
15
23
|
require 'cryptopunks/attributes'
|
16
24
|
require 'cryptopunks/structs'
|
17
25
|
require 'cryptopunks/composite'
|
18
|
-
|
19
|
-
|
20
|
-
|
26
|
+
## add old backwards compatible alias
|
21
27
|
|
22
28
|
module Cryptopunks
|
23
|
-
class
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
file: './punks.png',
|
28
|
-
offset: 0,
|
29
|
-
}
|
30
|
-
|
31
|
-
parser = OptionParser.new do |cmd|
|
32
|
-
cmd.banner = "Usage: punk (or cryptopunk) [options] IDs"
|
33
|
-
|
34
|
-
cmd.separator " Mint punk characters from composite (#{opts[:file]}) - for IDs use 0 to 9999"
|
35
|
-
cmd.separator ""
|
36
|
-
cmd.separator " Options:"
|
37
|
-
|
38
|
-
cmd.on("-z", "--zoom=ZOOM", "Zoom factor x2, x4, x8, etc. (default: #{opts[:zoom]})", Integer ) do |zoom|
|
39
|
-
opts[:zoom] = zoom
|
40
|
-
end
|
41
|
-
|
42
|
-
cmd.on("-d", "--dir=DIR", "Output directory (default: #{opts[:outdir]})", String ) do |outdir|
|
43
|
-
opts[:outdir] = outdir
|
44
|
-
end
|
45
|
-
|
46
|
-
cmd.on("-f", "--file=FILE", "True Official Genuine CryptoPunks™ composite image (default: #{opts[:file]})", String ) do |file|
|
47
|
-
opts[:file] = file
|
48
|
-
end
|
49
|
-
|
50
|
-
cmd.on("--offset=NUM", "Start counting at offset (default: #{opts[:offset]})", Integer ) do |offset|
|
51
|
-
opts[:offset] = offset
|
52
|
-
end
|
53
|
-
|
54
|
-
cmd.on("-h", "--help", "Prints this help") do
|
55
|
-
puts cmd
|
56
|
-
exit
|
57
|
-
end
|
58
|
-
end
|
29
|
+
class Image
|
30
|
+
Composite = ImageComposite
|
31
|
+
end
|
32
|
+
end
|
59
33
|
|
60
|
-
parser.parse!( args )
|
61
34
|
|
62
|
-
|
63
|
-
pp opts
|
35
|
+
require 'cryptopunks/dataset'
|
64
36
|
|
65
|
-
|
66
|
-
|
37
|
+
require 'cryptopunks/colors'
|
38
|
+
require 'cryptopunks/image'
|
67
39
|
|
40
|
+
require 'cryptopunks/generator'
|
68
41
|
|
69
|
-
|
42
|
+
###
|
43
|
+
## add convenience pre-configurated generatored with build-in spritesheet (see config)
|
70
44
|
|
71
|
-
|
72
|
-
FileUtils.mkdir_p( opts[:outdir] ) unless Dir.exist?( opts[:outdir] )
|
45
|
+
module Cryptopunks
|
73
46
|
|
74
|
-
|
75
|
-
|
47
|
+
def self.generator
|
48
|
+
@generator ||= Generator.new( "#{root}/config/spritesheet.png",
|
49
|
+
"#{root}/config/spritesheet.csv" )
|
50
|
+
end
|
51
|
+
|
52
|
+
class Image
|
53
|
+
def self.generate( *values )
|
54
|
+
img = Cryptopunks.generator.generate( *values )
|
55
|
+
## note: unwrap inner image before passing on to c'tor (requires ChunkyPNG image for now)
|
56
|
+
new( img.image )
|
57
|
+
end
|
58
|
+
end # class Image
|
59
|
+
|
60
|
+
|
61
|
+
class Spritesheet
|
62
|
+
## note: for now class used for "namespace" only
|
63
|
+
def self.find_by( name:, gender: nil ) ## return archetype/attribute image by name
|
64
|
+
# note: pass along name as q (query string)
|
65
|
+
Cryptopunks.generator.find( name, gender: gender )
|
66
|
+
end
|
67
|
+
end # class Spritesheet
|
68
|
+
## add convenience (alternate spelling) alias - why? why not?
|
69
|
+
SpriteSheet = Spritesheet
|
70
|
+
Sheet = Spritesheet
|
71
|
+
end # module Cryptopunks
|
76
72
|
|
77
|
-
punk = punks[ punk_index ]
|
78
73
|
|
79
|
-
punk_name = "punk-" + "%04d" % (punk_index + opts[:offset])
|
80
74
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
75
|
+
####
|
76
|
+
# add CryptoPunksData (off-chain) contract
|
77
|
+
require 'cryptopunks/contract/punksdata-assets'
|
78
|
+
require 'cryptopunks/contract/punksdata-meta'
|
79
|
+
require 'cryptopunks/contract/punksdata-contract'
|
80
|
+
CryptoPunksData = CryptopunksData
|
81
|
+
PunksData = CryptopunksData
|
86
82
|
|
87
|
-
path = "#{opts[:outdir]}/#{punk_name}.png"
|
88
|
-
puts "==> (#{index+1}/#{args.size}) minting punk ##{punk_index+opts[:offset]}; writing to >#{path}<..."
|
89
83
|
|
90
|
-
punk.save( path )
|
91
|
-
end
|
92
84
|
|
93
|
-
puts "done"
|
94
|
-
end ## method run
|
95
|
-
end # class Tool
|
96
85
|
|
97
86
|
|
98
|
-
|
99
|
-
|
100
|
-
|
87
|
+
require 'cryptopunks/tool'
|
88
|
+
|
89
|
+
### add tool convenience helper
|
90
|
+
module Cryptopunks
|
91
|
+
def self.main( args=ARGV ) Tool.new.run( args ); end
|
101
92
|
end ## module Cryptopunks
|
102
93
|
|
103
94
|
|
104
95
|
|
96
|
+
|
97
|
+
|
105
98
|
### add some convenience shortcuts
|
106
99
|
CryptoPunks = Cryptopunks
|
107
100
|
Punks = Cryptopunks
|
108
101
|
|
109
102
|
|
103
|
+
###
|
104
|
+
# note: for convenience auto include Pixelart namespace!!! - why? why not?
|
105
|
+
include Pixelart
|
106
|
+
|
110
107
|
|
111
108
|
|
112
109
|
puts Cryptopunks.banner # say hello
|
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:
|
4
|
+
version: 2.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: 2021-
|
11
|
+
date: 2021-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pixelart
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gli
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rdoc
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,11 +105,20 @@ files:
|
|
91
105
|
- Rakefile
|
92
106
|
- bin/cryptopunk
|
93
107
|
- bin/punk
|
108
|
+
- config/spritesheet.csv
|
109
|
+
- config/spritesheet.png
|
94
110
|
- lib/cryptopunks.rb
|
95
111
|
- lib/cryptopunks/attributes.rb
|
112
|
+
- lib/cryptopunks/colors.rb
|
96
113
|
- lib/cryptopunks/composite.rb
|
114
|
+
- lib/cryptopunks/contract/punksdata-assets.rb
|
115
|
+
- lib/cryptopunks/contract/punksdata-contract.rb
|
116
|
+
- lib/cryptopunks/contract/punksdata-meta.rb
|
97
117
|
- lib/cryptopunks/dataset.rb
|
118
|
+
- lib/cryptopunks/generator.rb
|
119
|
+
- lib/cryptopunks/image.rb
|
98
120
|
- lib/cryptopunks/structs.rb
|
121
|
+
- lib/cryptopunks/tool.rb
|
99
122
|
- lib/cryptopunks/version.rb
|
100
123
|
homepage: https://github.com/cryptopunksnotdead/cryptopunks
|
101
124
|
licenses:
|