PostScript Flipbook

art ps

Table of Contents

Animations in PostScript .

Code

<< /PageSize [600 400] >> setpagedevice

/sqrt2 2 sqrt def
/sqrt3 3 sqrt def
/isqrt6 1 6 sqrt div def

/project {
    3 dict begin
    /z exch def
    /y exch def
    /x exch def

    x z sub sqrt3 mul isqrt6 mul
    x y 2 mul add z add isqrt6 mul
    % x y sub z add sqrt2 mul isqrt6 mul
    end
} def

/a 100 neg def
/b 100 def

/polygons [
    [[a a a] [a b a] [b b a] [b a a]]
    [[a a b] [a b b] [b b b] [b a b]]
    [[a a a] [a a b] [b a b] [b a a]]
    [[a b a] [a b b] [b b b] [b b a]]
    [[a a a] [a b a] [a b b] [a a b]]
    [[b a a] [b b a] [b b b] [b a b]]
] def

/rotate-x {
    4 dict begin
    /ang exch def
    /z exch def
    /y exch def
    /x exch def

    x
    ang cos y mul ang sin z mul sub
    ang sin y mul ang cos z mul add
    end
} def

/translate-center {
    currentpagedevice /PageSize get
    aload pop
    2 div
    exch
    2 div
    exch
    translate
} def

0 5 359 {
    translate-center
    /rot exch def
    polygons {
        /first true def
        {
            aload pop rot rotate-x project
            first {
                moveto
                /first false def
            } {
                lineto
            } ifelse
        } forall
        closepath
        stroke
    } forall
    showpage
} for

images/ps/flipbook.pdf

GIF

cd images/ps/
convert -delay 10 -alpha off -loop 0 flipbook.pdf flipbook.gif
flipbook.gif

If you have an idea how this page could be improved or a comment send me a mail.