Stats

Popular Posts

Followers

Tikz: Drawing Random Circles with Randomly Assigned Centers and Radii

戴忠淵 於 2023年4月7日星期五 上午11:45 發表
\documentclass{article}
\usepackage{tikz}
\usepackage{adjustbox}
\begin{document}
\begin{center}
\begin{adjustbox}{width=0.6\textwidth}
  \begin{tikzpicture}
  \pgfmathsetseed{42}
    \foreach \i in {1,...,500}
    {
      \pgfmathsetmacro{\a}{int(random(0,255))}
      \pgfmathsetmacro{\b}{int(random(0,255))}
      \pgfmathsetmacro{\c}{int(random(0,255))}
      \pgfmathsetmacro{\r}{rand*2}
      \pgfmathsetmacro{\x}{random(-10,10)}
      \pgfmathsetmacro{\y}{random(-10,10)}
      \definecolor{mycolor}{RGB}{\a,\b,\c}
      \fill[mycolor] (\x,\y) circle (\r cm);
    }
  \end{tikzpicture}
  \end{adjustbox}
  \end{center}
\end{document}
Tags:

讀者回應 ( 0 意見 )

發佈留言

Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.

如果這篇文章對你有幫助,那請留個訊息給我~