# Random scale of square makes a rectangle

Why does this code generates a rectangle, not a square?

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[scale=rnd] (0,0) rectangle (1,1);
\end{tikzpicture}
\end{document}

-

Every coordinate of (1,1) is multiplied with the value of scale. So you have two values x and y which will be multiplied with rnd. And of course rnd isn't equal for x and y.

To use rnd as an option of scale you can do the following:

\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\pgfmathparse{rnd}
\draw[scale=\pgfmathresult] (0,0) rectangle (1,1);
\end{tikzpicture}
\begin{tikzpicture}
\draw[scale=1] (0,0) rectangle (1,1);
\end{tikzpicture}
\end{document}

-
Thanks! Is there a way to scale the square properly without using a variable? – Jill-Jênn Vie Aug 5 '12 at 11:39
@Jill-JênnVie: You can use scale=2. Or what do you mean? – Marco Daniel Aug 5 '12 at 11:56
I mean, the same random scale affecting both x and y. – Jill-Jênn Vie Aug 5 '12 at 12:09
@Jill-JênnVie: You can use the option cm – Marco Daniel Aug 5 '12 at 12:11
And how to factor the random number in \draw[cm={rnd,0,0,rnd,(0,0)}] (0,0) rectangle (1,1);? – Jill-Jênn Vie Aug 5 '12 at 12:28