Hsin-Po's Website


Postdoc @ UC San Diego

TikZ TeX TalK


a spinning color wheel that seems to be drawing cycloid

% cycloid.tex
\foreach\f in{1,...,90}{ % frame
        \wheel[shift={(\dx,\dy)},rotate=-14]; % help wheel
        \wheel[shift={(-\dx,-\dy)},rotate=14]; % help wheel
        \wheel[]; % main wheel

Convert pdf to gif with terminal command (with ImageMagick installed)

convert -delay 2 cycloid.pdf cycloid.gif

or with this command that does anti-aliasing

convert -delay 2 -density 300 -resize 300x300 cycloid.pdf cycloid.gif

This is inspired by https://twitter.com/jagarikin/status/1331409504953540613.


A former pangram with certain word glowing

% diffuse.tex
    \pdfliteral{q 1 J 1 j 1 Tr}%
    \foreach\mixture in{5,10,...,45}{\relax%
    \pdfliteral{q 4 Tr}%
    \pdfliteral{1 Tr}%
    \foreach\mixture in{95,90,...,55}{\relax%
    Quick \textdiffuse{Blurred Fox}    \\
    Jumps over    \\
    the \textdiffuse{Laser Dog}

Convert pdf to jpg (or png in exchange for file size) with terminal command (with ImageMagick installed)

convert -density 144 -resize 2000 diffuse.pdf diffuse.jpg


Applying inversion transformation to Lenna the image

% inversion.tex
    \expandafter\xdef\csname Inv(\u,\v)x\endcsname{\xx}
    \expandafter\xdef\csname Inv(\u,\v)y\endcsname{\yy}
    \expandafter\xdef\csname#1x\endcsname{\csname Inv(#2,#3)x\endcsname}
    \expandafter\xdef\csname#1y\endcsname{\csname Inv(#2,#3)y\endcsname}
    \draw circle(.05)circle(5)(3,0)node{\LennaIpsum}(12.5,0);
    \foreach\u in{-10,...,10}{
        \foreach\v in{-10,...,10}{
            % Affine transformation of (u, v), unit mm
            % Take inversion, unit mm
            % Remember the coordinates
    \foreach\u in{-10,...,9}{
        \foreach\v in{-10,...,9}{
            % For every square, recall the coordinates of the four corners
            \RecallInversion NW(\u,\V)\RecallInversion NE(\U,\V)
            \RecallInversion SW(\u,\v)\RecallInversion SE(\U,\v)
            % The lower left triangle ◺
                \pgfsettransformentries\aa\ab\ba\bb{\SWx mm}{\SWy mm}
                \path(-\u mm,-\v mm)node{\LennaIpsum};
            % The upper right triangle ◹
                \pgfsettransformentries\aa\ab\ba\bb{\NEx mm}{\NEy mm}
                \path(-\U mm,-\V mm)node{\LennaIpsum};

Convert pdf to jpg with terminal command (with ImageMagick installed)

convert -density 300 inversion.pdf inversion.jpg


Pixelated galaxy is rotating

% galaxy.tex
        % X Y
        1 index      % X Y X
        floor .5 add % X Y U:=floor(X)+.5
        1 index      % X Y U Y
        floor .5 add % X Y U V:=floor(Y)+.5
        2 copy       % X Y U V U V
        2 copy       % X Y U V U V U V
        25 div       % X Y U V U V U v:=V/25
        dup mul      % X Y U V U V U v²
        exch         % X Y U V U V v² U
        25 div       % X Y U V U V v² u:=U/25
        dup mul      % X Y U V U V v² u²
        add sqrt     % X Y U V U V r:=√u²+v²
        360 mul      % X Y U V U V R:=360r
        3 1 roll     % X Y U V R U V
        atan         % X Y U V R θ
        ~ add        % add the phase
        add          % X Y U V τ:=R+θ+phase
        sin          % X Y U V sin(τ)
        dup mul      % X Y U V s:=sin(τ)²
        5 1 roll     % s X Y U V
        3 2 roll     % s X U V Y
        sub 2 mul    % s X U y:=2(V-Y)
        dup mul      % s X U y²
        3 1 roll     % s y² X U
        sub 2 mul    % s y² x:=2(X-U)
        dup mul      % s y² x²
        add          % s q:=y²+x²
        le {0 0 0} {1 1 1} ifelse % s ≤ q ? black : white

ImageMagick does not convert this pdf properly. (In general, it has issues with functional shading.) I ended up using online conversion tools.