Wolfram Research

Function Repository Resource:

RandomMandala

Source Notebook

Make random mandala plots

Contributed by: Anton Antonov

ResourceFunction["RandomMandala"][]

generates a mandala graphic.

Details and Options

The mandalas made by ResourceFunction["RandomMandala"] are generated through rotational symmetry of a “seed segment”.
RandomMandala accepts the same options as Graphics as well as the following options to specify different features of the seed segment generation and rotational symmetry order:
"RotationalSymmetryOrder" 6 a value k defining the rotation symmetry angle, 2 π/k
"Radius" 10 maximum radius of the seed segment generation points
"SymmetricSeed" True should the seed be symmetric or not
"NumberOfSeedElements" Automatic the number of elements in a seed segment
"KeepGridPoints" False should the grid points be shown
"ConnectionFunction" Random how to connect grid point
"ColorFunction" None how to colorize the mandala
The option "ConnectionFunction" specifies what Graphics primitive function should be used to connect the grid points of the seed segment. If the value is Automatic then Polygon is used. If the value is Random then a random choice is made from the following: Line, Polygon, BezierCurve, FilledCurve[BezierCurve[#]]&.

Examples

Basic Examples

Here we generate a random mandala:

In[1]:=
SeedRandom[4243]
ResourceFunction["RandomMandala"][]
Out[2]=

Here we generate a mandala with different option settings:

In[3]:=
SeedRandom[1]
ResourceFunction["RandomMandala"]["RotationalSymmetryOrder" -> 7, "Radius" -> 12, "SymmetricSeed" -> False]
Out[4]=

Scope

There are two modes of making random mandalas: (i) single-mandala mode and (ii) multi-mandala mode. The multi-mandala mode is activated by giving the “Radius” option a list of positive reals.


Here are gray-level and colorized mandalas generated with the single-mandala mode:

In[5]:=
SeedRandom[54929];
Table[ResourceFunction["RandomMandala"]["Radius" -> 10], 4]
Out[6]=
In[7]:=
SeedRandom[54929];
Table[ResourceFunction["RandomMandala"]["Radius" -> 10, ColorFunction -> ColorData["Rainbow"]], 4]
Out[8]=

Here are gray-level and colorized mandalas generated with a multi-mandala mode:

In[9]:=
SeedRandom[54929];
Table[ResourceFunction["RandomMandala"]["Radius" -> {7, 5, 3}], 4]
Out[10]=
In[11]:=
SeedRandom[54929];
Table[ResourceFunction["RandomMandala"]["Radius" -> {7, 5, 3}, ColorFunction -> "Rainbow"], 4]
Out[12]=

Options

ColorFunction

The function given to ColorFunction is run over Range[0,1,0.1] the obtained colors are used to colorize the mandala. By default no colorizing is done, ColorFunctionNone.

ColorFunction can also take strings that are color schemes known by ColorData.

Here is a list of colorized mandalas using single-mandala mode:

In[13]:=
Table[SeedRandom[17]; ResourceFunction["RandomMandala"][ColorFunction -> ColorData[cf], PlotLabel -> cf], {cf, {"Rainbow", "SouthwestColors", "BrightBands",
    "DeepSeaColors"}}]
Out[13]=

Here are mandalas generated using multi-mandala mode:

In[14]:=
Table[SeedRandom[74]; ResourceFunction["RandomMandala"]["Radius" -> {7, 6, 4}, ColorFunction -> cf, PlotLabel -> cf], {cf, {"Rainbow", "SouthwestColors", "BrightBands",
    "DeepSeaColors"}}]
Out[14]=

ConnectingFunction

The option "ConnectingFunction" specifies which graphics primitive to be used over the seed segment points:

In[15]:=
Table[(SeedRandom[263]; ResourceFunction["RandomMandala"]["ConnectingFunction" -> cf, PlotLabel -> cf]), {cf, {Line, Arrow, Polygon, BezierCurve, FilledCurve@*BezierCurve}}]
Out[15]=

KeepGridPoints

The option "KeepGridPoints" specifies should the points used to generate the seed segment be kept or not:

In[16]:=
Table[(SeedRandom[163]; ResourceFunction["RandomMandala"]["KeepGridPoints" -> k, "NumberOfSeedElements" -> 3, "RotationalSymmetryOrder" -> 6, PlotLabel -> k]), {k, {True, False}}]
Out[16]=
In[17]:=
Table[(SeedRandom[163]; ResourceFunction["RandomMandala"]["KeepGridPoints" -> k, "NumberOfSeedElements" -> 5, "RotationalSymmetryOrder" -> 6, PlotLabel -> k]), {k, {True, False}}]
Out[17]=

NumberOfElements

The option "NumberOfElements" controls how may graphics elements are in the seed segment:

In[18]:=
Table[(SeedRandom[200]; ResourceFunction["RandomMandala"]["NumberOfSeedElements" -> n, "RotationalSymmetryOrder" -> 3, PlotLabel -> Row[{"n:", Spacer[2], n}]]), {n, 1, 6}]
Out[18]=
In[19]:=
Table[(SeedRandom[200]; ResourceFunction["RandomMandala"]["NumberOfSeedElements" -> n, "RotationalSymmetryOrder" -> 3, PlotLabel -> Row[{"n:", Spacer[2], n}]]), {n, 5, 20, 5}]
Out[19]=

If the value of “NumberOfElements” is Automatic in single-mandala mode 6 elements are used, and in multi-mandala mode 3 elements are used (for each mandala.)

Radius

In single-mandala mode the option "Radius" specifies the radius of the seed segment and the mandala:

In[20]:=
Table[(SeedRandom[226]; ResourceFunction["RandomMandala"]["Radius" -> r, PlotLabel -> Row[{"radius:", Spacer[2], r}], Frame -> True]), {r, 5, 20, 5}]
Out[20]=

If the value given to “Radius” is a list of positive numbers then multi-mandala mode is used.

If "Radius"{r1,,rk}, then for each ri is made a mandala with radius ri and the mandalas are drawn upon each other according to their radii order:

In[21]:=
SeedRandom[98];
ResourceFunction["RandomMandala"]["Radius" -> Range[8, 2, -2]]
Out[19]=

Using the option ColorFunction colorized mandalas are obtained:

In[22]:=
SeedRandom[98];
ResourceFunction["RandomMandala"]["Radius" -> Range[8, 2, -2], ColorFunction -> ColorData["Rainbow"]]
Out[23]=

RotationalSymmetryOrder

The "RotationalSymmetryOrder" option specifies how many copies of the seed segment comprise the mandala:

In[24]:=
Table[(SeedRandom[122]; ResourceFunction["RandomMandala"]["RotationalSymmetryOrder" -> a, PlotLabel -> Row[{"order:", Spacer[2], a}]]), {a, {2, 3, 4, 6}}]
Out[24]=
In[25]:=
Table[(SeedRandom[122]; ResourceFunction["RandomMandala"]["RotationalSymmetryOrder" -> a, "SymmetricSeed" -> False, PlotLabel -> Row[{"order:", Spacer[2], a}]]), {a, {2, 3, 4, 6}}]
Out[25]=

SymmetricSeed

The option "SymmetricSeed" specifies should the seed segment be symmetric or not:

In[26]:=
Table[(SeedRandom[122]; ResourceFunction["RandomMandala"]["SymmetricSeed" -> s, PlotLabel -> s]), {s, {True, False}}]
Out[26]=

Possible Issues

In general, the rotational symmetry order should be an integer, but for didactic purposes it is permitted to be a positive real. If the specified rotational symmetry order is not an integer, then the produced mandalas will appear “open”:

In[27]:=
SeedRandom[23];
rotOrders = RandomReal[{0, 10}, 5]
Out[25]=
In[28]:=
Table[(SeedRandom[32]; ResourceFunction["RandomMandala"][
   "RotationalSymmetryOrder" -> r]), {r, rotOrders}]
Out[28]=
In[29]:=
Table[(SeedRandom[1]; ResourceFunction["RandomMandala"][
   "RotationalSymmetryOrder" -> r]), {r, rotOrders}]
Out[29]=

Neat Examples

A table of random mandalas

In[30]:=
SeedRandom[342]; Multicolumn[
 Table[ResourceFunction["RandomMandala"][
   "RotationalSymmetryOrder" -> RandomChoice[{3, 6, 12}], "SymmetricSeed" -> RandomChoice[{True, False}], ImageSize -> Tiny],
   36], 6]
Out[30]=

A table of random colorized mandalas

In[31]:=
SeedRandom[474]; Multicolumn[
 Table[ResourceFunction["RandomMandala"][
   "Radius" -> Reverse[Range[RandomChoice[{3, 4, 5, 6}]]], "NumberOfSeedElements" -> RandomChoice[{2, 3, 4}], "RotationalSymmetryOrder" -> RandomChoice[{3, 4, 5, 6, 7}], ColorFunction -> "Rainbow", "ConnectingFunction" -> FilledCurve@*BezierCurve, "SymmetricSeed" -> True, ImageSize -> Tiny], 36], 6]
Out[31]=

A table of “open” colorized mandalas

In[32]:=
n = 36;
Magnify[Multicolumn[
  Map[BlockRandom[SeedRandom[24]; ResourceFunction["RandomMandala"]["RotationalSymmetryOrder" -> #,
       ColorFunction -> ColorData["DeepSeaColors"]]] &, RandomReal[{2, 4}, n]], 6], 0.5]
Out[25]=

Colored mandala images by blending

Make a list of random mandalas:

In[33]:=
SeedRandom[6567]
mandalas = Table[ResourceFunction["RandomMandala"][], 36];
Magnify[mandalas, 0.3]
Out[28]=

Make images of the generated mandala graphics:

In[34]:=
AbsoluteTiming[
 mandalaImages = Map[Image[#, ImageSize -> {400, 400}, ColorSpace -> "Grayscale"] &,
     mandalas];
 ]
Out[34]=

Pick mandala images at random and blend them using a set of coloring schemes:

In[35]:=
SeedRandom[3488]
AbsoluteTiming[
 directBlendingImages = Table[
    RemoveBackground@
     ImageAdjust[
      Blend[Colorize[#, ColorFunction -> RandomChoice[{"IslandColors", "FruitPunchColors", "AvocadoColors", "Rainbow"}]] & /@ RandomChoice[mandalaImages, 4], RandomReal[1, 4]]], 12];
 ]
Out[36]=

Make a collage:

In[37]:=
ImageCollage[directBlendingImages, Background -> White, ImagePadding -> 3, ImageSize -> 200]
Out[37]=

Resource History

Source Metadata

License Information