Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldb committed Feb 29, 2024
1 parent df477ae commit 276ef7b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 49 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
###
# don't check in punks.png for testing
# don't check in punks.png and cryptpunks.csv, cryptopunks-classic.csv
# for testing
punks.png
cryptopunks-classic.csv
cryptopunks.csv


###
# skip temporary files for testing only
Expand Down
16 changes: 8 additions & 8 deletions 01_rip.md → 01_crop.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Do-It-Yourself (DIY) - Yes, You Can! - Rip & Save Your Own Punks in Original 24x24 Pixel Format or With 2X / 4X / 8X Zoom
# Do-It-Yourself (DIY) - Yes, You Can! - Crop & Save Your Own Punks in Original 24x24 Pixel Format or With 2X / 4X / 8X Zoom


## Step 0 - Download the True Official Genuine Matt & John's® (Crypto) Punks composite image
Expand All @@ -13,7 +13,7 @@ See [`punks.png` »](https://github.com/larvalabs/cryptopunks/blob/master/punks.



Let's create a script to rip & save punks.
Let's create a script to crop & save punks.

## Step 1 - Read True Official Genuine Matt & John's® (Crypto) Punks composite image

Expand All @@ -25,7 +25,7 @@ punks = ImageComposite.read( './punks.png' )
```


## Step 2 - Start ripping
## Step 2 - Start cropping

Note: By default punks get saved in the original 24x24 pixel format
and the first punk starts at index zero, that is, `0`.
Expand Down Expand Up @@ -92,7 +92,7 @@ in the series.



Let's rip & save punk #0, #18, #40, and #88
Let's crop & save punk #0, #18, #40, and #88
and let's add an offset of 10000
(to start counting at 10000 instead of 0) when saving to disk:

Expand Down Expand Up @@ -135,7 +135,7 @@ Let's try the second pack - that is, punks 100 to 199 in the series.



Let's rip & save punk #0, #79, #80, and #90
Let's crop & save punk #0, #79, #80, and #90
and let's add an offset of 10100
(to start counting at 10000 plus 100 instead of 0):

Expand Down Expand Up @@ -170,7 +170,7 @@ And 4x:
![](i/punk-10190x4.png)


And so on. Happy miniting.
And so on. Happy cropping & saving.



Expand All @@ -179,7 +179,7 @@ And so on. Happy miniting.

## Frequently Asked Questions (F.A.Q.s) and Answers

### Q: How can I rip & save all punks from 0 to 9999 from the Matt & John's 24x24 series?
### Q: How can I crop & save all punks from 0 to 9999 from the Matt & John's 24x24 series?


Use a script with a loop like:
Expand All @@ -188,7 +188,7 @@ Use a script with a loop like:
# step 1: read composite image
punks = ImageComposite.read( './punks.png' )

# step 2: rip & save all punks
# step 2: crop & save all punks
(0..9999).each do |i|
name = '%04d' % i
punks[i].save( "./punk-#{name}.png" )
Expand Down
39 changes: 20 additions & 19 deletions 02_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@

Crypto collectibles are all about rarity - the more rare the type or accessories of a punk the more valuable the 24x24 pixel art in theory.

Let's use the [`cryptopunks.csv` dataset](https://github.com/cryptopunksnotdead/punks)
Let's use the [`cryptopunks.csv` (classic) dataset](https://github.com/cryptopunksnotdead/punks)
in comma-separated values (CSV) format
that houses in blocks of a thousand punks each
(e.g.
`0-999.csv`,
`1000-1999.csv`,
`2000-2999.csv`, and so on)
all the 10 000 punks for more insight into the population.
that houses all the 10 000 punks for more insight into the population.


The data records for punks
Expand All @@ -43,30 +38,30 @@ Let's read in the dataset:


``` ruby
require 'cryptopunks'
require 'punks'

punks = Punks::Dataset.read( './punks/*.csv' )
punks = Punks::Dataset.read( './cryptopunks-classic.csv' )
punks.size
#=> 10000
```

Let the cryptopunks helper do the heavy lifting :-).
Let the punk dataset helper do the heavy lifting :-).
As a bonus all punks get wrapped into easy-to-access structs.
Example:

``` ruby
punk = punks[0]
punk.id
#=> 0
punk.type.name
punk.type
#=> "Female"
punk.accessories.size
#=> 3
punk.accessories[0].name
punk.accessories[0]
#=> "Green Eye Shadow"
punk.accessories[1].name
punk.accessories[1]
#=> "Earring"
punk.accessories[2].name
punk.accessories[2]
#=> "Blonde Bob"
```

Expand All @@ -78,7 +73,7 @@ Let's calculate popularity & rarity by punk types:
``` ruby
counter = Hash.new(0) # a hash (table) - let's (auto-)default to 0 for values
punks.each do |punk|
counter[ punk.type.name ] += 1
counter[ punk.type ] += 1
end

counter.size
Expand Down Expand Up @@ -129,12 +124,12 @@ let's break out the count by punk type:
counter = {}
punks.each do |punk|
punk.accessories.each do |acc|
rec = counter[ acc.name ] ||= { count: 0,
by_type: Hash.new(0)
}
rec = counter[ acc ] ||= { count: 0,
by_type: Hash.new(0)
}

rec[ :count ] += 1
rec[ :by_type ][ punk.type.name ] += 1
rec[ :by_type ][ punk.type ] += 1
end
end

Expand Down Expand Up @@ -323,6 +318,8 @@ stats on the 10 000 punk population.



<!--
**REMINDER: In the digitial world there are no originals! Every copy is a original and you cannot tell the difference
(all 0s and 1s are the same). And, yes, you can always make as many (free) copies as you like (in a free world).
Claiming that you can protect your exclusive rights to pixels because the record of ownership
Expand All @@ -333,3 +330,7 @@ Check your license agreement with LarvaLabs - the pixel art license seller - and
You are a licensee and NOT an owner.**
-->



2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _Inside Unique 24×24 Pixel Art on the Blockchain..._

by [Gerald Bauer](https://github.com/geraldb), et al

- [Do-It-Yourself (DIY) - Yes, You Can! - Rip & Save Your Own Punks in Original 24x24 Pixel Format or With 2X / 4X / 8X Zoom](01_rip.md)
- [Do-It-Yourself (DIY) - Yes, You Can! - Crop & Save Your Own Punks in Original 24x24 Pixel Format or With 2X / 4X / 8X Zoom](01_crop.md)
- [Statistics, Statistics, Statistics - Calculate Rarity & Popularity By Type, By Accessories, & More - Inside the Matt & John's® 10 000 Punks Population](02_attributes.md)
- [Inside the Punk Art Machinery - How To Generate 10 000 Punks (and Punkettes), Algorithmically - Paint by Numbers](03_generate.md)
- [10 000 More Punks - Inside the Punk Art Machinery (Continued) - How To Generate Punks, Algorithmically - Paint by Numbers - A New Punk Series](04_generate_ii.md)
Expand Down
37 changes: 18 additions & 19 deletions attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,41 @@



require 'cryptopunks'
require 'punks'

punks = Punks::Dataset.read( './punks/*.csv' )
punks.size
punks = Punks::Dataset.read( './cryptopunks-classic.csv' )
pp punks.size
#=> 10000



punk = punks[0]
punk.id
pp punk.id
#=> 0
punk.type.name
pp punk.type
#=> "Female"
punk.accessories.size
pp punk.accessories.size
#=> 3
punk.accessories[0].name
pp punk.accessories[0]
#=> "Green Eye Shadow"
punk.accessories[1].name
pp punk.accessories[1]
#=> "Earring"
punk.accessories[2].name
pp punk.accessories[2]
#=> "Blonde Bob"





## Popularity & Rarity by Punk Types (5)

counter = Hash.new(0) # a hash (table) - let's (auto-)default to 0 for values
punks.each do |punk|
counter[ punk.type.name ] += 1
counter[ punk.type ] += 1
end

counter.size
pp counter.size
#=> 5
counter
pp counter
#=> {"Female"=>3840, "Male"=>6039, "Zombie"=>88, "Ape"=>24, "Alien"=>9}


Expand All @@ -61,18 +60,18 @@
counter = {}
punks.each do |punk|
punk.accessories.each do |acc|
rec = counter[ acc.name ] ||= { count: 0,
rec = counter[ acc ] ||= { count: 0,
by_type: Hash.new(0)
}

rec[ :count ] += 1
rec[ :by_type ][ punk.type.name ] += 1
rec[ :by_type ][ punk.type ] += 1
end
end

counter.size
pp counter.size
#=> 87
counter
pp counter
#=> {"Green Eye Shadow"=>{:count=>271,
# :by_type=>{"Female"=>271}},
# "Earring"=>{:count=>2459,
Expand Down Expand Up @@ -109,9 +108,9 @@
counter[ punk.accessories.size ] += 1
end

counter.size
pp counter.size
#=> 8
counter
pp counter
#=> {"3"=>4501, "2"=>3560, "1"=>333, "4"=>1420, "5"=>166, "0"=>8, "6"=>11, "7"=>1}


Expand Down
2 changes: 1 addition & 1 deletion rip.rb → crop.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###
# to run use:
# ruby ./rip.rb
# ruby ./crop.rb


require 'pixelart'
Expand Down

0 comments on commit 276ef7b

Please sign in to comment.