DIY (Do-It-Yourself) - 是的,你可以! 像素艺术集快速入门 - 以算法生成自己的精选 (或随机) 集合
DIY (Do-It-Yourself) - 是的,你可以! 像素艺术集快速入门 - 以算法生成自己的精选 (或随机) 集合
Note: See /punks.whitelabel - The Free White Label Punk Quick Starter Edition - if you want to (re)create from zero / scratch a pixel-perfect copy of the Matt & John's® 10 000 punks collection (anno 2017).
Table of Contents / Sample Collections
Collection №1 - Twenty-Five Dodge Pixel Art Punks
Collection №2 - The First One Hundred Pixel Art Punks
Collection №4 - 111 Cool Blue Aliens (Incl. Females & Super-Rare Apes)
Let's start and generate algorithmically a pixel art collection in three steps:
Step 1 - Generate A List of Your Pixel Art Collection in a Tabular Text Format (Spreadsheet)
Step 2 - Generate All Pixel Art Images in Original Format and In 20x
Step 3 - Bonus: Generate an All-In-One Composite Image
Let's start with an exclusive twenty-five Shiba Inu dogs pixel art collection. Much wow. Super rare.
Let's copy and (re)use all punk (building) blocks in the dodge series (24×24):
Classic , Dark , Zombie , Alien
Attributes (by category and a-z):
(Source: Punk (Building) Blocks - Dodge Series (24×24))
In the first sample let's generate the list of the pixel art collection
by hand. Let's use a rarity & popularity distribution of
10 classic Shibas, 7 darkies, 5 zombies and 3 aliens. Example - dodge.csv:
…Yes, that's it. For the list format let's use the comma-separated values (.CSV) format supported by all spreadsheet programs. Every line is a record of a punk made up of the original type and one or more attributes.
Note: Let's NOT add the index number (0,1,2,3, and so on). Why? That way you can easily reshuffle your collection anytime. Let's try a more "random" look by hand:
…Now the "magic" let's read in the list in the comma-separated values (.CSV) format and generate all pixel art images in the original format (24×24) and in 20x (480×480).
require './boot'
recs = read_csv( './no1/dodge.csv' )
puts " #{recs.size} punk(s)"
#=> 25 punk(s)
art = Art.new( dir: './dodge' )
recs.each_with_index do |rec,i|
name = "punk#{i}"
punk = art.generate( rec )
punk.save( "./o/no1/#{name}.png" )
punk.zoom(20).save( "./o/no1/#{name}@20x.png" )
endYes, that's it. Run the script to generate algorithmically your collection.
In the /o directory you will now find
two images per punk - in the orginal format, that is, 24×24
and 20x, that is, 480×480 - and get:
no1/
punk0.png
[email protected]
punk1.png
[email protected]
punk2.png
[email protected]
punk3.png
[email protected]
punk4.png
[email protected]
punk5.png
[email protected]
punk6.png
[email protected]
punk7.png
[email protected]
punk8.png
[email protected]
...Let's open up punk0.png to punk24.png:
And let's have a looksie at the biggie 20x (480×480) versions:
[...]
Note: If you use your own artwork
make sure your type and attribute names
used in the list in the comma-separated values (.CSV) format
match the filenames (without the .png extension).
For the matching algorithm all names
get automatically downcased and all spaces deleted,
thus,
Classic will map to classic.png
and 3D Glasses to 3dglasses.png
and Knitted Cap to knittedcap.png
and so on.
Let's generate an all-in-one composite image holding the complete collection in a 5×5 grid.
…Note: The attributes (see above) come
in two editions, that is, m - male (stored in the /m directory)
and f - female (stored in the /f directory).
To map the attribute (or "qualify"
the name with an extra auto-added directory)
let's configure
the "qualifier" by archetype, that is,
Male 1/2/3/4, Zombie, Ape and Alien will auto-add the /m directory
to the attribute image lookup and
Female 1/2/3/4 will aut-add the /f directory.
Yes, that's it. Run the script to generate algorithmically your collection.
In the /o directory you will now find
two images per punk - in the orginal format, that is, 24×24
and 20x, that is, 480×480 - and get:
no2/
punk0.png
[email protected]
punk1.png
[email protected]
punk2.png
[email protected]
punk3.png
[email protected]
punk4.png
[email protected]
punk5.png
[email protected]
punk6.png
[email protected]
punk7.png
[email protected]
punk8.png
[email protected]
...Let's open up punk0.png to punk99.png:
And let's have a looksie at the biggie 20x (480×480) versions:
[...]
Again let's generate an all-in-one composite image holding the complete collection in a 10×10 grid.
…What's different from Collection №2 - The First One Hundred Pixel Art Punks?
Two new achetypes, that is, Alien Ape and Alien Female in the qualifier setting / configuration. Yes, that's it. Run the script to generate algorithmically your collection.
In the /o directory you will now find
two images per punk - in the orginal format, that is, 24×24
and 20x, that is, 480×480 - and get:
no4/
punk0.png
[email protected]
punk1.png
[email protected]
punk2.png
[email protected]
punk3.png
[email protected]
punk4.png
[email protected]
punk5.png
[email protected]
punk6.png
[email protected]
punk7.png
[email protected]
punk8.png
[email protected]
...Let's open up punk0.png to punk110.png:
And let's have a looksie at the biggie 20x (480×480) versions:
[...]
And open up punks.png for the all-in-one composite:
To be continued...
Q: Can I use a different pixel format for the collection e.g. 16×16 (instead of the classic 24×24)?
A: Yes, it works with any square pixel size (e.g. 16×16, 24×24, 32×32).
Note: If you use the CompositeImage the default width × height is set to 24 × 24 - if you use a different size
you have to pass in width and height e.g.
# 5×5 grid with every tile 16×16
composite = CompositeImage.new( 5, 5, width: 16, height: 16 )Q: I am trying to make a composite of 30 variations with a base size of 125×125 px each. I can't seem to figure out how to adjust the settings to make it generate a composite without all of the results overlapping each other. Any ideas?
The CompositeImage defaults to width: 24, height: 24, thus, if you use a different dimension / canvas you have to pass along the "custom" width and height. Example with a 10×3 grid (equal to 30 tiles / variations) and 125×125 width x height:
composite = CompositeImage.new( 10, 3, width: 125, height: 125 )Q: Is it possible to have more attributes, that is, seven instead of the five used in the sample collection №2?
Yes, you can use as many attributes as you like (no limit really other than the computer processing power and memory) for the scripts / collections.
If you want to use seven attributes - add two more attributes to the tabular dataset - change:
type, attribute1, attribute2, attribute3, attribute4, attribute5
Female 2, Earring, Blonde Bob, Green Eye Shadow
...to
type, attribute1, attribute2, attribute3, attribute4, attribute5, attribute6, attribute7
Female 2, Earring, Blonde Bob, Green Eye Shadow
...That's it. By the way - the column names are "arbitrary", that is, yes you can use any name e.g. try hair, eyes, mouth, neck or such instead of attribute1, attribute2, etc.
Q: I cannot get the ./generate.rb script to run [in Powershell / in Sublime / in ...]?
A: Make sure you run the script in the "top-level", that is, /punks.starter and you use no1/generate.rb or no2/generate.rb or no3/generate.rb:
/punks.starter
boot.rb
/no1
dodge.csv
generate.rb
/no2
punks.csv
generate.rb
/no3
punks.csv
generate.rbAnd run inside the /punks.starter directory:
$ ruby no1/generate.rb # start in /punks.starterPost them on the D.I.Y. Punk (Pixel) Art reddit. Thanks.
暂无开放 Issues,或尚未同步最近议题。