cryptopunks 1.2.0 → 1.2.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/Manifest.txt +22 -0
- data/README.md +1 -4
- data/config/more/alien-female.txt +34 -0
- data/config/more/ape-female.txt +33 -0
- data/config/more/demon-female.txt +33 -0
- data/config/more/demon-male.txt +33 -0
- data/config/more/mummy-female.txt +33 -0
- data/config/more/mummy-male.txt +33 -0
- data/config/more/orc-female.txt +33 -0
- data/config/more/orc-male.txt +33 -0
- data/config/more/robot-female.txt +34 -0
- data/config/more/robot-male.txt +33 -0
- data/config/more/skeleton-female.txt +33 -0
- data/config/more/skeleton-male.txt +33 -0
- data/config/more/vampire-female.txt +33 -0
- data/config/more/vampire-male.txt +33 -0
- data/config/more/zombie-female.txt +33 -0
- data/config/original/alien-male.txt +33 -0
- data/config/original/ape-male.txt +33 -0
- data/config/original/human-female.txt +33 -0
- data/config/original/human-male.txt +34 -0
- data/config/original/zombie-male.txt +33 -0
- data/lib/cryptopunks.rb +29 -1
- data/lib/cryptopunks/colors.rb +162 -0
- data/lib/cryptopunks/composite.rb +20 -44
- data/lib/cryptopunks/image.rb +121 -0
- data/lib/cryptopunks/structs.rb +19 -6
- data/lib/cryptopunks/version.rb +1 -1
- metadata +44 -2
@@ -1,61 +1,37 @@
|
|
1
1
|
module Cryptopunks
|
2
|
-
class Image
|
3
|
-
class Composite
|
4
|
-
|
5
|
-
|
6
|
-
def self.read( path='./punks.png' )
|
7
|
-
data = File.open( path, 'rb' ) { |f| f.read }
|
8
|
-
new( data )
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
PUNK_HEIGHT = 24
|
13
|
-
PUNK_WIDTH = 24
|
2
|
+
class Image ## nest Composite inside Image - why? why not?
|
3
|
+
class Composite < Pixelart::ImageComposite
|
14
4
|
|
15
5
|
PUNK_HASH = 'ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b'
|
16
6
|
|
17
|
-
|
18
|
-
def initialize( data )
|
19
|
-
@punks = ChunkyPNG::Image.from_blob( data )
|
20
|
-
puts " #{@punks.height}x#{@punks.width} (height x width)"
|
21
|
-
|
22
|
-
@punk_rows = @punks.width / PUNK_WIDTH ## e.g. 2400/24 = 100
|
23
|
-
@punk_cols = @punks.height / PUNK_HEIGHT ## e.g. 2400/24 = 100
|
24
|
-
@punk_count = @punk_rows * @punk_cols ## ## 10000 = 100x100 (2400x2400 pixel)
|
25
|
-
|
26
|
-
## check sha256 checksum
|
27
|
-
@hexdigest = sha256( data )
|
28
|
-
if original?
|
29
|
-
puts " >#{@hexdigest}< SHA256 hash matching"
|
30
|
-
puts " ✓ True Official Genuine CryptoPunks™ verified"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def sha256( data )
|
7
|
+
def self.sha256( data )
|
36
8
|
## todo/check: or just use Digest::SHA256.hexdigest - why? why not?
|
37
9
|
Digest::SHA256.digest( data ).unpack( 'H*' )[0]
|
38
10
|
end
|
39
11
|
|
12
|
+
def self.read( path='./punks.png' )
|
13
|
+
data = File.open( path, 'rb' ) { |f| f.read }
|
40
14
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
15
|
+
hexdigest = sha256( data ) ## check sha256 checksum
|
16
|
+
if hexdigest == PUNK_HASH
|
17
|
+
puts " >#{hexdigest}< SHA256 hash matching"
|
18
|
+
puts " ✓ True Official Genuine CryptoPunks™ verified"
|
19
|
+
else
|
20
|
+
puts " ✓ True Official Genuine Yes, You Can! Punks Not Dead™ verified"
|
21
|
+
end
|
47
22
|
|
23
|
+
img = ChunkyPNG::Image.from_blob( data )
|
24
|
+
new( img )
|
25
|
+
end
|
48
26
|
|
49
|
-
def size() @punk_count; end
|
50
27
|
|
28
|
+
PUNK_HEIGHT = 24
|
29
|
+
PUNK_WIDTH = 24
|
51
30
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
Pixelart::Image.new( img.width, img.height, img ) ## wrap in pixelart image
|
31
|
+
def initialize( *args, width: PUNK_WIDTH,
|
32
|
+
height: PUNK_HEIGHT )
|
33
|
+
super
|
56
34
|
end
|
57
|
-
alias_method :[], :punk
|
58
|
-
|
59
35
|
|
60
36
|
end ## class Composite
|
61
37
|
end ## class Image
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Cryptopunks
|
2
|
+
|
3
|
+
|
4
|
+
class Design ## todo/fix - move to its own file!!!
|
5
|
+
|
6
|
+
end # class Design
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
##############
|
11
|
+
## todo/check:
|
12
|
+
## find a better way to (auto?) include more designs?
|
13
|
+
class DesignSeries ## find a better name for class (just use Series?) - why? why not?
|
14
|
+
def self.build( dir )
|
15
|
+
data = {}
|
16
|
+
paths = Dir.glob( "#{dir}/**.txt" )
|
17
|
+
paths.each do |path|
|
18
|
+
basename = File.basename( path, File.extname( path ) )
|
19
|
+
text = File.open( path, 'r:utf-8' ) { |f| f.read }
|
20
|
+
## todo/check: auto-parse "ahead of time" here
|
21
|
+
## or keep "raw" text - why? why not?
|
22
|
+
data[ basename ] = text
|
23
|
+
end
|
24
|
+
data
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize( dir )
|
28
|
+
@dir = dir # e.g. "#{Cryptopunks.root}/config/more"
|
29
|
+
end
|
30
|
+
|
31
|
+
def data
|
32
|
+
## note: lazy load / build on first demand only
|
33
|
+
@data ||= self.class.build( @dir )
|
34
|
+
end
|
35
|
+
|
36
|
+
def [](key) data[ key ]; end
|
37
|
+
def size() data.size; end
|
38
|
+
def keys() data.keys; end
|
39
|
+
def to_h() data; end ## todo/check: use to_hash() - why? why not?
|
40
|
+
end # class DesignSeries
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
class Image
|
45
|
+
|
46
|
+
def self.read( path ) ## convenience helper
|
47
|
+
img = ChunkyPNG::Image.from_file( path )
|
48
|
+
new( img )
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def initialize( initial=nil, design: nil,
|
53
|
+
colors: nil )
|
54
|
+
if initial
|
55
|
+
## pass image through as-is
|
56
|
+
img = inital
|
57
|
+
else
|
58
|
+
|
59
|
+
## todo/fix:
|
60
|
+
## move design code into design class!!!
|
61
|
+
## for now assume design is a string
|
62
|
+
## split into parts
|
63
|
+
## original/alien-male or original@alien-male
|
64
|
+
## more/alien-female or more@alien-female
|
65
|
+
## original/human-male+darker or original@human-male!darker ????
|
66
|
+
## human-male!darker ?????
|
67
|
+
## keep @ as separator too - why? why not?
|
68
|
+
parts = design.split( %r{[@/]} )
|
69
|
+
parts.unshift( '*' ) if parts.size == 1 ## assume "all-in-one" series (use * as name/id/placeholder)
|
70
|
+
|
71
|
+
series_key = parts[0]
|
72
|
+
design_composite = parts[1]
|
73
|
+
|
74
|
+
## todo/check - find a way for unambigious (color) variant key
|
75
|
+
## use unique char e.g. +*!# or such
|
76
|
+
more_parts = design_composite.split( %r{[!+]} )
|
77
|
+
design_key = more_parts[0]
|
78
|
+
variant_key = more_parts[1] ## color variant for now (for humans) e.g. lighter/light/dark/darker
|
79
|
+
|
80
|
+
series = if ['*','**','_','__'].include?( series_key )
|
81
|
+
DESIGNS ## use all-series-in-one collection
|
82
|
+
else
|
83
|
+
case series_key
|
84
|
+
when 'original' then DESIGNS_ORIGINAL
|
85
|
+
when 'more' then DESIGNS_MORE
|
86
|
+
else raise ArgumentError, "unknown design series >#{series_key}<; sorry"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
design = series[ design_key ]
|
91
|
+
raise ArgumentError, "unknow design >#{design_key}< in series >#{series_key}<; sorry" if design.nil?
|
92
|
+
|
93
|
+
if colors.nil? ## try to auto-fill in colors
|
94
|
+
## note: (auto-)remove _male,_female qualifier if exist
|
95
|
+
colors_key = design_key.sub( '-male', '' ).sub( '-female', '' )
|
96
|
+
colors = COLORS[ colors_key ]
|
97
|
+
|
98
|
+
## allow / support color scheme variants (e.g. lighter/light/dark/darker) etc.
|
99
|
+
if colors.is_a?(Hash)
|
100
|
+
if variant_key
|
101
|
+
colors = colors[ variant_key ]
|
102
|
+
raise ArgumentError, "no colors defined for variant >#{variant_key}< for design >#{design_key}< in series >#{series_key}<; sorry" if colors.nil?
|
103
|
+
else ## note: use (fallback to) first color scheme if no variant key present
|
104
|
+
colors = colors[ colors.keys[0] ]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
raise ArgumentError, "no (default) colors defined for design >#{design_key}< in series >#{series_key}<; sorry" if colors.nil?
|
109
|
+
end
|
110
|
+
|
111
|
+
## note: unwrap inner image before passing on to super c'tor
|
112
|
+
img = Pixelart::Image.parse( design, colors: colors ).image
|
113
|
+
end
|
114
|
+
|
115
|
+
super( img.width, img.height, img )
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
end # class Image
|
121
|
+
end # module Cryptopunks
|
data/lib/cryptopunks/structs.rb
CHANGED
@@ -137,12 +137,25 @@ end ## (nested) class Accessory
|
|
137
137
|
@birthday = Date.new( 2017, 6, 23) ## all 10,000 minted on June 23, 2017
|
138
138
|
end
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
def
|
145
|
-
def
|
140
|
+
def is_type?( name ) @type.name == name; end
|
141
|
+
alias_method :is?, :is_type?
|
142
|
+
|
143
|
+
## convenience helpers for "classic" (5) types
|
144
|
+
def alien?() is_type?( 'Alien'); end
|
145
|
+
def ape?() is_type?( 'Ape' ); end
|
146
|
+
def zombie?() is_type?( 'Zombie' ); end
|
147
|
+
def female?() is_type?( 'Female' ); end
|
148
|
+
def male?() is_type?( 'Male' ); end
|
149
|
+
|
150
|
+
## convenience helpers to lookup attributes
|
151
|
+
def has_attribute?( name )
|
152
|
+
accessories.each do |acc|
|
153
|
+
return true if acc.name == name
|
154
|
+
end
|
155
|
+
false
|
156
|
+
end
|
157
|
+
alias_method :has?, :has_attribute?
|
158
|
+
alias_method :include?, :has_attribute?
|
146
159
|
end # class Metadata
|
147
160
|
|
148
161
|
end # module Cryptopunks
|
data/lib/cryptopunks/version.rb
CHANGED
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: 1.2.
|
4
|
+
version: 1.2.1
|
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-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pixelart
|
@@ -84,6 +84,26 @@ extra_rdoc_files:
|
|
84
84
|
- CHANGELOG.md
|
85
85
|
- Manifest.txt
|
86
86
|
- README.md
|
87
|
+
- config/more/alien-female.txt
|
88
|
+
- config/more/ape-female.txt
|
89
|
+
- config/more/demon-female.txt
|
90
|
+
- config/more/demon-male.txt
|
91
|
+
- config/more/mummy-female.txt
|
92
|
+
- config/more/mummy-male.txt
|
93
|
+
- config/more/orc-female.txt
|
94
|
+
- config/more/orc-male.txt
|
95
|
+
- config/more/robot-female.txt
|
96
|
+
- config/more/robot-male.txt
|
97
|
+
- config/more/skeleton-female.txt
|
98
|
+
- config/more/skeleton-male.txt
|
99
|
+
- config/more/vampire-female.txt
|
100
|
+
- config/more/vampire-male.txt
|
101
|
+
- config/more/zombie-female.txt
|
102
|
+
- config/original/alien-male.txt
|
103
|
+
- config/original/ape-male.txt
|
104
|
+
- config/original/human-female.txt
|
105
|
+
- config/original/human-male.txt
|
106
|
+
- config/original/zombie-male.txt
|
87
107
|
files:
|
88
108
|
- CHANGELOG.md
|
89
109
|
- Manifest.txt
|
@@ -91,10 +111,32 @@ files:
|
|
91
111
|
- Rakefile
|
92
112
|
- bin/cryptopunk
|
93
113
|
- bin/punk
|
114
|
+
- config/more/alien-female.txt
|
115
|
+
- config/more/ape-female.txt
|
116
|
+
- config/more/demon-female.txt
|
117
|
+
- config/more/demon-male.txt
|
118
|
+
- config/more/mummy-female.txt
|
119
|
+
- config/more/mummy-male.txt
|
120
|
+
- config/more/orc-female.txt
|
121
|
+
- config/more/orc-male.txt
|
122
|
+
- config/more/robot-female.txt
|
123
|
+
- config/more/robot-male.txt
|
124
|
+
- config/more/skeleton-female.txt
|
125
|
+
- config/more/skeleton-male.txt
|
126
|
+
- config/more/vampire-female.txt
|
127
|
+
- config/more/vampire-male.txt
|
128
|
+
- config/more/zombie-female.txt
|
129
|
+
- config/original/alien-male.txt
|
130
|
+
- config/original/ape-male.txt
|
131
|
+
- config/original/human-female.txt
|
132
|
+
- config/original/human-male.txt
|
133
|
+
- config/original/zombie-male.txt
|
94
134
|
- lib/cryptopunks.rb
|
95
135
|
- lib/cryptopunks/attributes.rb
|
136
|
+
- lib/cryptopunks/colors.rb
|
96
137
|
- lib/cryptopunks/composite.rb
|
97
138
|
- lib/cryptopunks/dataset.rb
|
139
|
+
- lib/cryptopunks/image.rb
|
98
140
|
- lib/cryptopunks/structs.rb
|
99
141
|
- lib/cryptopunks/version.rb
|
100
142
|
homepage: https://github.com/cryptopunksnotdead/cryptopunks
|