I wish to create a two by two Grid

  y = Graphics[{Red, Disk[Scaled[{.01, .01}]]}];
 GraphicsGrid[{{"", "first column"}, {"first raw", GraphicsGrid[{{y, y}, {y, y}}]}}, Frame -> All, 
  ImageSize -> 40*{3, 3}],

but instead of a Disk for Graphics, a new shape as the below one is desired. I don't know how can I generate that, and replace one of disks by this shape. Can anyone help me?

enter image description here

In addition, how can I apply the Alignment for just Disks and the new shape. For example the desired case is putting the new shape at the center of the cell as long as Disks be on the three corners.


Maybe this will work for you.

circledStar =
  Module[{blue, thick, circle, pentagonPts, innerPt, starPts, star},
    blue = RGBColor[{.3, .6, 1}];
    thick = Scaled[.03];
    circle = {Thickness[thick], Red, Circle[{0, 0}, 1.07]};
    pentagonPts = CirclePoints[5];
    innerPt =
       Line[{pentagonPts[[1]], pentagonPts[[3]]}], 
       Line[{pentagonPts[[2]], pentagonPts[[4]]}]];
    starPts = 
               RotationTransform[360/5 Degree], 
               {pentagonPts[[2]], innerPt[[1, 1]], pentagonPts[[3]]}, 
    star = {EdgeForm[{Thickness[thick], Red}], FaceForm[blue], Polygon[starPts]};
    Graphics[{circle, star}]]


  {{"", "first column"},
   {"first row", GraphicsGrid[ConstantArray[circledStar, {2, 2}]]}},
  Frame -> All]



If what I did above to generate the star isn't clear to you, consider the following graphic.

Module[{thick, pentagonPts, innerPt, starPart},
  thick = Scaled[.03];
  pentagonPts = CirclePoints[5];
  innerPt =
      Line[{pentagonPts[[1]], pentagonPts[[3]]}], 
      Line[{pentagonPts[[2]], pentagonPts[[4]]}]];
  starPart = Line[{pentagonPts[[2]], innerPt[[1, 1]], pentagonPts[[3]]}];
    {Thickness[thick], Red, starPart,
     Text[Style["innerPt", 14, Black], innerPt[[1, 1]], {0, 2}],, 
     MapThread[Text[Style[#1, 20, Black], #2] &, {Range[5], pentagonPts}]}]]


Here you see the five vertices of a pentagon labeled 1 through 5. In the code I found the intersection of the line from 1 to 3 with the line from 2 to 4. Then I constructed one fifth of the star from points 2 and 3 and innerPt, the found intersection.

In the main graphic. I took this set of tree points, rotated it trough 105 degrees about the origin, rotated the results trough 105 degrees again, and so on until I had five sets of three points. I deleted the duplicates and made a flat list of remaining points, which form the vertices of the star polygon in the main graphic.

  • $\begingroup$ Thank you so much for your clear explanation. It was very good $\endgroup$ – Inzo Babaria Feb 28 '18 at 13:09
  • $\begingroup$ @InzoBabaria. I'm glad you find my answer useful. Please consider accepting this answer or the other one, whichever you think best. You can do that by clicking on the check mark that appears on the left of an answer below the down arrow. $\endgroup$ – m_goldberg Feb 28 '18 at 15:46
  • $\begingroup$ @m_goldberg: When I evaluate your code, the figure is created, but I get a N::meprec warning, originating in the RegionIntersection command in MMA 11.0.1. This can be avoided by putting N@ in front of CirclePoints. $\endgroup$ – JEM_Mosig Feb 28 '18 at 22:34
  • $\begingroup$ @InzoBabaria. I'm using 11.2.1. CirclePoints returns coordinate in exact numbers for a pentagon, so there is problem with precision when passing points that it returns to R RegionIntersection. Did you somehow compute the pentagon vertices with machine floats? $\endgroup$ – m_goldberg Feb 28 '18 at 22:59

You can create the circle/star figure with

          (* outer points of the star *)
          (* inner points of the star *)
          CirclePoints[{(* inner radius: *) 0.4, -\[Pi]/2}, 5]
       (* sort points by angle *)
       N[ArcTan@@#] &
       (* enclosing circle *)
       Directive[Thick, Red],
       (* star *)
       EdgeForm[Directive[Thick, Red]],

circle-star graphics output

You can adjust the thickness of the lines with, e.g., Thickness[.03] instead of Thick. If thick lines reach beyond the circle, you may increase its radius, e.g. by Circle[{0,0}, 1.1].

I am not sure what you mean by your second question, though.


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.