public class LineKit
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
exteriorCircleLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
exteriorDiamondLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
exteriorPlus
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
exteriorPlusLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
exteriorSquare
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
exteriorSquareLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static char[] |
heavy |
static char[] |
heavyAlt |
static long |
interiorCircleLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
interiorDiamondLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
interiorPlus
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
interiorPlusLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
interiorSquare
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
interiorSquareLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static char[] |
light |
static char[] |
lightAlt |
static long |
shallowerExteriorSquareLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
shallowerInteriorSquareLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
shallowExteriorSquareLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
static long |
shallowInteriorSquareLarge
A constant that represents the encoded pattern for a 4x4 square with all lines possible except those that
would extend to touch cells adjacent to the 4x4 area.
|
Constructor and Description |
---|
LineKit() |
Modifier and Type | Method and Description |
---|---|
static char[][] |
decode4x4(long encoded)
Produces a 4x4 2D char array by interpreting the bits of the given long as line information.
|
static char[][] |
decode4x4(long encoded,
char[] symbols)
Produces a 4x4 2D char array by interpreting the bits of the given long as line information.
|
static char[][] |
decodeInto4x4(long encoded,
char[] symbols,
char[][] into,
int startX,
int startY)
Fills a 4x4 area of the given 2D char array
into by interpreting the bits of the given long as line
information. |
static long |
encode4x4(char[][] decoded)
Reads a 2D char array
decoded , which must be at least 4x4 in size, and returns a long that encodes the cells from 0,0 to
3,3 in a way that this class can interpret and manipulate. |
static long |
flipHorizontal4x4(long encoded)
Makes a variant on the given encoded 4x4 pattern so the left side is flipped to the right side and vice versa.
|
static long |
flipVertical4x4(long encoded)
Makes a variant on the given encoded 4x4 pattern so the top side is flipped to the bottom side and vice versa.
|
static char[][] |
pruneLines(char[][] map,
GreasedRegion seen,
char[][] writeInto)
Adjusts an existing map that uses box-drawing characters so non-visible line segments aren't rendered.
|
static char[][] |
pruneLines(char[][] map,
GreasedRegion seen,
char[] symbols,
char[][] writeInto)
Adjusts an existing map that uses box-drawing characters so non-visible line segments aren't rendered.
|
static long |
rotateClockwise(long encoded)
Makes a variant on the given encoded 4x4 pattern so the lines are rotated 90 degrees clockwise, changing their
positions as well as what chars they will decode to.
|
static long |
rotateCounterclockwise(long encoded)
Makes a variant on the given encoded 4x4 pattern so the lines are rotated 90 degrees counterclockwise, changing
their positions as well as what chars they will decode to.
|
static long |
transpose4x4(long encoded)
Makes a variant on the given encoded 4x4 pattern so the x and y axes are interchanged, making the top side become
the left side and vice versa, while the bottom side becomes the right side and vice versa.
|
public static final char[] lightAlt
public static final char[] heavyAlt
public static final char[] light
public static final char[] heavy
public static final long interiorSquare
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long exteriorSquare
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long interiorPlus
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long exteriorPlus
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long interiorSquareLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long exteriorSquareLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long shallowInteriorSquareLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long shallowExteriorSquareLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long shallowerInteriorSquareLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long shallowerExteriorSquareLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long interiorPlusLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long exteriorPlusLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long interiorCircleLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long exteriorCircleLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long interiorDiamondLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static final long exteriorDiamondLarge
LineKit.interiorSquare & encoded
.
If you limit the area to the square with this, you may sometimes want to add a border, and for that you can use
exteriorSquare
and bitwise OR that with the restricted area.
"┌┬┬┐" "├┼┼┤" "├┼┼┤" "└┴┴┘"
public static char[][] decode4x4(long encoded)
light
, which are compatible with most fonts.encoded
- a long, which can be random, that encodes some pattern of (typically box drawing) characterspublic static char[][] decode4x4(long encoded, char[] symbols)
light
, heavy
,
lightAlt
, or heavyAlt
, with the last two usable only if using a font that supports the chars
╴╵╶╷
(this is true for Iosevka and Source Code Pro, for instance, but not Inconsolata or GoMono).encoded
- a long, which can be random, that encodes some pattern of (typically box drawing) characterssymbols
- a 16-element-or-larger char array; usually a constant in this class like light
public static char[][] decodeInto4x4(long encoded, char[] symbols, char[][] into, int startX, int startY)
into
by interpreting the bits of the given long as line
information. Uses the given char array symbols
, which must have at least 16 elements and is usually one
of light
, heavy
, lightAlt
, or heavyAlt
, with the last two usable only if
using a font that supports the chars ╴╵╶╷
(this is true for Iosevka and Source Code Pro, for instance,
but not Inconsolata or GoMono).encoded
- a long, which can be random, that encodes some pattern of (typically box drawing) characterssymbols
- a 16-element-or-larger char array; usually a constant in this class like light
into
- a 2D char array that will be modified in a 4x4 areastartX
- the first x position to modify in intostartY
- the first y position to modify in intopublic static long encode4x4(char[][] decoded)
decoded
, which must be at least 4x4 in size, and returns a long that encodes the cells from 0,0 to
3,3 in a way that this class can interpret and manipulate. The 2D array decoded
must contain box drawing
symbols, which can be any of those from light
, heavy
, lightAlt
, or heavyAlt
.
Valid chars are ╴╵┘╶─└┴╷┐│┤┌┬├┼╸╹┛╺━┗┻╻┓┃┫┏┳┣╋
; any other chars will be treated as empty space.decoded
- a 2D char array that must be at least 4x4 and should usually contain box drawing characterspublic static long flipHorizontal4x4(long encoded)
encoded
- an encoded pattern long that represents a 4x4 areapublic static long flipVertical4x4(long encoded)
encoded
- an encoded pattern long that represents a 4x4 areapublic static long transpose4x4(long encoded)
encoded
- an encoded pattern long that represents a 4x4 areapublic static long rotateClockwise(long encoded)
rotateCounterclockwise(long)
should be used for a 270 degree rotation.encoded
- an encoded pattern long that represents a 4x4 areapublic static long rotateCounterclockwise(long encoded)
rotateClockwise(long)
should be used for a 270 degree rotation.encoded
- an encoded pattern long that represents a 4x4 areapublic static char[][] pruneLines(char[][] map, GreasedRegion seen, char[][] writeInto)
DungeonUtility.hashesToLines(char[][])
and a GreasedRegion that
stores already-seen cells, and writes an altered version of the 2D char array map
to writeInto
,
leaving non-box-drawing chars unchanged. This method modifies writeInto in-place, and also returns it after those
changesare made. The way this works is explained well with an example: if the player is north of a T-junction
wall, '┬', then unless he has already explored the area south of his position, the bottom segment of the wall
isn't visible to him, and so '─' should be rendered instead of '┬'. If a cell has already been seen, it is
considered still visible for the purpose of calculating shown segments (it won't change once you leave an area).map
- a 2D char array that should have been produced by DungeonUtility.hashesToLines(char[][])
seen
- a GreasedRegion where "on" cells are visible now or were visible in the pastwriteInto
- a 2D char array that must have at least the dimensions of map; will be modifiedpublic static char[][] pruneLines(char[][] map, GreasedRegion seen, char[] symbols, char[][] writeInto)
DungeonUtility.hashesToLines(char[][])
a GreasedRegion that stores
already-seen cells, an optional char array that refers to a line drawing style constant in this class (defaults
to light
, and writes an altered version of the 2D char array map
to writeInto
, leaving
non-box-drawing chars unchanged. This method modifies writeInto in-place, and also returns it after those changes
are made. The way this works is explained well with an example: if the player is north of a T-junction wall, '┬',
then unless he has already explored the area south of his position, the bottom segment of the wall isn't visible
to him, and so '─' should be rendered instead of '┬'. If a cell has already been seen (it is true in
seen
), it is considered still visible for the purpose of calculating shown segments (that is, it won't
change once you leave an area).map
- a 2D char array that should have been produced by DungeonUtility.hashesToLines(char[][])
seen
- a GreasedRegion where "on" cells are visible now or were visible in the pastsymbols
- a char array that should be light
or heavy
unless you know your font supports
the chars "╴╵╶╷", in which case you can use lightAlt
, or the heavy-weight versions of
those chars, in which case you can use heavyAlt
writeInto
- a 2D char array that must have at least the dimensions of map; will be modifiedCopyright © Eben Howard 2012–2022. All rights reserved.