Created
December 5, 2012 01:21
-
-
Save daemongh/4211077 to your computer and use it in GitHub Desktop.
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
def map2png | |
png = ChunkyPNG::Image.new(15, 15, ChunkyPNG::Color::TRANSPARENT) | |
$map.each_with_index do |v, y| | |
v.each_with_index do |_, x| | |
character = $map[x][y] | |
case character | |
when -1 then png[x, y] = ChunkyPNG::Color('black') | |
when 0 then png[x, y] = ChunkyPNG::Color('white') | |
when 1 then png[x, y] = ChunkyPNG::Color('red') | |
when 2 then png[x, y] = ChunkyPNG::Color('green') | |
end | |
end | |
end | |
png.resample_nearest_neighbor!(150, 150) | |
png.save 'map.png' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment