# Draw regular polygon (maximum n = 12) with semicircles on each side,painted black

I need to draw a regular polygon on n sides, n <13 for side L, L <11 in cm. with semicircles on its sides, completely black in such a way that I save it as a xxx.png image to print and cut out later. The important thing is that the dimensions on the screen in cm. are identical to the image to be cropped later. Could you help me. I have seen several examples in the forum, like this one, but I can't find a way to modify it. I attach a picture of the idea.(but totally black without squares or borders, on a white background) L = 12;
Graphics[Line[{{L, 0}, {L/2, L Sqrt/2}, {-L/2, L Sqrt/2}, {-L,
0}, {-L/2, -L Sqrt/2}, {L/2, -L Sqrt/2}, {L, 0}}]]


An obvious method would be stitiching together RegularPolygon[] + appropriately positioned Disk[] objects, but that would usually result in unwanted seams. To avoid this, we can instead build a FilledCurve[] object from the result of CirclePoints[], using the NURBS representation of a semicircle:

With[{r = 2, θ = π/2, n = 7},
Graphics[FilledCurve[MapIndexed[With[{d = (EuclideanDistance @@ #1)
Normalize[Cross[Subtract @@ #1]]/2},
BSplineCurve[If[#2 === {1}, Identity, Rest]
[{#1[], #1[] + d,
#1[] + d, #1[]}],
SplineDegree -> 2,
SplineKnots -> {0, 0, 0, 1/2,
1, 1, 1},
SplineWeights -> {1, 1/2,
1/2, 1}]] &,
Partition[N[CirclePoints[{r, θ}, n]], 2, 1, 2]]]]] Here is the naive approach, also mentioned by J.M. (but he implemented another):

draw[n_, {w_, h_}] := Module[{pts, segments, midPoints, lengths},
pts = With[{ipts = CirclePoints[n]}, Append[ipts, First[ipts]]];
segments = Partition[pts, 2, 1];
midPoints = Mean /@ segments;
lengths = Norm[First[#] - Last[#]] & /@ segments;
Graphics[{
Polygon[pts]
},
ImageSize -> (72/2.54) {w, h},
]
]

draw[7, {10, 10}] ImageSize -> (72/2.54) {w, h} will hopefully mean that if you export this graphics and print it then it will be wxh centimeters large. I removed the plot range padding because otherwise that would count towards the size of the figure. The number 72 comes in because, as documented under ImageSize, the size of the figure is given in printer's points.

Considering the discussion here it seems that you should be careful about printing it directly from Mathematica. The better approach seems to be to export it e.g. to PDF and then print it.

• Thank you all, very good explanation of the printing, which I did not have much idea. On the other hand since I do not use style sheets, as they implement the rule above, it must be a silly question but I do not see it Aug 23, 2020 at 20:14
• @zeros you mean you do not understand how it applies to you? You can just ignore that post. It has some interesting context but it should not be necessary. All you should need to do is export the image to a file, and then print the file. That is my understanding. Aug 23, 2020 at 20:26
• @C.E.Not what I was really asking is how they put the rule at the top of the mathematica sheet, everything interests me, I learn a lot from you. My knowledge of nathematica is limited. Aug 25, 2020 at 4:58
r = 12;
Graphics[{#, Disk[RegionCentroid @ #, r/2] & /@ MeshPrimitives[#, 1]}] & @
RegularPolygon[r, 6] • Or for any number of sides, n, consider Graphics[{#,Disk[RegionCentroid @ #,r Sin[Pi/n]]&/@MeshPrimitives[#,1]}]&@RegularPolygon[r,n] Aug 23, 2020 at 18:58
• @ creidhne,thank you for your suggestion Aug 24, 2020 at 4:27
• @kglr, thanks for your indications Aug 24, 2020 at 4:29