Offset a Line Segment based on coordinates or thickness

I’m trying to figure out a way to offset a line segment based on the coordinates or even set thickness. The line will be created on top of the current line segment and needs to be offsetted based on the current line segment (away from the line segment). So lets say I have a square, the top segment needs to offset above, bottom below, left to the left, and right to the right. What’s the best way to achieve an offset?