cryptopunks 1.1.0 → 1.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.
data/lib/cryptopunks.rb CHANGED
@@ -1,22 +1,56 @@
1
1
  ## 3rd party
2
- require 'crypto-lite'
3
- require 'chunky_png'
2
+ require 'pixelart/base'
4
3
  require 'csvreader'
5
4
 
6
5
 
6
+
7
7
  ## extra stdlibs
8
- require 'fileutils'
8
+ require 'digest' ## move/add to pixelart upstream - why? why not?
9
9
  require 'optparse'
10
10
 
11
11
 
12
12
 
13
13
  ## our own code
14
14
  require 'cryptopunks/version' # note: let version always go first
15
+
16
+ ## forward define superclass for image
17
+ module Cryptopunks
18
+ class Image < Pixelart::Image; end
19
+ end
20
+
21
+
15
22
  require 'cryptopunks/attributes'
16
23
  require 'cryptopunks/structs'
17
- require 'cryptopunks/image'
24
+ require 'cryptopunks/composite'
18
25
  require 'cryptopunks/dataset'
19
26
 
27
+ require 'cryptopunks/colors'
28
+ require 'cryptopunks/image'
29
+
30
+ require 'cryptopunks/generator'
31
+
32
+ ###
33
+ ## add convenience pre-configurated generatored with build-in spritesheet (see config)
34
+
35
+ module Cryptopunks
36
+
37
+ def self.generator
38
+ @generator ||= Generator.new( "#{root}/config/spritesheet.png",
39
+ "#{root}/config/spritesheet.csv" )
40
+ end
41
+
42
+ class Image
43
+ def self.generate( *values )
44
+ img = Cryptopunks.generator.generate( *values )
45
+ ## note: unwrap inner image before passing on to c'tor (requires ChunkyPNG image for now)
46
+ new( img.image )
47
+ end
48
+ end # class Image
49
+ end # module Cryptopunks
50
+
51
+
52
+
53
+
20
54
 
21
55
 
22
56
  module Cryptopunks
@@ -25,6 +59,7 @@ class Tool
25
59
  opts = { zoom: 1,
26
60
  outdir: '.',
27
61
  file: './punks.png',
62
+ offset: 0,
28
63
  }
29
64
 
30
65
  parser = OptionParser.new do |cmd|
@@ -46,6 +81,9 @@ class Tool
46
81
  opts[:file] = file
47
82
  end
48
83
 
84
+ cmd.on("--offset=NUM", "Start counting at offset (default: #{opts[:offset]})", Integer ) do |offset|
85
+ opts[:offset] = offset
86
+ end
49
87
 
50
88
  cmd.on("-h", "--help", "Prints this help") do
51
89
  puts cmd
@@ -59,26 +97,31 @@ class Tool
59
97
  pp opts
60
98
 
61
99
  puts "==> reading >#{opts[:file]}<..."
62
- punks = Image.read( opts[:file] )
100
+ punks = Image::Composite.read( opts[:file] )
63
101
 
64
102
 
65
103
  puts " setting zoom to #{opts[:zoom]}x" if opts[:zoom] != 1
66
- punks.zoom = opts[:zoom] ## note: always reset zoom even if 1
67
104
 
68
105
  ## make sure outdir exits (default is current working dir e.g. .)
69
106
  FileUtils.mkdir_p( opts[:outdir] ) unless Dir.exist?( opts[:outdir] )
70
107
 
71
108
  args.each_with_index do |arg,index|
72
109
  punk_index = arg.to_i
73
- punk_name = "punk-" + "%04d" % punk_index
110
+
111
+ punk = punks[ punk_index ]
112
+
113
+ punk_name = "punk-" + "%04d" % (punk_index + opts[:offset])
74
114
 
75
115
  ## if zoom - add x2,x4 or such
76
- punk_name << "x#{opts[:zoom]}" if opts[:zoom] != 1
116
+ if opts[:zoom] != 1
117
+ punk = punk.zoom( opts[:zoom] )
118
+ punk_name << "x#{opts[:zoom]}"
119
+ end
77
120
 
78
121
  path = "#{opts[:outdir]}/#{punk_name}.png"
79
- puts "==> (#{index+1}/#{args.size}) minting punk ##{punk_index}; writing to >#{path}<..."
122
+ puts "==> (#{index+1}/#{args.size}) minting punk ##{punk_index+opts[:offset]}; writing to >#{path}<..."
80
123
 
81
- punks[ punk_index ].save( path )
124
+ punk.save( path )
82
125
  end
83
126
 
84
127
  puts "done"
@@ -93,6 +136,18 @@ end ## module Cryptopunks
93
136
 
94
137
 
95
138
 
139
+
140
+ ### add more built-in (load on demand) design series / collections
141
+ DESIGNS_ORIGINAL = Cryptopunks::DesignSeries.new( "#{Cryptopunks.root}/config/original" )
142
+ DESIGNS_MORE = Cryptopunks::DesignSeries.new( "#{Cryptopunks.root}/config/more" )
143
+
144
+ ## all designs in one collections
145
+ DESIGNS = {}.merge( DESIGNS_ORIGINAL.to_h,
146
+ DESIGNS_MORE.to_h )
147
+
148
+
149
+
150
+
96
151
  ### add some convenience shortcuts
97
152
  CryptoPunks = Cryptopunks
98
153
  Punks = Cryptopunks
@@ -100,4 +155,10 @@ Punks = Cryptopunks
100
155
 
101
156
 
102
157
 
158
+ ###
159
+ # note: for convenience auto include Pixelart namespace!!! - why? why not?
160
+ include Pixelart
161
+
162
+
163
+
103
164
  puts Cryptopunks.banner # say hello
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptopunks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.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: 2021-02-14 00:00:00.000000000 Z
11
+ date: 2021-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: crypto-lite
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: chunky_png
14
+ name: pixelart
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
@@ -98,6 +84,26 @@ extra_rdoc_files:
98
84
  - CHANGELOG.md
99
85
  - Manifest.txt
100
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
101
107
  files:
102
108
  - CHANGELOG.md
103
109
  - Manifest.txt
@@ -105,13 +111,38 @@ files:
105
111
  - Rakefile
106
112
  - bin/cryptopunk
107
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
134
+ - config/spritesheet.csv
135
+ - config/spritesheet.png
108
136
  - lib/cryptopunks.rb
109
137
  - lib/cryptopunks/attributes.rb
138
+ - lib/cryptopunks/colors.rb
139
+ - lib/cryptopunks/composite.rb
110
140
  - lib/cryptopunks/dataset.rb
141
+ - lib/cryptopunks/generator.rb
111
142
  - lib/cryptopunks/image.rb
112
143
  - lib/cryptopunks/structs.rb
113
144
  - lib/cryptopunks/version.rb
114
- homepage: https://github.com/rubycoco/blockchain
145
+ homepage: https://github.com/cryptopunksnotdead/cryptopunks
115
146
  licenses:
116
147
  - Public Domain
117
148
  metadata: {}