Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # frozen_string_literal: true
- require 'chunky_png'
- ascii = <<~ASCII
- @@@@@@ @@@@@@
- @@@@@@@@@@ @@@@@@@@@@
- @@@@@@@@@@@@@@ @@@@@@@@@@@@@@
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@
- @@@@@@@@@@@@ @@@@@@@@@@@@
- @@@@@@@@@@ @@@@@@@@@@
- @@@@@@@@@@@ @@@@@@@@@@@
- @@@@@@@@@@@@ @@@@@@@@@@@@
- @@@@@@@@@@@@@ @@@@@@@@@@@@@
- @@@@@@@@@@@@@@ @@@@@@@@@@@@@@
- @@@@@@@@@@@@@ @@@@@@@@@@@@@
- @@@@@@@@@@@@@@@@@@@@@
- @@@@@@@@@@@@@@@
- @@@@@@@@@@@
- @@@@@@@
- @@@
- @
- ASCII
- lines = ascii.lines
- horizontal = lines.max_by(&:size).size
- vertical = lines.size * 2
- red = [255, 0, 0]
- alpha = 255
- filename = 'ruby.png'
- png = ChunkyPNG::Image.new(horizontal, vertical, ChunkyPNG::Color::TRANSPARENT)
- lines.flat_map { |line| [line, line] }.each_with_index do |line, y|
- line.each_char.with_index do |char, x|
- png[x, y] = ChunkyPNG::Color.rgba(*red, alpha) if char != ' '
- end
- end
- png.save(filename, interlace: true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement