Latex 绘图小清新

来源:互联网 发布:网络维护管理 编辑:程序博客网 时间:2024/04/29 09:54

发一颗圣诞树供大家学习哟。


code:

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. \documentclass[11pt]{scrartcl}   
  2. \usepackage[dvipsnames,svgnames]{xcolor}    
  3. \usepackage{tikz}  
  4. \usetikzlibrary{shapes,decorations.shapes}  
  5. \newsavebox{\mycandle}  
  6. \savebox{\mycandle}{   
  7. \begin{tikzpicture}[scale=.1]  
  8. \shade[top color=yellow,bottom color=red] (0,0) .. controls (1,.2) and (1,.5) .. (0,2) .. controls (-1,.5)  and  (-1,.2) .. (0,0);  
  9. \fill[yellow!90!black] (.8,0) rectangle (-.8,-5);   
  10. \end{tikzpicture} }   
  11.   
  12. \tikzset{  
  13.   paint/.style={draw=#1!50!black, fill=#1!50},  
  14.   my star/.style={decorate,decoration={shape backgrounds,shape=star},  
  15.                   star points=#1}  
  16. }    
  17.   
  18. \begin{document}  
  19. \begin{tikzpicture}   
  20.    \draw[fill=Maroon,ultra thick]   
  21.    (.75,-1)  ..  controls (.5,.5)  and   (.5,3)    .. (0.5,4)   
  22. -- (-0.5,4)  ..  controls (-.5,3) and (-.5,.5)     .. (-.75,-1) ;  
  23. \draw[ultra thick,fill=green!50!black]   
  24.       (0,10) .. controls  (0,8)     and   (1,7)    .. (1.5,7)   
  25.              ..  controls (1,7)     and   (1,7)    .. (0.5,7.25)   
  26.              ..  controls (1.5,5)   and   (2.5,4)  .. (3,4)  
  27.              ..  controls (2,4)     and   (1.25,4) .. (1,4.5)  
  28.              ..  controls (2,2)     and   (3.5,2)  .. (4,2)  
  29.              ..  controls (1,1)     and   (-1,1)   .. (-4,2)   
  30.              ..  controls (-3.5,2)  and   (-2,2)   .. (-1,4.5)  
  31.              ..  controls (-1.25,4) and   (-2,4)   .. (-3,4)   
  32.              ..  controls (-2.5,4)  and   (-1.5,5) .. (-0.5,7.25)   
  33.              ..  controls  (-1,7)   and   (-1,7)   .. (-1.5,7)  
  34.              ..  controls  (-1,7)   and   (0,8)    .. (0,10)  
  35.               ;  
  36. \foreach \candle in {(2,5),(-2,5),(0.5,7.5),(-0.5,7.5),(-3,2.5), (3,2.5),  
  37.                     (1.5,1.75),(-1.5,1.75)}  
  38. \node at \candle {\usebox{\mycandle}} ;   
  39.  \node [star, star point height=.5cm, minimum size=.5cm, draw,fill=yellow,thick]  
  40.        at (0,10) {};  
  41.        \begin{scope}[decoration={shape sep=.2cm, shape size=.25cm}]   
  42.     \draw [my star=6, paint=red]  (-4,2)  
  43.              ..  controls (0,2)     and   (1,3.5)   .. (1,4.5)  
  44.              ..  controls (1,6)     and   (0.5,6)      .. (0.5,7.25);   
  45.     \draw [my star=6, paint=blue]  (4,2)  
  46.              ..  controls  (0,2) and (-1,3.5)      .. (-1,4.5)               
  47.              ..  controls (-1,6)     and   (-0.5,6)      .. (-0.5,7.25);      
  48.        \end{scope}    
  49. \end{tikzpicture}  
  50.   
  51. \end{document}   

效果:



code2:

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. \documentclass{article}  
  2. \usepackage{tikz}  
  3. \usetikzlibrary{lindenmayersystems}  
  4. \begin{document}  
  5. \begin{tikzpicture}  
  6. \draw [color=green!50!black, l-system={rule set={S -> [+++G][---G]TS,  
  7.   G -> +H[-G]L, H -> -G[+H]L, T -> TL, L -> [-FFF][+FFF]F}, step=4pt, angle=18,  
  8.  axiom=+++++SLFFF, order=11}] lindenmayer system -- cycle;  
  9. \end{tikzpicture}  
  10. \end{document}  

效果:


code3:

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. \documentclass[11pt]{scrartcl}   
  2. \usepackage[dvipsnames,svgnames]{xcolor}    
  3. \usepackage{tikz}  
  4. \usetikzlibrary{%  
  5.   shapes,  
  6.   decorations.shapes,  
  7.   decorations.fractals,  
  8.   decorations.markings,  
  9.   shadows  
  10. }  
  11.   
  12. \newsavebox{\mycandle}  
  13. \savebox{\mycandle}{   
  14. \begin{tikzpicture}[scale=.1]  
  15. \shade[top color=yellow,bottom color=red] (0,0) .. controls (1,.2) and (1,.5) .. (0,2) .. controls (-1,.5)  and  (-1,.2) .. (0,0);  
  16. \fill[yellow!90!black] (.8,0) rectangle (-.8,-5);   
  17. \end{tikzpicture} }   
  18.   
  19. \tikzset{  
  20.   paint/.style={draw=#1!50!black, fill=#1!50},  
  21.   my star/.style={decorate,decoration={shape backgrounds,shape=star},  
  22.                   star points=#1}  
  23. }    
  24.   
  25. \begin{document}  
  26.   \begin{tikzpicture}[  ball red/.style={  
  27.     decorate,  
  28.     decoration={  
  29.       markings,  
  30.       mark=between positions .2 and 1 step 3cm  
  31.       with  
  32.       {  
  33.         \pgfmathsetmacro{\sz}{2 + .5 * rand}  
  34.         \path[shading=ball,ball color=red] (0,0) circle[radius=\sz mm];  
  35.       }  
  36.     }  
  37.   } ,ball blue/.style={  
  38.     decorate,  
  39.     decoration={  
  40.       markings,  
  41.       mark=between positions 0.1 and .9 step 3cm  
  42.       with  
  43.       {  
  44.         \pgfmathsetmacro{\sz}{2 + .5 * rand}  
  45.         \path[shading=ball,ball color=blue] (0,0) circle[radius=\sz mm];  
  46.       }  
  47.     }  
  48.   }     
  49. ]  
  50.   
  51. \draw[fill=Maroon,ultra thick]   
  52.       (.75,-1)  ..  controls (.5,.5)  and   (.5,3)    .. (0.5,4)   
  53.    -- (-0.5,4)  ..  controls (-.5,3) and (-.5,.5)     .. (-.75,-1) ;  
  54. \shade[ultra thick, top color=green!90!black,bottom color=green!10!black]   
  55.       (0,10) .. controls  (0,8)     and   (1,7)    .. (1.5,7)   
  56.              ..  controls (1,7)     and   (1,7)    .. (0.5,7.25)   
  57.              ..  controls (1.5,5)   and   (2.5,4)  .. (3,4)  
  58.              ..  controls (2,4)     and   (1.25,4) .. (1,4.5)  
  59.              ..  controls (2,2)     and   (3.5,2)  .. (4,2)  
  60.              ..  controls (1,1)     and   (-1,1)   .. (-4,2)   
  61.              ..  controls (-3.5,2)  and   (-2,2)   .. (-1,4.5)  
  62.              ..  controls (-1.25,4) and   (-2,4)   .. (-3,4)   
  63.              ..  controls (-2.5,4)  and   (-1.5,5) .. (-0.5,7.25)   
  64.              ..  controls  (-1,7)   and   (-1,7)   .. (-1.5,7)  
  65.              ..  controls  (-1,7)   and   (0,8)    .. (0,10)  
  66.               ;  
  67.   
  68. \foreach \candle in {(2,5),(-2,5),(0.5,7.5),(-0.5,7.5),(-3,2.5), (3,2.5),  
  69.                     (1.5,1.75),(-1.5,1.75)}  
  70. \node at \candle {\usebox{\mycandle}} ;   
  71. \node [star, star point height=.5cm, minimum size=.5cm,draw,fill=yellow,thick]  
  72.       at (0,10) {};  
  73. \begin{scope}[decoration={shape sep=.2cm, shape size=.25cm}]   
  74.     \draw [my star=6, paint=red]  (-4,2)  
  75.              ..  controls (0,2)     and   (1,3.5)   .. (1,4.40);   
  76.     \draw [my star=6, paint=red]  (-1.5,5.40)  
  77.              ..  controls (0,5.40)     and   (0.5,6.5)      .. (0.5,7);    
  78.     \draw [my star=6, paint=blue]  (4,2)  
  79.              ..  controls  (0,2) and (-1,3.5)      .. (-1,4.40);               
  80.     \draw [my star=6, paint=blue]  (1.5,5.40)  
  81.              ..  controls (0,5.40)     and   (-0.5,6.5)      .. (-0.5,7);       
  82. \end{scope}   
  83. % the balls  
  84. \path[ball red]   
  85.       (0,10) .. controls  (0,8)     and   (1,7)    .. (1.5,7)   
  86.              ..  controls (1,7)     and   (1,7)    .. (0.5,7.25)   
  87.              ..  controls (1.5,5)   and   (2.5,4)  .. (3,4)  
  88.              ..  controls (2,4)     and   (1.25,4) .. (1,4.5)  
  89.              ..  controls (2,2)     and   (3.5,2)  .. (4,2)  
  90.              ..  controls (1,1)     and   (-1,1)   .. (-4,2)   
  91.              ..  controls (-3.5,2)  and   (-2,2)   .. (-1,4.5)  
  92.              ..  controls (-1.25,4) and   (-2,4)   .. (-3,4)   
  93.              ..  controls (-2.5,4)  and   (-1.5,5) .. (-0.5,7.25)   
  94.              ..  controls  (-1,7)   and   (-1,7)   .. (-1.5,7)  
  95.              ..  controls  (-1,7)   and   (0,8)    .. (0,10)  
  96.               ;   
  97. \path[ball blue]   
  98.       (0,10) .. controls  (0,8)     and   (1,7)    .. (1.5,7)   
  99.              ..  controls (1,7)     and   (1,7)    .. (0.5,7.25)   
  100.              ..  controls (1.5,5)   and   (2.5,4)  .. (3,4)  
  101.              ..  controls (2,4)     and   (1.25,4) .. (1,4.5)  
  102.              ..  controls (2,2)     and   (3.5,2)  .. (4,2)  
  103.              ..  controls (1,1)     and   (-1,1)   .. (-4,2)   
  104.              ..  controls (-3.5,2)  and   (-2,2)   .. (-1,4.5)  
  105.              ..  controls (-1.25,4) and   (-2,4)   .. (-3,4)   
  106.              ..  controls (-2.5,4)  and   (-1.5,5) .. (-0.5,7.25)   
  107.              ..  controls  (-1,7)   and   (-1,7)   .. (-1.5,7)  
  108.              ..  controls  (-1,7)   and   (0,8)    .. (0,10)  
  109.               ;   
  110.  % the snow  
  111. \foreach \i in {0.5,0.6,...,1.6}  
  112.      \fill [white!80!blue,decoration=Koch snowflake,opacity=.9]  
  113.            [shift={(rand*5,rnd*8)},scale=\i]  
  114.            [double copy shadow={opacity=0.2,shadow xshift=0pt,  
  115.            shadow yshift=3*\i pt,fill=white,draw=none}]  
  116.         decorate {  
  117.           decorate {  
  118.             decorate {  
  119.               (0,0) -- ++(60:1) -- ++(-60:1) -- cycle  
  120.             }  
  121.           }  
  122.         };                    
  123. \end{tikzpicture}  
  124.   
  125. \end{document}   


效果:


code 4:

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. \documentclass{article}  
  2. \usepackage{listings}  
  3. \usepackage{tikz}  
  4. \usetikzlibrary{%  
  5.   lindenmayersystems,  
  6.   decorations.pathmorphing,  
  7.   decorations.markings,  
  8.   shapes.geometric,  
  9.   calc%  
  10. }  
  11. \tikzset{  
  12.   tinsel/.style={  
  13.     #1,   
  14.     rounded corners=10mm,  
  15.     ultra thin,  
  16.     decorate,  
  17.     decoration={  
  18.       snake,  
  19.       amplitude=.1mm,  
  20.       segment length=10,  
  21.     }  
  22.   },  
  23.   baubles/.style={  
  24.     decorate,  
  25.     decoration={  
  26.       markings,  
  27.       mark=between positions .3 and 1 step 2cm  
  28.       with  
  29.       {  
  30.         \pgfmathsetmacro{\brad}{2 + .5 * rand}  
  31.         \path[shading=ball,ball color=#1] (0,0) circle[radius=\brad mm];  
  32.       }  
  33.     }  
  34.   },  
  35.   lights/.style={  
  36.     decorate,  
  37.     decoration={  
  38.       markings,  
  39.       mark=between positions 0 and 1 step 1cm  
  40.       with  
  41.       {  
  42.         \pgfmathparse{rand > 0 ? "dart" : "kite"}  
  43.         \let\lshape\pgfmathresult  
  44.          \pgfmathsetmacro{\tint}{100*rnd}  
  45.         \node[rotate=90,\lshape,shading=ball,inner sep=1pt,ball color=red!\tint!yellow] {};  
  46.       }  
  47.     }  
  48.   }  
  49. }  
  50.   
  51. \begin{document}  
  52. \begin{center}  
  53. \tikz[remember picture,overlay] \coordinate (star) at (0,-1);  
  54. \end{center}  
  55.   
  56. \lstinputlisting[  
  57.   breaklines=true,  
  58.   language=TeX,  
  59.   basicstyle=\tiny,  
  60.   firstline=63,  
  61.   lastline=103]{\jobname.tex}  
  62.   
  63. \begin{tikzpicture}[overlay,remember picture]  
  64. \path (star) +(-50:7) coordinate (rhs) +(-130:7) coordinate (lhs);  
  65. \draw[brown!50!black,line width=5mm,line cap=round] (star) ++(-90:6.8) -- ++(0,-1) coordinate (base);  
  66. \node[scale=-1,trapezium,fill=black,minimum size=1cm] at (base) {};  
  67. \foreach \height/\colour in {%  
  68.   .2/blue,  
  69.   .4/yellow,  
  70.   .6/red,  
  71.   .8/orange,  
  72.   1/pink%  
  73. } {  
  74.   \draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);  
  75. }  
  76. \path (star);  
  77. \pgfgetlastxy{\starx}{\stary}  
  78. \begin{scope}[xshift=\starx,yshift=\stary,yshift=-7cm]  
  79. \draw[color=green!50!black, l-system={rule set={S -> [+++G][---G]TS,  G -> +H[-G]L, H -> -G[+H]L, T -> TL, L -> [-FFF][+FFF]F}, step=4pt, angle=18, axiom=+++++SLFFF, order=11}] lindenmayer system -- cycle;  
  80. \end{scope}  
  81. \foreach \height/\colour in {%  
  82.   .1/pink,  
  83.   .3/red,  
  84.   .5/yellow,  
  85.   .7/blue,  
  86.   .9/orange%  
  87. } {  
  88.   \draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);  
  89. }  
  90. \foreach \height in {.15,.35,...,1} {  
  91.   \draw[lights]  ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);  
  92. }  
  93. \foreach \angle/\colour in {  
  94.   -50/red,  
  95.   -70/yellow,  
  96.   -90/blue,  
  97.   -110/pink,  
  98.   -130/purple%  
  99. } {  
  100.   \draw[baubles=\colour] (star) -- ++(\angle:7);  
  101. }  
  102. \node[star,star point ratio=2.5,fill=yellow,minimum size=1cm] at (star) {};  
  103. \end{tikzpicture}  
  104. \end{document}  


效果:



code 5:

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. \documentclass[border=5mm]{standalone}  
  2. \usepackage{pgfplots}  
  3.   
  4. \begin{document}  
  5. %  
  6. \begin{tikzpicture}  
  7. \begin{axis}[  
  8.     hide axis, clip=false,  
  9.     y domain=0:2*pi,  
  10.     samples=30,axis equal, view={45}{20}]  
  11.   
  12. \addplot3 [domain=0:4,surf,shader=flat,z buffer=sort,fill=green!50!brown, draw=green!50!black, line join=bevel]   
  13.     ({(1.3*x-floor(x))*x^0.5*cos(deg(y))},  
  14.      {(1.3*x-floor(x))*x^0.5*sin(deg(y))},  
  15.      {-5*x});  
  16.   
  17. \addplot3 [domain=0:4.5, samples=10, samples y=0, fill=yellow!85!red, draw=yellow!55!red] ({0},{sin(x/5*360) * (1 - x + floor(x)) },{cos(x/5*360) * (1 - x + floor(x) )  + 0.5}) -- cycle;  
  18. \end{axis}  
  19. \end{tikzpicture}%  
  20. %  
  21. \end{document}  


效果:



code 6:

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. \documentclass{article}  
  2. \usepackage{tikz}  
  3. \usetikzlibrary{scopes,svg.path,shapes.geometric,shadows}  
  4. \begin{document}  
  5. \begin{tikzpicture}[  
  6.   mystar/.style={star, minimum size=2cm, star point ratio=2.5, shade, thick,  
  7.     line join=round, color=yellow!80!black, draw=red!20!black,  
  8.     top color=yellow!80!white, bottom color=yellow!60!black},  
  9.   mytree/.style={scale=0.5, rotate=180, draw=green!60!black, thick,  
  10.     line join=round, inner color=green!60!yellow, outer color=green!50!black},  
  11.   myball/.style={shade, ball color=#1, circular drop shadow={  
  12.     shadow xshift=0pt, shadow yshift=-.5ex, fill=green!40!black}}  
  13.   ]  
  14.   {[mytree]  
  15.   \shadedraw svg "M355,430  
  16.     q90,10 105,-85 30,0 50,-30 20,30 50,30 50,-20 100,0 10,88 105,85  
  17.     -45,90 -205,25 Q400,520 355,430";  
  18.   \shadedraw svg "M380,325  
  19.     q83,10 105,-80 25,0 35,-30 20,25 40,30 20,-10 35,-25 20,20 40,25  
  20.     25,90 105,82 -15,50 -120,15 -30,-2 -60,12 -30,0 -52,-28  
  21.     C490,370 380,360 380,325";  
  22.   \shadedraw svg "M435,225  
  23.     q65,-8 90,-70 35,40 70,0 25,60 90,70 -30,52 -90,5 -36,48 -73,-3  
  24.     C520,254 445,265 435,225";  
  25.   \shadedraw svg "M470,139  
  26.     q50,5 90,-80 50,90 90,80 -30,30 -50,20 -40,45 -78,0  
  27.     Q500,170 470,139";  
  28.   }  
  29.   %\shadedraw svg[scale=0.5,rotate=180]  
  30.   %"M460,532 q50,-8 q77,-45 v-20 a20,13 0 1 1 48,0 v20 q30,40 77,45";  
  31.   %pgf/tikz doesn't like the arc operation, as stated in manual  
  32.   
  33.   \node[mystar] at (-9.85,-1) {$\lambda$};  
  34.   
  35.   \shade[myball=blue]   (-9.7,-2.2)   circle (.2cm);  
  36.   \shade[myball=red]    (-9.2,-3.8)   circle (.2cm);  
  37.   \shade[myball=green]  (-10.3,-4)    circle (.4cm);  
  38.   \shade[myball=yellow] (-8.95,-5.4)  circle (.4cm);  
  39.   \shade[myball=red]    (-10.7,-6.1)  circle (.4cm);  
  40.   \shade[myball=blue]   (-10.8,-5)    circle (.2cm);  
  41.   \shade[myball=yellow] (-9.5,-6.7)   circle (.2cm);  
  42.   \shade[myball=green]  (-8.3,-7.6)   circle (.4cm);  
  43.   \shade[myball=yellow] (-11.7,-7.6)  circle (.4cm);  
  44.   \shade[myball=blue]   (-10.5,-7.8)  circle (.2cm);  
  45. \end{tikzpicture}  
  46. \end{document}  

效果:


0 0
原创粉丝点击