Sinusoidal text

Python 2, 156 bytes

l=map(int,"654322111%08d1122345"%1);l+=[12-c for c in l]
def f(t):
 h=len(t);o=bytearray(' '*h+'\n')*13;i=0
 for c in t:o[i-~h*l[i%48]]=c;i+=1
 print o[:-1]

Explanation

  • The whole code simply makes a block of spaces (o) and replaces the right spaces with the letters of the input t.

  • The variable l stores a list of offsets from the top. So that the nth character of t should be on line l[n].

  • The bytearray o serves as a mutable string, since strings are immutable in python.

  • -~h is the same as h+1 but saves space because I don't need parentheses.


Java, 219 209 199 bytes

void p(char[]s){int r=6,c;String t="";for(;r>-7;r--,t+='\n')for(c=0;c<s.length;c++)t+=(s(c%48)==r?s[c]:' ');System.out.println(t);}int s(int a){return a<4?a:a<6?4:a<9?5:a<15?6:a<24?s(24-a):-s(a-24);}

I'm still a newbie here, and hope that it is compliant to the rules to introduce a sub-function (when the bytes of this function are counted, of course). If not, I'll try to convert the sin function into some clever array lookup...

public class SinusText
{
    public static void main(String[] args)
    {
        SinusText s = new SinusText();
        s.p(".................................................".toCharArray());
        s.p("Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.".toCharArray());
        s.p("Short text.".toCharArray());
        s.p("The quick brown fox jumps over the lazy dog".toCharArray());
    }
    void p(char[]s){int r=6,c;String t="";for(;r>-7;r--,t+='\n')for(c=0;c<s.length;c++)t+=(s(c%48)==r?s[c]:' ');System.out.println(t);}int s(int a){return a<4?a:a<6?4:a<9?5:a<15?6:a<24?s(24-a):-s(a-24);}
}

Pyth, 59 bytes (57 characters)

Xjb.sC.>V+R*12\ Xz\ C9*+-L12K+JsM._+6jC\཈2tP_JKlz]*dlzC9d

Demonstration.

A binary lookup table is encoded inside , which has value 3912. This is converted to binary, giving [1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0]. This is treated as the differences between consecutive heights. By prepending a 6, forming all prefixes and mapping each to its sum, the first quarter of the wave is generated.

sM._+6jC\཈2 evaluates to [6, 7, 8, 9, 10, 10, 11, 11, 11, 12, 12, 12, 12] as described above. Then, the code concatenates on the reverse of this string to form the first half of the wave, and then subtracts it from 12 to give the entire wave.

Then, we form lines of each input character followed by 12 spaces. This line is rotated to the right by the wave height parameter corresponding to that location, and then the lines are transposed and joined on newlines.

Then, we strip off leading and trailing blank lines. However, we can't strip off leading or trailing blank lines that have spaces from the input. This is implemented by replacing spaces in the input with tabs (C9), which can't be in the input, stripping blank lines, and turning the tabs back into spaces.