Skip to main content
added 438 characters in body
Source Link
Donna
  • 385
  • 2
  • 10

I'd like to draw a rectilinear path by starting at a particular location, and then prescribing increments in the horizontal and vertical directions.

I am currently doing something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw [ultra thick] (20,12) -- (18,12);
    \draw [ultra thick] (18,12) -- (18,10);
    \draw [ultra thick] (18,10) -- (16,10);
    \draw [ultra thick] (16,10) -- (16,8);
    \draw [ultra thick] (16,8) -- (12,8);
    \draw [ultra thick] (12,8) -- (12,10);
    \draw [ultra thick] (12,10) -- (8,10);
    \draw [ultra thick] (8,10) -- (8,12);
    \draw [ultra thick] (8,12) -- (6,12);
    \draw [ultra thick] (6,12) -- (6,14);
    \draw [ultra thick] (6,14) -- (4,14);
    % etc ...

\end{tikzpicture}
\end{document}

enter image description here

But this requires that I locate each point, when what is much easier (for my particular case) is to just indicate the horizontal or vertical distance from one point to the next.

I have tried something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
   \node (A) at (20,12) {};
   \node (B) at (18,12) {};
   \node (C) at (18,10) {};
   \node (D) at (16,10) {};

   \draw (A) |- ++ (-2,0)  -| (B);
   \draw (B) |- ++ (0, -2) -| (C);
   \draw (C) |- ++ (-2, 0) -| (D);
   % etc
\end{tikzpicture}
\end{document}

It looks like the ++ (-2,0) bit seems to be on the right track, but naming the nodes is tedious, and this doesn't produce what I have in mind.

Is there somewaysome way to do what I have in mind with simple notation? Something like

Start at (20,12)
Go left 2 units
Go down 2 units
Go left 2 units
% etc

Aka, Etch-a-Sketch style?

I'd like to draw a rectilinear path by starting at a particular location, and then prescribing increments in the horizontal and vertical directions.

I am currently doing something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw [ultra thick] (20,12) -- (18,12);
    \draw [ultra thick] (18,12) -- (18,10);
    \draw [ultra thick] (18,10) -- (16,10);
    \draw [ultra thick] (16,10) -- (16,8);
    \draw [ultra thick] (16,8) -- (12,8);
    \draw [ultra thick] (12,8) -- (12,10);
    \draw [ultra thick] (12,10) -- (8,10);
    \draw [ultra thick] (8,10) -- (8,12);
    \draw [ultra thick] (8,12) -- (6,12);
    \draw [ultra thick] (6,12) -- (6,14);
    \draw [ultra thick] (6,14) -- (4,14);
    % etc ...

\end{tikzpicture}
\end{document}

enter image description here

But this requires that I locate each point, when what is much easier (for my particular case) is to just indicate the horizontal or vertical distance from one point to the next.

I have tried something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
   \node (A) at (20,12) {};
   \node (B) at (18,12) {};
   \node (C) at (18,10) {};
   \node (D) at (16,10) {};

   \draw (A) |- ++ (-2,0)  -| (B);
   \draw (B) |- ++ (0, -2) -| (C);
   \draw (C) |- ++ (-2, 0) -| (D);
   % etc
\end{tikzpicture}
\end{document}

It looks like the ++ (-2,0) bit seems to be on the right track, but naming the nodes is tedious, and this doesn't produce what I have in mind.

Is there someway to do what I have in mind with simple notation? Something like

Start at (20,12)
Go left 2 units
Go down 2 units
Go left 2 units
% etc

Aka, Etch-a-Sketch style?

I'd like to draw a rectilinear path by starting at a particular location, and then prescribing increments in the horizontal and vertical directions.

I am currently doing something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw [ultra thick] (20,12) -- (18,12);
    \draw [ultra thick] (18,12) -- (18,10);
    \draw [ultra thick] (18,10) -- (16,10);
    \draw [ultra thick] (16,10) -- (16,8);
    \draw [ultra thick] (16,8) -- (12,8);
    \draw [ultra thick] (12,8) -- (12,10);
    \draw [ultra thick] (12,10) -- (8,10);
    \draw [ultra thick] (8,10) -- (8,12);
    \draw [ultra thick] (8,12) -- (6,12);
    \draw [ultra thick] (6,12) -- (6,14);
    \draw [ultra thick] (6,14) -- (4,14);
    % etc ...

\end{tikzpicture}
\end{document}

enter image description here

But this requires that I locate each point, when what is much easier (for my particular case) is to just indicate the horizontal or vertical distance from one point to the next.

I have tried something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
   \node (A) at (20,12) {};
   \node (B) at (18,12) {};
   \node (C) at (18,10) {};
   \node (D) at (16,10) {};

   \draw (A) |- ++ (-2,0)  -| (B);
   \draw (B) |- ++ (0, -2) -| (C);
   \draw (C) |- ++ (-2, 0) -| (D);
   % etc
\end{tikzpicture}
\end{document}

It looks like the ++ (-2,0) bit seems to be on the right track, but naming the nodes is tedious, and this doesn't produce what I have in mind.

Is there some way to do what I have in mind with simple notation? Something like

Start at (20,12)
Go left 2 units
Go down 2 units
Go left 2 units
% etc

Aka, Etch-a-Sketch style?

Source Link
Donna
  • 385
  • 2
  • 10

Drawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawing

I'd like to draw a rectilinear path by starting at a particular location, and then prescribing increments in the horizontal and vertical directions.

I am currently doing something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw [ultra thick] (20,12) -- (18,12);
    \draw [ultra thick] (18,12) -- (18,10);
    \draw [ultra thick] (18,10) -- (16,10);
    \draw [ultra thick] (16,10) -- (16,8);
    \draw [ultra thick] (16,8) -- (12,8);
    \draw [ultra thick] (12,8) -- (12,10);
    \draw [ultra thick] (12,10) -- (8,10);
    \draw [ultra thick] (8,10) -- (8,12);
    \draw [ultra thick] (8,12) -- (6,12);
    \draw [ultra thick] (6,12) -- (6,14);
    \draw [ultra thick] (6,14) -- (4,14);
    % etc ...

\end{tikzpicture}
\end{document}

enter image description here

But this requires that I locate each point, when what is much easier (for my particular case) is to just indicate the horizontal or vertical distance from one point to the next.

I have tried something like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
   \node (A) at (20,12) {};
   \node (B) at (18,12) {};
   \node (C) at (18,10) {};
   \node (D) at (16,10) {};

   \draw (A) |- ++ (-2,0)  -| (B);
   \draw (B) |- ++ (0, -2) -| (C);
   \draw (C) |- ++ (-2, 0) -| (D);
   % etc
\end{tikzpicture}
\end{document}

It looks like the ++ (-2,0) bit seems to be on the right track, but naming the nodes is tedious, and this doesn't produce what I have in mind.

Is there someway to do what I have in mind with simple notation? Something like

Start at (20,12)
Go left 2 units
Go down 2 units
Go left 2 units
% etc

Aka, Etch-a-Sketch style?