Skip to content

Instantly share code, notes, and snippets.

@daemongh
Created December 5, 2012 01:21
Show Gist options
  • Save daemongh/4211077 to your computer and use it in GitHub Desktop.
Save daemongh/4211077 to your computer and use it in GitHub Desktop.
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