3

I want to draw two figures using tikz. One is bigotimes and the other one is diamond, as you can seen in the picture below. But I don't know how to draw them. Could someone help me?

enter image description here

  • \documentclass{minimal} \usepackage{tikz} \usetikzlibrary{calc,intersections} \begin{document} \begin{tikzpicture} \draw[name path=c] (0,0) circle (1); \path[name path=fst] (-1,-1) -- (1,1); \path[name path=snd] (-1,1) -- (1,-1); \draw[name intersections={of=c and fst,by={a,b}}] (a) -- (b); \draw[name intersections={of=c and snd,by={a,b}}] (a) -- (b); \draw (3,0) +(1,0) -- +(0,2) -- +(-1,0) -- +(0,-2) -- cycle; \end{tikzpicture} \end{document} – user10274 Jul 30 '12 at 3:06
  • 1
    FWIW: I just realised the first shape could have been drawed easier in the polar coordinate system. – user10274 Jul 30 '12 at 9:17
  • 2
    There are lots of ways to draw these with TikZ/PGF so it would help if you said what you wanted to do with them. Although you say you don't know how to draw them, have you managed to draw anything close? – Loop Space Jul 30 '12 at 12:14
7

enter image description here

  \documentclass[11pt]{scrartcl}
  \usepackage{tikz}
  \usetikzlibrary{shapes.geometric}
  \begin{document}
  \begin{tikzpicture} 
     \tikzset{oplus/.style={path picture={% 
        \draw[black]
         (path picture bounding box.south west) -- (path picture bounding box.north east) 
         (path picture bounding box.north west) -- (path picture bounding box.south east);
        }}} 
      \node[oplus,fill=blue!10,draw=blue,thick,circle, scale=10] {};
      \end{tikzpicture}  
   \begin{tikzpicture}
     \node [draw,scale=8,diamond,fill=orange!50]{}; 
   \end{tikzpicture}

  \end{document}    
4

here's my attempt (with limited Tikz knowledge) at the diamond in a tikzpicture environment where you set half of the largest and half of the smallest angle:

     \newcommand{\halffirstangle}{60}
      \newcommand{\halfsecondangle}{30} %half second angle = 0.5*(360-2*\halffirstangle)

        \path[draw, blue] (0,0) -- ++(\halffirstangle:1cm) -- ++(270+\halfsecondangle:1cm) -- ++(180+\halffirstangle:1cm) -- ++(90+\halfsecondangle:1cm)  ;

The shape starts from (0,0) and then relative coordinates are used. It's worth reading up on these. The subsequent pairs give the angle of the line segment first, then its length. Here the sides are 1cm in length, the angles are just worked out from basic geometry.

I can recommend the pgf-tut.pdf by Meik Hellmund if you're starting out.

4

Here is one way to draw the diamond:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz\node[rectangle,draw,yscale=1.2,rotate=45] {};
\end{document}

enter image description here

but you can't have text inside the node this way (or you can, but it gets rotated and the shape won't stay as a diamond).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.