6

How to rotate the box?

enter image description here

How to change the above grid to the below shown grid

enter image description here

I used this code to rotate

\draw[step=1, red,thin,rotate=30] (-1cm,-1cm) grid (1cm,1cm); 

but i don't wan't to rotate the grid, i only need to rotate the rectangular box.

1 Answer 1

6

Draw the grid but clipped with a convenient path.

\documentclass[tikz,border=2mm]{standalone} 

\begin{document}
\begin{tikzpicture}

\clip[draw] (0,-3cm) -- (3,0) -- (0,3)--(-3,0)--cycle;
\draw[step=.5, red, thin] (-3cm,-3cm) grid (3cm,3cm);

\end{tikzpicture}
\end{document}

enter image description here

**Update: **

From Kevin comments I understand that he wants to draw a non rotated grid over a rotated image. And the grid should also be clipped to rotated image size. Something like:

enter image description here

which has been done with following code:

\documentclass[tikz,border=2mm]{standalone} 

\begin{document}
\begin{tikzpicture}

\node[anchor=south west, inner sep=0, rotate=23] (image) at (0,0) {\includegraphics{lion}};

\clip[draw] (image.south west) --(image.south east)--(image.north east)--(image.north west)--cycle;

\draw[white] (image.north west|-image.south west) grid (image.north east-|image.south east);

\end{tikzpicture}
\end{document}

First the external image is include as a rotated node. These node corners define the clipping path for the grid which is drawn later on.

By the way, the lion comes from Keep the frame background in minislides

4
  • \draw[step=1, red,thin,rotate=-30] (0,0) grid (\scaledwidth,\scaledheight); I m using this code now. Could you tell me, how your clip code should be?.
    – Kevin
    Jun 6, 2016 at 11:30
  • @Kevin My code shows the result you posted. So could you better explain what you want? First, could you show me a complete example using your command? I don't know what are \scaledwidth and \scaledheight. Even more, to my understanding rotate=-30 rotates the grid which is drawn with this command. Do you want a rotated grid inside a differently rotated rectangle?
    – Ignasi
    Jun 6, 2016 at 13:35
  • I had an external image with in a box, the \scaledwidth and \scaledheight are the width and height of my external image, and i need to place grid inside the box of the external image. if say the scaledwidht and scaledheight of external images are 3.3 and 3.7 with rotate 23, then how the clip code should be.
    – Kevin
    Jun 7, 2016 at 4:27
  • @Kevin I've updated the answer, I hope it's better now. In any case I'd suggest to rephrase your question to better explain it.
    – Ignasi
    Jun 7, 2016 at 7:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .