Commit 65829e88 authored by Pouya Kary's avatar Pouya Kary

more 2d horizontal drawings lines

parent 25544433
......@@ -105,6 +105,57 @@
result[ height - 1 ] = bottomLine
// done
return result
}
//
// ─── HORIZONTAL 2D LINE ─────────────────────────────────────────────────────────
//
// CreateHorizontalBottomLeftToUpRightLine is a line object from bottom left to
// top right specified by it's `width` and `height`
func CreateHorizontalBottomLeftToUpRightLine( width, height int ) lines.Lines {
// in special case of height == 1
if height == 1 {
return lines.Lines{ createHorizontalLine(
charset.BoxDrawingsLightHorizontal, width ) }
}
// in the normal case which is done within three phases: top line,
// middle vertical line, bottom line.
leftSize, rightSize := computeLineLeftRightSpaces( width )
result := make( lines.Lines, height )
// top line
topLineRightSide := line.Repeat( charset.BoxDrawingsLightHorizontal, rightSize )
topLineLeftSide := line.Repeat( " ", leftSize )
topLine := ( topLineLeftSide + charset.BoxDrawingsLightDownAndRight +
topLineRightSide )
result[ 0 ] = topLine
// middle parts
middleLineLeftSide := line.Repeat( " ", leftSize )
middleLineRightSize := line.Repeat( " ", rightSize )
middleLine := ( middleLineLeftSide + charset.BoxDrawingsLightVertical + middleLineRightSize )
for index := 1; index < height - 1; index++ {
result[ index ] = middleLine
}
// ending bottom line
bottomLineRightSide := line.Repeat( " ", rightSize )
bottomLineLeftSide := line.Repeat( charset.BoxDrawingsLightHorizontal,
leftSize )
bottomLine := ( bottomLineLeftSide + charset.BoxDrawingsLightUpAndLeft +
bottomLineRightSide )
result[ height - 1 ] = bottomLine
// done
return result
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment