Write language name in 3D ASCII: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: add entry) |
(→{{header|Ruby}}: add banner3D_3 method) |
||
Line 1,822: | Line 1,822: | ||
EOS |
EOS |
||
def |
def banner3D_1(text, shift=-1) |
||
txt = text.each_line.map{|line| line.gsub('#','__/').gsub(' ',' ')} |
txt = text.each_line.map{|line| line.gsub('#','__/').gsub(' ',' ')} |
||
offset = Array.new(txt.size){|i| " " * shift.abs * i} |
offset = Array.new(txt.size){|i| " " * shift.abs * i} |
||
offset.reverse! if shift < 0 |
offset.reverse! if shift < 0 |
||
puts offset.zip(txt).map(&:join) |
|||
end |
end |
||
banner3D_1(text) |
|||
puts |
puts |
||
# |
# Other display: |
||
def |
def banner3D_2(text, shift=-2) |
||
txt = text.each_line.map{|line| line.chomp + ' '} |
txt = text.each_line.map{|line| line.chomp + ' '} |
||
offset = |
offset = txt.each_index.map{|i| " " * shift.abs * i} |
||
offset.reverse! if shift < 0 |
offset.reverse! if shift < 0 |
||
txt.each_with_index do |line,i| |
txt.each_with_index do |line,i| |
||
line2 = line.gsub |
line2 = offset[i] + line.gsub(' ',' ').gsub('#','///').gsub('/ ','/\\') |
||
puts |
puts line2, line2.tr('/\\\\','\\\\/') |
||
puts offset[i] + line2.gsub('#','\\\\\\\\\\').gsub('\ ','\/') |
|||
end |
end |
||
end |
end |
||
banner3D_2(text) |
|||
puts |
|||
# Another display: |
|||
def banner3D_3(text) |
|||
txt = text.each_line.map(&:rstrip) |
|||
offset = [*0...txt.size].reverse |
|||
area = Hash.new(' ') |
|||
box = [%w(/ / / \\), %w(\\ \\ \\ /)] |
|||
txt.each_with_index do |line,i| |
|||
line.each_char.with_index do |c,j| |
|||
next if c==' ' |
|||
x = offset[i] + 2*j |
|||
box[0].each_with_index{|c,k| area[[x+k,i ]] = c} |
|||
box[1].each_with_index{|c,k| area[[x+k,i+1]] = c} |
|||
end |
|||
end |
|||
(xmin, xmax), (ymin, ymax) = area.keys.transpose.map(&:minmax) |
|||
puts (ymin..ymax).map{|y| (xmin..xmax).map{|x| area[[x,y]]}.join} |
|||
end |
|||
banner3D_3 <<EOS |
|||
#### # |
|||
# # # |
|||
# # # |
|||
# # # |
|||
#### # # #### # # |
|||
# # # # # # # # |
|||
# # # # # # # # |
|||
# # # # # # # |
|||
# # ### #### # |
|||
# |
|||
# |
|||
EOS</lang> |
|||
{{out}} |
{{out}} |
||
Line 1,874: | Line 1,906: | ||
///\ |
///\ |
||
\\\/ |
\\\/ |
||
/////////\ ///\ |
|||
///\\\\\///\ ///\/ |
|||
///\/ ///\/ ///\/ |
|||
///\/ ///\/ ///\/ |
|||
/////////\\\/ ///\ ///\ /////////\ ///\ ///\ |
|||
///\///\\\/ ///\/ ///\/ ///\\\\\///\ \///\ ///\\\/ |
|||
///\/\///\ ///\/ ///\/ ///\/ ///\/ \///\///\\\/ |
|||
///\/ \///\ ///\/ ///\/ ///\/ ///\/ \///\\\/ |
|||
///\/ \///\ \///////\/ /////////\\\/ ///\\\/ |
|||
\\\/ \\\/ \\\\\\\/ \\\\\\\\\/ ///\\\/ |
|||
///\\\/ |
|||
\\\/ |
|||
</pre> |
</pre> |
||