Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass[preview]{standalone}
- \usepackage{tikz}
- \usetikzlibrary{calc} %for coordinate calculation
- \usetikzlibrary{math} %for \tikzmath (thanks to /u/tzjin for the LaTeX Challenge Part 2 where I learned about this!)
- \begin{document}
- \begin{tikzpicture}
- \tikzmath{
- \N = 30; %the number of lines to draw per side, more is prettier but 30 is a good number for the challenge (I suggest trying 50 or greater)
- \L = 10; %width of the side, only affects the output size
- \d = \L/\N; %distance between line connection points (on both horizontal and vertical axes)
- \lineW = 0.1; %width of the lines, should be small for the best output
- \lineopac = 1; %opacity of the lines
- }
- \coordinate (LL) at (0,0); %lower left corner
- \coordinate (LR) at (\L,0); %lower right corner
- \coordinate (UR) at (\L,\L); %upper right corner
- \coordinate (UL) at (0,\L); %upper left corner
- \coordinate (dx) at (\d,0); %for coordinate calculations
- \coordinate (dy) at (0,\d); %for coordinate calculations
- \foreach \i in {0,...,\N}{
- \draw[draw opacity = \lineopac, line width = \lineW] ($(UL) - \i*(dy)$) -- ($(LL) + \i*(dx)$);
- \draw[draw opacity = \lineopac, line width = \lineW] ($(LR) + \i*(dy)$) -- ($(UR) - \i*(dx)$);
- }
- \end{tikzpicture}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement