Python 2 - 331 = import sys l=[s[:-1]for s in sys.stdin] d=(int(l[-1])+315)/90%4 l=l[:-1] r=len(l)-1 c=len(max(l,key=len))-1 a=d/2 b=d%2 k=r+c+1 x=a^b z=1-x*2 t=1-a*2 m=[[' ']*k for i in range(k)] for i in range(r+1): for j in range(len(l[i])): h=l[i][j] if h>' ':m[a*c+x*r+z*i+t*j][r-a*r+x*c-t*i+z*j]='\\/'[(h>'_')^b] for s in m:print''.join(s) I strongly suspect it can be golfed much more, tips are welcome. Examples: % python r45.py <<< "|| ----- 45" / \ / \ \ \ \ % python r45.py <<< " _ | |_ |___| -45" / \ / \ / / \ / \ If the 2nd one looks misaligned, that's because of some issues with the question: First, the underscore is at the bottom of the character "cell", while the pipe, slash and backslash are all in the middle. It would be fairer to use a dash (-) instead of underscore. Second, with the rotation of the heart in the question, you couldn't represent it in any reasonable way if the first line was `___` (3 underscores) instead of ` _`, as the 1st and 3rd underscore would be "capping" the pipes in the 2nd line.