迎接2019年圓周率日:如何畫出字母π?

迎接2019年圓周率日:如何畫出字母π?

首先:別忘了,就在140年前,艾爾伯特愛因斯坦出生於;但就在一年前,史蒂芬·威廉·霍金去世了。對科學來說,這是多麼特別的一天啊!


問題

如何字母 π不是以標準方式(即\pi)?

我的意思是“畫”,而不是“打字”!今天不會有\pi,但是會有這樣的事情

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,2)--(3,2);
\draw (1,0)--(1,2);
\draw (2,0)--(2,2);
\end{tikzpicture}
\end{document}

在此輸入影像描述

(靈感來自大衛卡萊爾– 我用 Ti 畫的kZ只是因為我不知道如何使用picture;))

或這個

\documentclass[tikz]{standalone}
\usepackage{tikzducks}
\begin{document}
\begin{tikzpicture}
\duck
\duck[xshift=1cm,yshift=2cm]
\duck[xshift=1cm,yshift=4cm]
\duck[xshift=1cm,yshift=6cm]
\duck[xshift=0cm,yshift=8cm]
\duck[xshift=-2cm,yshift=7.5cm]
\duck[xshift=2cm,yshift=8cm]
\duck[xshift=4cm,yshift=8cm]
\duck[xshift=6cm,yshift=8cm]
\duck[xshift=8cm,yshift=8cm]
\duck[xshift=5cm,yshift=6cm]
\duck[xshift=5cm,yshift=4cm]
\duck[xshift=5.5cm,yshift=2cm]
\duck[xshift=6.5cm,yshift=0cm]
\duck[xshift=8cm,yshift=1cm]
\node[font=\huge] at (4,11) {Happy $\pi$ day with \verb|tikzducks|!};
\end{tikzpicture}
\end{document}

在此輸入影像描述

它們是我最自豪的 π 繪圖,由於今天是 π 日,我想看看你的!


那麼,我為什麼不把提問時間延後8分鐘呢?我是在 UTC 時間 1:51:31 提出這個問題的,而今年的「Pi 秒」就是今天的 1:59:26!

答案1

這是一個\shapepar,非常感謝流程框架

在此輸入影像描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{shapepar}

\newcommand{\sep}{\discretionary{}{}{}}

\begin{document}

\small%
\shapepar[1.00375pt]{{137.821777}%
{0.0}b{27.0}%
\\{0.0}t{27.0}{249.0}%
\\{11.955168}t{14.0}{250.0}%
\\{23.910336}t{2.0}{249.0}%
\\{27.074219}t{0.0}{135.5}st{135.5}{111.5}%
\\{35.865504}t{57.0}{35.0}t{179.0}{35.0}%
\\{47.820672}t{56.0}{34.0}t{178.0}{34.0}%
\\{59.775841}t{55.0}{34.0}t{177.0}{34.0}%
\\{71.731009}t{53.0}{35.0}t{175.0}{35.0}%
\\{83.686177}t{52.0}{34.0}t{174.0}{34.0}%
\\{95.641345}t{51.0}{34.0}t{173.0}{34.0}%
\\{107.596513}t{49.0}{35.0}t{171.0}{35.0}%
\\{119.551681}t{48.0}{34.0}t{170.0}{34.0}%
\\{131.506849}t{47.0}{34.0}t{169.0}{34.0}%
\\{135.137695}t{46.0}{35.0}t{168.0}{35.0}%
\\{143.462017}t{45.0}{35.0}t{168.0}{34.0}%
\\{154.276367}t{44.0}{34.0}t{166.0}{35.0}%
\\{155.417186}t{44.0}{34.0}t{166.0}{35.0}%
\\{163.378906}t{43.0}{34.0}t{166.0}{34.0}%
\\{167.372354}t{43.0}{34.0}t{165.0}{35.0}t{256.0}{3.0}%
\\{171.936859}t{42.0}{34.0}t{165.0}{35.0}t{253.0}{8.0}%
\\{179.327522}t{41.0}{35.0}t{165.0}{35.0}t{248.0}{13.0}%
\\{182.050781}t{41.0}{34.0}t{165.0}{36.0}t{245.0}{15.0}%
\\{187.185547}t{40.0}{35.0}t{166.0}{36.0}t{240.0}{17.0}%
\\{191.28269}t{40.0}{34.0}t{166.0}{39.0}t{235.0}{19.0}%
\\{193.214996}t{40.0}{34.0}t{166.0}{40.0}t{232.0}{20.0}%
\\{197.688477}t{39.0}{35.0}t{167.0}{50.0}jt{217.0}{31.0}%
\\{198.388672}t{39.0}{35.0}t{167.0}{80.0}%
\\{203.237858}t{39.0}{34.0}t{169.0}{72.0}%
\\{207.880219}t{38.0}{34.0}t{171.0}{64.0}%
\\{207.958008}t{38.0}{34.0}t{171.0}{64.0}%
\\{215.193026}t{37.0}{19.0}t{175.0}{49.0}%
\\{215.660156}t{37.0}{18.0}t{176.0}{47.0}%
\\{222.195312}t{37.0}{2.0}t{186.0}{23.0}%
\\{222.195312}e{37.0}%
\\{223.362305}t{191.0}{13.0}%
\\{223.362305}e{191.0}%
}%
3\sep{}.\sep{}1\sep{}4\sep{}1\sep{}5\sep{}9\sep{}2\sep{}6\sep{}5\sep{}3\sep{}5\sep{}8\sep{}9\sep{}7\sep{}9\sep{}3\sep{}2\sep{}3\sep{}8\sep{}4\sep{}6\sep{}2\sep{}6\sep{}4\sep{}3\sep{}3\sep{}8\sep{}3\sep{}2\sep{}7\sep{}9\sep{}5\sep{}0\sep{}2\sep{}8\sep{}8\sep{}4\sep{}1\sep{}9\sep{}7\sep{}1\sep{}6\sep{}9\sep{}3\sep{}9\sep{}9\sep{}3\sep{}7\sep{}5\sep{}1\sep{}0\sep{}5\sep{}8\sep{}2\sep{}0\sep{}9\sep{}7\sep{}4\sep{}9\sep{}4\sep{}4\sep{}5\sep{}9\sep{}2\sep{}3\sep{}0\sep{}7\sep{}8\sep{}1\sep{}6\sep{}4\sep{}0\sep{}6\sep{}2\sep{}8\sep{}6\sep{}2\sep{}0\sep{}8\sep{}9\sep{}9\sep{}8\sep{}6\sep{}2\sep{}8\sep{}0\sep{}3\sep{}4\sep{}8\sep{}2\sep{}5\sep{}3\sep{}4\sep{}2\sep{}1\sep{}1\sep{}7\sep{}0\sep{}6\sep{}7\sep{}9\sep{}8\sep{}2\sep{}1\sep{}4\sep{}8\sep{}0\sep{}8\sep{}6\sep{}5\sep{}1\sep{}3\sep{}2\sep{}8\sep{}2\sep{}3\sep{}0\sep{}6\sep{}6\sep{}4\sep{}7\sep{}0\sep{}9\sep{}3\sep{}8\sep{}4\sep{}4\sep{}6\sep{}0\sep{}9\sep{}5\sep{}5\sep{}0\sep{}5\sep{}8\sep{}2\sep{}2\sep{}3\sep{}1\sep{}7\sep{}2\sep{}5\sep{}3\sep{}5\sep{}9\sep{}4\sep{}0\sep{}8\sep{}1\sep{}2\sep{}8\sep{}4\sep{}8\sep{}1\sep{}1\sep{}1\sep{}7\sep{}4\sep{}5\sep{}0\sep{}2\sep{}8\sep{}4\sep{}1\sep{}0\sep{}2\sep{}7\sep{}0\sep{}1\sep{}9\sep{}3\sep{}8\sep{}5\sep{}2\sep{}1\sep{}1\sep{}0\sep{}5\sep{}5\sep{}5\sep{}9\sep{}6\sep{}4\sep{}4\sep{}6\sep{}2\sep{}2\sep{}9\sep{}4\sep{}8\sep{}9\sep{}5\sep{}4\sep{}9\sep{}3\sep{}0\sep{}3\sep{}8\sep{}1\sep{}9\sep{}6\sep{}4\sep{}4\sep{}2\sep{}8\sep{}8\sep{}1\sep{}0\sep{}9\sep{}7\sep{}5\sep{}6\sep{}6\sep{}5\sep{}9\sep{}3\sep{}3\sep{}4\sep{}4\sep{}6\sep{}1\sep{}2\sep{}8\sep{}4\sep{}7\sep{}5\sep{}6\sep{}4\sep{}8\sep{}2\sep{}3\sep{}3\sep{}7\sep{}8\sep{}6\sep{}7\sep{}8\sep{}3\sep{}1\sep{}6\sep{}5\sep{}2\sep{}7\sep{}1\sep{}2\sep{}0\sep{}1\sep{}9\sep{}0\sep{}9\sep{}1\sep{}4\sep{}5\sep{}6\sep{}4\sep{}8\sep{}5\sep{}6\sep{}6\sep{}9\sep{}2\sep{}3\sep{}4\sep{}6\sep{}0\sep{}3\sep{}4\sep{}8\sep{}6\sep{}1\sep{}0\sep{}4\sep{}5\sep{}4\sep{}3\sep{}2\sep{}6\sep{}6\sep{}4\sep{}8\sep{}2\sep{}1\sep{}3\sep{}3\sep{}9\sep{}3\sep{}6\sep{}0\sep{}7\sep{}2\sep{}6\sep{}0\sep{}2\sep{}4\sep{}9\sep{}1\sep{}4\sep{}1\sep{}2\sep{}7\sep{}3\sep{}7\sep{}2\sep{}4\sep{}5\sep{}8\sep{}7\sep{}0\sep{}0\sep{}6\sep{}6\sep{}0\sep{}6\sep{}3\sep{}1\sep{}5\sep{}5\sep{}8\sep{}8\sep{}1\sep{}7\sep{}4\sep{}8\sep{}8\sep{}1\sep{}5\sep{}2\sep{}0\sep{}9\sep{}2\sep{}0\sep{}9\sep{}6\sep{}2\sep{}8\sep{}2\sep{}9\sep{}2\sep{}5\sep{}4\sep{}0\sep{}9\sep{}1\sep{}7\sep{}1\sep{}5\sep{}3\sep{}6\sep{}4\sep{}3\sep{}6\sep{}7\sep{}8\sep{}9\sep{}2\sep{}5\sep{}9\sep{}0\sep{}3\sep{}6\sep{}0\sep{}0\sep{}1\sep{}1\sep{}3\sep{}3\sep{}0\sep{}5\sep{}3\sep{}0\sep{}5\sep{}4\sep{}8\sep{}8\sep{}2\sep{}0\sep{}4\sep{}6\sep{}6\sep{}5\sep{}2\sep{}1\sep{}3\sep{}8\sep{}4\sep{}1\sep{}4\sep{}6\sep{}9\sep{}5\sep{}1\sep{}9\sep{}4\sep{}1\sep{}5\sep{}1\sep{}1\sep{}6\sep{}0\sep{}9\sep{}4\sep{}3\sep{}3\sep{}0\sep{}5\sep{}7\sep{}2\sep{}7\sep{}0\sep{}3\sep{}6\sep{}5\sep{}7\sep{}5\sep{}9\sep{}5\sep{}9\sep{}1\sep{}9\sep{}5\sep{}3\sep{}0\sep{}9\sep{}2\sep{}1\sep{}8\sep{}6\sep{}1\sep{}1\sep{}7\sep{}3\sep{}8\sep{}1\sep{}9\sep{}3\sep{}2\sep{}6\sep{}1\sep{}1\sep{}7\sep{}9\sep{}3\sep{}1\sep{}0\sep{}5\sep{}1\sep{}1\sep{}8\sep{}5\sep{}4\sep{}8\sep{}0\sep{}7\sep{}4\sep{}4\sep{}6\sep{}2\sep{}3\sep{}7\sep{}9\sep{}9\sep{}6\sep{}2\sep{}7\sep{}4\sep{}9\sep{}5\sep{}6\sep{}7\sep{}3\sep{}5\sep{}1\sep{}8\sep{}8\sep{}5\sep{}7\sep{}5\sep{}2\sep{}7\sep{}2\sep{}4\sep{}8\sep{}9\sep{}1\sep{}2\sep{}2\sep{}7\sep{}9\sep{}3\sep{}8\sep{}1\sep{}8\sep{}3\sep{}0\sep{}1\sep{}1\sep{}9\sep{}4\sep{}9\sep{}1\sep{}2\sep{}9\sep{}8\sep{}3\sep{}3\sep{}6\sep{}7\sep{}3\sep{}3\sep{}6\sep{}2\sep{}4\sep{}4\sep{}0\sep{}6\sep{}5\sep{}6\sep{}6\sep{}4\sep{}3\sep{}0\sep{}8\sep{}6\sep{}0\sep{}2\sep{}1\sep{}3\sep{}9\sep{}4\sep{}9\sep{}4\sep{}6\sep{}3\sep{}9\sep{}5\sep{}2\sep{}2\sep{}4\sep{}7\sep{}3\sep{}7\sep{}1\sep{}9\sep{}0\sep{}7\sep{}0\sep{}2\sep{}1\sep{}7\sep{}9\sep{}8\sep{}6\sep{}0\sep{}9\sep{}4\sep{}3\sep{}7\sep{}0\sep{}2\sep{}7\sep{}7\sep{}0\sep{}5\sep{}3\sep{}9\sep{}2\sep{}1\sep{}7\sep{}1\sep{}7\sep{}6\sep{}2\sep{}9\sep{}3\sep{}1\sep{}7\sep{}6\sep{}7\sep{}5\sep{}2\sep{}3\sep{}8\sep{}4\sep{}6\sep{}7\sep{}4\sep{}8\sep{}1\sep{}8\sep{}4\sep{}6\sep{}7\sep{}6\sep{}6\sep{}9\sep{}4\sep{}0\sep{}5\sep{}1\sep{}3\sep{}2\sep{}0\sep{}0\sep{}0\sep{}5\sep{}6\sep{}8\sep{}1\sep{}2\sep{}7\sep{}1\sep{}4\sep{}5\sep{}2\sep{}6\sep{}3\sep{}5\sep{}6\sep{}0\sep{}8\sep{}2\sep{}7\sep{}7\par
\end{document}

答案2

一些棋盤格...

在此輸入影像描述

這是簡單地完成的梅塔普斯特,所以用 進行編譯mpost

prologues := 3;
outputtemplate := "%j%c.eps";
input colorbrewer-rgb;
beginfig(1);
    path pi; numeric t; t = 13;
    pi = (origin -- (5,0) -- (5,1) -- (4,1) -- (4,4) -- (3,4) -- (3,1) -- (2,1) -- (2,4) -- (1,4) -- (1,1) -- up -- cycle) scaled t;

    for i=1 upto 48:
        for j=1 upto 48:
            fill pi                              shifted (4t*i-2t*j, t*i+5t*j) withcolor Spectral[7][i mod 7 + 1];
            fill pi rotated 180 shifted (4t, 5t) shifted (4t*i-2t*j, t*i+5t*j) withcolor Spectral[7][(3+i) mod 7 + 1];
       endfor
    endfor
    clip currentpicture to unitsquare scaled 100t shifted (0, 32t);
endfig;
end.

您將需要加載Metapost Colorbrewer對於顏色...

答案3

用 π 的數字寫 π - 使用verbatim環境。

在此輸入影像描述

\documentclass{article}
\linespread{0.7}
\begin{document}
\begin{verbatim}
     3.141592653589793238462643383279
   5028841971693993751058209749445923
  07816406286208998628034825342117067
  9821    48086         5132     
 823      06647        09384
46        09550        58223
17        25359        4081
          2848         1117
          4502         8410
          2701         9385
         21105        55964
         46229        48954
         9303         81964
         4288         10975
        66593         34461
       284756         48233
       78678          31652        71
      2019091         456485       66
     9234603           48610454326648
    2133936            0726024914127
    3724587             00660631558
    817488               152092096
\end{verbatim}
\end{document}

基於 Jorel 的 ascii 藝術繪畫 -https://www.flickr.com/photos/jorel314/3352784321/

答案4

我們可以從字體中提取字形的 MetaPost 路徑\pi,並使用 LuaTeX 繪製它。

\documentclass{article}

\usepackage{fontspec}
\setmainfont{latinmodern-math.otf}

\usepackage{luacode}
\begin{luacode*}
-- We need some utilities from ConTeXt
callbacks = callbacks or {}
callbacks.supported = callbacks.supported or {}
CONTEXTLMTXMODE = CONTEXTLMTXMODE or (status.obj_ptr == nil and 2 or 1)
dofile(kpse.find_file("util-fmt.lua"))
dofile(kpse.find_file("node-ini.lua"))
dofile(kpse.find_file("font-mps.lua"))
dofile(kpse.find_file("font-shp.lua"))

-- That's a simple reimplemetation of ConTeXt's \showshape macro
function outlinepaths(character)
    local fontid      = font.current()
    local shapedata   = fonts.hashes.shapes[fontid] -- by index
    local chardata    = fonts.hashes.characters[fontid] -- by unicode
    local shapeglyphs = shapedata.glyphs or { }

    character = utf.byte(character)
    local c = chardata[character]
    if c then
        if not c.index then
            return {}
        end
        local glyph = shapeglyphs[c.index]
        if glyph and (glyph.segments or glyph.sequence) then
            local units  = shapedata.units or 1000
            local factor = 100/units
            local paths  = fonts.metapost.paths(glyph,factor)
            return paths
        end
    end
end
\end{luacode*}

\usepackage{luamplib}
\everymplib{beginfig(0);}
\everyendmplib{endfig;}

\def\mpdefineoutlines#1{\directlua{
    local char = "\luaescapestring{#1}"
    local outlines = outlinepaths("#1")
    for i, path in ipairs(outlines) do
        tex.print("fill " .. path .. ";")
    end
  }}

\begin{document} 

\begin{mplibcode}

  \mpdefineoutlines{

相關內容