30
2
Introduction
I think everyone agrees that nice pictures have to have a nice frame. But most challenges on this site about ASCII-Art just want the raw picture and don't care about it's preservation.
Wouldn't it be nice if we had a program that takes some ASCII-Art and surrounds it with a nice frame?
The Challenge
Write a program that takes some ASCII-Art as input and outputs it surrounded by a nice frame.
Example:
***** *** * *** *****
becomes
╔═══════╗ ║ ***** ║ ║ *** ║ ║ * ║ ║ *** ║ ║ ***** ║ ╚═══════╝
- You have to use the exact same characters for the frame as in the example:
═ ║ ╔ ╗ ╚ ╝
- The top and the bottom of the frame get inserted before the first and after the last line of the input.
- The left and rights parts of the frame have to have exact one space padding to the widest line of the input.
- There may be no leading or trailing whitespaces in the output. Only a trailing newline is allowed.
- You may assume that the input has no unnecessary leading whitespaces.
- You may assume that the input has no trailing whitespaces on any line.
- You don't have to handle empty input.
- The input will only contain printable ASCII-characters and newlines.
Rules
- Function or full program allowed.
- Default rules for input/output.
- Standard loopholes apply.
- This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.
Happy Coding!
Using some great ASCII-Art, that was produced in any challenge on this site, as input to your program and showing it with a nice frame is highly encouraged!
29A non-ASCII frame for ASCII art? Heresy! – Dennis – 2016-02-16T18:27:04.390
@Dennis I like the irony too :) – Denker – 2016-02-16T18:31:07.077
5Very closely related. Same challenge, but only using a single (ASCII) character for the frame. – Martin Ender – 2016-02-16T18:31:52.147
13(I should clarify I don't think it's a dupe. Having to use 6 different characters makes this a lot trickier. The other challenge can be solved by rotating the grid and appending
#
four times. Adapting such an approach here will be tricky at best, and not viable at worst.) – Martin Ender – 2016-02-16T18:38:02.290@MartinBüttner This is indeed a very similar challenge, did not find it before (guess I should have searched for something more than just
frame
). But I also think its different enough to leave this one open. – Denker – 2016-02-16T18:43:32.9801This is also a multiline challenge, while the previous challenge was only a single line of text. – Neil – 2016-02-16T19:12:47.067
@MartinBüttner According to your rules, this question is a duplicated. Quoting from http://meta.codegolf.stackexchange.com/a/3605/14732 :
– Ismael Miguel – 2016-02-17T01:55:54.637"[...] the differences seem very minor, if someone did adapt an old answer, the heavy lifting would have been done by the user who answered the previous question."
.6@IsmaelMiguel I have won the previous contest and don't see how I could adapt my old answer at all. – Martin Ender – 2016-02-17T06:31:56.880
@MartinBüttner I can. Just replace the "middle section" with multi-line support. Which is exactly what I did. Check the answers below. – Ismael Miguel – 2016-02-17T12:13:27.410
2I suspect that DenkerAffe is assuming CP437 or something where the frame chars are also one byte. – Joshua – 2016-02-17T18:48:02.640