note: the string art might look horrible here because of SE font weirdness :P :(
Given a list of four-tuples representing the corners of rectangles, draw translucent rectangles over each other in that order.
For this challenge, you are required to have the smallest coordinate in the top-left corner and the x-axis increasing to the right and the y-axis increasing downwards.
A four-tuple (x0, y0, x1, y1)
or (x0, x1, y0, y1)
represents the (x, y)
coordinate pairs of the top-left and bottom-right corners of a rectangle (you may choose either of the two formats for rectangles but it must be consistent)
What do I mean by "translucent rectangle"? Well, for this challenge, you will be using the space character and most of the box-drawing characters; specifically, all of the ones used to draw rectangles, including "bold" characters. When a translucent rectangle is drawn, first all thin lines in the space being occupied disappear and all bold lines become thin, and then the rectangle itself is drawn over in bold lines.
For example, if you draw a rectangle in the top-left and then in the bottom-right, it might look something like this:
┏━━━━┓
┃ ┃
┃ ┃
┃ ┏━━╇━━┓
┃ ┃ │ ┃
┗━╉──┘ ┃
┃ ┃
┃ ┃
┗━━━━━┛
To be clear, lines are lightened (bold -> thin -> none) for all lines strictly within the rectangle (for example, downwards facing lines are affected for the top edge but not the bottom edge).
Test Cases
Some number of lines of input will be given, followed by unicode-art, for each test case.
0 0 5 5
5 5 10 10
3 3 7 7
2 2 8 8
┏━━━━┓
┃ ┃
┃ ┏━━╇━━┓
┃ ┃┌─┴─┐┃
┃ ┃│ │┃
┗━╉┤ ├╊━┓
┃│ │┃ ┃
┃└─┬─┘┃ ┃
┗━━╈━━┛ ┃
┃ ┃
┗━━━━┛
14 5 15 9
13 2 15 16
6 4 15 11
┏━┓
┃ ┃
┏━━━━━━╇━┫
┃ │ ┃
┃ │ ┃
┃ │ ┃
┃ │ ┃
┃ │ ┃
┃ │ ┃
┗━━━━━━╈━┫
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┗━┛
6 8 10 11
15 12 16 16
14 10 16 16
9 1 15 15
┏━━━━━┓
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┃ ┃
┏━━╉┐ ┃
┃ ┃│ ┃
┃ ┃│ ┌╊┓
┗━━╉┘ │┃┃
┃ │┠┨
┃ │┃┃
┃ │┃┃
┗━━━━╈┩┃
┗┷┛
Rules
- Input can be in any reasonable format for a list of four-tuples. Input can be one-indexed or zero-indexed along either axis (i.e. the top-left corner can be any of
(0, 0)
,(0, 1)
,(1, 0)
,(1, 1)
. - Output must be as unicode-art as described. Output may not have leading newlines and can have at most one trailing newline (after the last line). Trailing whitespace will be ignored for the purposes of this challenge.
Code-points
The bold and light horizontal and vertical pipes are in the range [U+2500, U+2503]
. The various corner pipes are in the range [U+250C, U+251C)
. The three-armed pipes are in the range [U+251C, U+253C)
. The four-armed pipes are in the range [U+253C, U+254C)
. The remaining pipes that can be found in my program are never actually used.
Typically this uses only 95 printable (from a total of 128) characters defined by the ASCII Standard from 1963.
\$\endgroup\$