Created
November 28, 2012 23:15
-
-
Save akoskovacs/4165455 to your computer and use it in GitHub Desktop.
pgm picture generator (gray gradient pattern)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
HEIGHT = 1024 | |
WIDTH = 1024 | |
f = File.new("sample.pgm", "w") | |
f.puts "P2" | |
f.puts "#{HEIGHT} #{WIDTH}" | |
f.puts 255 | |
f.puts "# Generated by pgen.rb (C) Akos Kovacs" | |
HEIGHT.times do |row| | |
f.puts "# row #{row}" | |
i = 0 | |
b = 0 | |
WIDTH.times do | |
if (i == 255) | |
i = 0 | |
end | |
b += 1 | |
if (b == 20) | |
f.print "\n" | |
b = 0 | |
end | |
f.print "#{i += 1} " | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment