Default
61 |
Just display a representation of binary data.
62 |
pixelchart draw test.csv test.png -w 100 -h 100 -s 3
63 |
64 |

65 |
Prime numbers
66 |
A representation of prime numbers under 10,000.
67 |
require 'pixelchart'
68 | require 'prime'
69 |
70 | primes = (1..10000).map{ |i| Prime.prime?(i) }
71 | options = {
72 | colors: [[255,255,255],[255,20,147]],
73 | scale: 5
74 | }
75 | im = PixelChart.new(primes, 100, 100, options)
76 | im.draw('primes.png')
77 |
78 |

79 |
Malware hash
80 |
Create a unique fingerprint image for a malware (eg.
81 | VirusTotal).
82 |
require 'pixelchart'
83 | require 'ctf_party'
84 |
85 | sha256 = '142b638c6a60b60c7f9928da4fb85a5a8e1422a9ffdc9ee49e17e56ccca9cf6e'.hex2bin.split('')
86 | sha256.map! { |x| x.to_i }
87 | options = {
88 | colors: [:random,:random],
89 | scale: 50
90 | }
91 | im = PixelChart.new(sha256, 23, 11, options)
92 | im.draw('virus.png')
93 |
94 |

95 |
Random data
96 |
Create an image with random data, for example for a default profile image on a
97 | forum.
98 |
require 'pixelchart'
99 |
100 | data = (0 ... 10000).map {|_i| rand(2) }
101 | options = {
102 | colors: [[0,255,127],[0,0,0]],
103 | scale: 5
104 | }
105 | im = PixelChart.new(data, 100, 100, options)
106 | im.draw('random.png')
107 |
108 |

109 |
The logo
110 |
The PixelChart logo was designed pixel by pixel on a 7*7 square.
111 |
░▓▓▓▓▓░
112 | ░░▓░▓▓░
113 | ░░▓░░▓░
114 | ░░▓▓▓▓░
115 | ░░▓░░░░
116 | ░░▓░░░░
117 | ░░▓░░░░
118 |
119 |
Then convert black and white pixel to 1 and 0.
120 |
0,1,1,1,1,1,0
121 | 0,0,1,0,1,1,0
122 | 0,0,1,0,0,1,0
123 | 0,0,1,1,1,1,0
124 | 0,0,1,0,0,0,0
125 | 0,0,1,0,0,0,0
126 | 0,0,1,0,0,0,0
127 |
128 |
Inline.
129 |
0,1,1,1,1,1,0,0,0,1,0,1,1,0,0,0,1,0,0,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0
130 |
131 |
Then map the data and choose some colors.
132 |
require 'pixelchart'
133 |
134 | data = [0,1,1,1,1,1,0,0,0,1,0,1,1,0,0,0,1,0,0,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0]
135 | options = {
136 | colors: [[0,0,0],[0,255,127]],
137 | scale: 30
138 | }
139 | im = PixelChart.new(data, 7, 7, options)
140 | im.draw('logo.png')
141 |
142 |
Tada! The logo is done!
143 |

144 |