-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathadam.rb
111 lines (87 loc) · 3.42 KB
/
adam.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
###
# to run use:
# ruby ./adam.rb
require 'pixelart'
###
# step 1 - generate 24x24 attributes from 1-bit (black & white) pixel art (in ascii text format)
colors = {
'.' => 0, # transparent
'0' => 'ffffff', # color 0 - white
'1' => '000000', # color 1 - black
}
img = Image.parse( <<TXT, colors: colors )
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . 1 1 1 1 1 1 1 . . . . . . . . .
. . . . . . . 1 0 0 0 0 0 0 0 1 . . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 1 1 0 0 0 1 1 1 . . . . . . .
. . . . . 1 0 0 0 1 0 0 0 0 1 0 1 . . . . . . .
. . . . . 1 0 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . 1 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 1 1 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 1 1 1 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 0 1 . . . . . . .
. . . . . . 1 0 0 0 0 0 0 0 0 1 . . . . . . . .
. . . . . . 1 0 0 0 1 1 1 1 1 . . . . . . . . .
. . . . . . 1 0 0 0 1 . . . . . . . . . . . . .
. . . . . . 1 0 0 0 1 . . . . . . . . . . . . .
TXT
img.save( "./i/attributes/face.png" )
img.zoom(4).save( "./i/attributes/[email protected]" )
hair = Image.parse( <<TXT, colors: colors )
. . . . . 1 . . . . 1 . . . . . . .
. . . . 1 1 1 1 1 1 1 1 1 1 1 . . .
. . . . 1 1 1 1 1 1 1 1 1 1 1 1 . .
. . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 .
1 . . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 .
. . 1 1 1 1 1 1 . . 1 . 1 . 1 . . .
. . 1 1 . . 1 . . . . . . . . . . .
. 1 1 1 . . . . . . . . . . . . . .
. 1 1 . . . . . . . . . . . . . . .
. . 1 . . . . . . . . . . . . . . .
. . 1 . . . . . . . . . . . . . . .
. 1 . . . . . . . . . . . . . . . .
TXT
img = Image.new( 24, 24 )
img.compose!( hair, 2, 2 ) # place in 24x24 canvas (image) with x/y offset
img.save( "./i/attributes/hair.png")
img.zoom(4).save( "./i/attributes/[email protected]")
lasereyes = Image.parse( <<TXT, colors: colors )
. . . . 1 . . . . . 1 . . . .
. . . . 1 . . . . . 1 . . . .
. . . 1 1 1 . . . 1 1 1 . . .
1 1 1 1 0 1 1 . 1 1 0 1 1 1 1
. . . 1 1 1 . . . 1 1 1 . . .
. . . . 1 . . . . . 1 . . . .
. . . . 1 . . . . . 1 . . . .
TXT
img = Image.new( 24, 24 )
img.compose!( lasereyes, 5, 8 ) # place in 24x24 canvas (image) with x/y offset
img.save( "./i/attributes/lasereyes.png")
img.zoom(4).save( "./i/attributes/[email protected]")
###
# step 2 - all-together now - generate 24x24 pixel punk from attributes
punk = Image.new( 24, 24 ) # canvas (image) with transparent background color
punk.compose!( Image.read( "i/attributes/face.png" ))
punk.compose!( Image.read( "i/attributes/hair.png" ))
punk.compose!( Image.read( "i/attributes/lasereyes.png" ))
punk.save( "./i/adam.png" )
punk.zoom(4).save( "i/[email protected]")
punk.zoom(8).save( "i/[email protected]")
punk.mirror.save( "./i/adam_left.png" )
punk.mirror.zoom(4).save( "i/[email protected]")
punk.mirror.zoom(8).save( "i/[email protected]")
punk.flip.save( "./i/adam_flipped.png" ) ## flip horizontally
punk.flip.zoom(4).save( "i/[email protected]")
punk.flip.zoom(8).save( "i/[email protected]")
puts "bye"