# Maintaining shape size while rotating in GraphicsGrid

I've the following snippet, simplified from a more complex code:

Shape[x_] := Rectangle[
{0, 0},
{1, 1},
]

exp1 = Table[
{
EdgeForm[Black],
Hue[Sqrt[x]],
Translate[
Rotate[
Shape[x],
x
],
{x*1.3, 0}
]
},
{x, 0, 10, 1}
];
GraphicsGrid[Partition[Graphics /@ exp1, 10]]


This is the output:

How can I maintain the size of rectangles during the rotation? I'd like them to have all the same size.

• why do you have Shape[x_] but x is not used any where in the function? Commented Feb 5, 2022 at 15:40
• The Partition is discarding the last element of the Table. To retain that element use GraphicsGrid[{Graphics /@ exp1}] If the discard is intentional, additionally change the upper bound on the Table to 9 Commented Feb 5, 2022 at 16:04
• @Nasser because Shape must represent a generic shape depending on the variable. In this particular example is not dependent from X because it was not the focus of the question, but I shoulr be able to use other shapes dependent on X Commented Feb 5, 2022 at 16:16

The different sizes are created by the unnecessary "GraphicsGrid" that scales the different pictures. Without it:

SimplifyShape := Rectangle[{0, 0}, {1, 1}, RoundingRadius -> 0.1]
exp1 = Table[{EdgeForm[Black], Hue[Sqrt[x]],
Translate[Rotate[SimplifyShape, x], {x*1.5, 0}]}, {x, 0, 10, 1}];
exp1 // Graphics


Update

If you want an "regular array", that is a vector, of images the same size, use RotateImage:

exp1 = Table[
ImageRotate[
Graphics[{EdgeForm[Black], Hue[Sqrt[x]], SimplifyShape}], x,
Background -> Transparent], {x, 0, 10, 1}];
exp1


• What if I need a rectangular array (that was the reason of Partition)? Commented Feb 5, 2022 at 16:19

Translate a circle to the same location. Set the color of the circle to White and you will have what you are looking for. I am sure there are more formal solutions available.

Shape[x_] := Rectangle[{0, 0}, {1, 1}, RoundingRadius -> 0.1]

exp1 = Table[{
EdgeForm[Black], Hue[Sqrt[x]],
Translate[Rotate[Shape[x], x], {x*1.3, 0}]
, Black, Translate[Circle[{0.5, 0.5}, 0.7], {x*1.3, 0}]
}, {x, 0, 10, 1}
];
GraphicsGrid[Partition[Graphics /@ exp1, 10]]


• +1 Alternatively, you could set the circles opacity to 0 Commented Feb 5, 2022 at 16:08

Specify ImageSize in each Graphics using the (still undocumented) syntax ImageSize -> 1 -> size (which makes 1 unit in user units correspond to size points in rendered image) :

GraphicsGrid[Partition[Graphics[#, ImageSize -> 1 -> 50] & /@ exp1, 10]]


Compare with

GraphicsGrid[Partition[Graphics[#, ImageSize -> 50] & /@ exp1, 10]]


Using with symbolic sizes:

Table[Labeled[GraphicsGrid[
Partition[Graphics[#, ImageSize -> is] & /@ exp1, 10]],
Style[ImageSize -> is, 24], Top],
{is, {5/3 -> Tiny, 3 -> Small, 6 -> Medium, 6 -> Automatic, 9.5 -> Large}}] //
Column[#, Dividers -> All] &


Use the 1st and 8th parts of exp1 to compare the results of two ways of specifying image size. Note how the spec ImageSize -> 1 -> size modifies the actual image size so that an object with a length of 1 user unit rendered as size pixels long:

Row[Labeled[#, Column[{"ImageDimensions:", ImageDimensions @ #}, Center], Top] & @
Graphics[#, ImageSize -> 1 -> 200] & /@ exp1[[{1, 8}]]]


versus

Row[Labeled[#, Column[{"ImageDimensions:", ImageDimensions @ #}, Center], Top] & @
Graphics[#, ImageSize -> 200] & /@ exp1[[{1, 8}]]]
`