请教各位大佬,如何用tikz实现图中的迭代?

2021-02-19 23:21发布

请教各位大佬,如何用tikz实现图中的迭代? ![](https://wenda.latexstudio.net/data/attach/210219/QvJJtc8o.png)

请教各位大佬,如何用tikz实现图中的迭代? ![](https://wenda.latexstudio.net/data/attach/210219/QvJJtc8o.png)
3条回答
U9430
2021-02-21 21:50
```c %\usepackage{tikz} %\usetikzlibrary[calc] \begin{tikzpicture} \def\myiterationtimes{10}%迭代次数 \def\myrationum{0.3}%一个比例值 \path coordinate (p01) at (1,1) coordinate (p02) at (-1,1) coordinate (p03) at (-1,-1) coordinate (p04) at (1,-1) \foreach \i [count=\j from 0] in {1,...,\myiterationtimes} { coordinate (p\i 1) at ($(p\j 1)!\myrationum!(p\j 2)$) coordinate (p\i 2) at ($(p\j 2)!\myrationum!(p\j 3)$) coordinate (p\i 3) at ($(p\j 3)!\myrationum!(p\j 4)$) coordinate (p\i 4) at ($(p\j 4)!\myrationum!(p\j 1)$) } ; \foreach \i[evaluate={\k=1.2-\i/(\myiterationtimes+1);\h=1-\i/\myiterationtimes;}] in {0,...,\myiterationtimes} { \draw [line width=\h pt](p\i 1)--(p\i 2)--(p\i 3)--(p\i 4)--cycle; \foreach \j in {1,...,4} \fill[fill=red] (p\i \j)circle[radius=\k pt]; } \end{tikzpicture} ``` 效果是 ![](https://wenda.latexstudio.net/data/attach/210221/ea4ZIA5z.PNG)

一周热门 更多>