I would like to take a polygon generated with shapes.geometric in TikZ and stretch it horizontally, but only a portion of the polyon. In particular, I would like to take the hexagon generated by

    \node[draw,minimum size=2cm,regular polygon,regular polygon sides=6] (H) {};

but modify it so that the top and bottom horizontal sides of the polygon are stretched out horizontally, while the other four sides maintain their original lengths, and in such way that things like (H.corner 2) still refer to the coordinates of the corners in this modified hexagon.

  • If you do so, then it would no longer be a regular polygon, would it ? The definition of new node shapes is documented in section 101.5 of the TikZ manual. The same manual also states in section 18.1 : defining new types of pics is much easier than defining new shapes for nodes, (and I humbly think this is right). pics can also carry marked points accessible from the outside. – marsupilam Jun 26 '17 at 19:39

This one comes with a free seagull (do you see it ?) !

The output

enter image description here

The code

      \draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0);
    pics/myHexagon/.style args={#1/#2}%
        \draw [cm={\r,0,.5*\r,\mySqrt*\r,(0,0)}] 
          (1+\a,0) coordinate (-corner 0) coordinate (-corner 6) 
          -- (\a,1) coordinate (-corner 1)
          -- (-1-\a,1) coordinate (-corner 2)
          -- (-1-\a,0) coordinate (-corner 3)
          -- (-\a,-1)  coordinate (-corner 4)
          -- (1+\a,-1) coordinate (-corner 5)
          -- cycle;
   \pic at (0,0) {seagull};
   \pic (monHexa) {myHexagon={2/.2}};
   \foreach \k in {0,...,6}
     \node at (monHexa-corner \k) {corner \k};

  • That's exactly what I was wanting to do. Thanks! – cjohnson Jun 26 '17 at 22:07
  • Really nice example of cm= use. Thanks! – Rmano Jun 27 '17 at 7:58
  • @Rmano I secretly hoped someone would notice ;) Thanks to you ! – marsupilam Jun 27 '17 at 8:28

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.