Wolfram Research

Function Repository Resource:

RandomMandala (2.1.0) current version: 2.3.0 »

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”.
ResourceFunction["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
"FaceForm" {} face graphics directive for filled objects
"EdgeForm" {} edge graphics directive for filled objects
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 (2) 

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 (3) 

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 (12) 

ColorFunction (2) 

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, ColorFunction->None.

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 (1) 

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]=

EdgeForm (1) 

The option EdgeForm specifies directives for the edges of polygons or other filled graphics objects:

In[16]:=
SeedRandom[42];
ResourceFunction["RandomMandala"]["Radius" -> 8, "RotationalSymmetryOrder" -> 5, "ConnectingFunction" -> FilledCurve@*BezierCurve, EdgeForm -> {Red, Thick}]
Out[14]=

FaceForm (1) 

The option FaceForm specifies directives for the faces of polygons or other filled graphics objects:

In[17]:=
Table[(SeedRandom[8]; ResourceFunction["RandomMandala"]["Radius" -> {6, 8, 4}, ColorFunction -> "Rainbow", "ConnectingFunction" -> FilledCurve@*BezierCurve, PlotLabel -> Row[{"Opacity:", Spacer[3], op}], FaceForm -> {Opacity[op]}]), {op, {0.4, 0.6, 1}}]
Out[17]=

KeepGridPoints (1) 

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

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

NumberOfElements (1) 

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

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

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 (2) 

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

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

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[23]:=
SeedRandom[98];
ResourceFunction["RandomMandala"]["Radius" -> Range[8, 2, -2]]
Out[21]=

Using the option ColorFunction colorized mandalas are obtained:

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

RotationalSymmetryOrder (2) 

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

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

If both "Radius" and “RotationalSymmetryOrder” is given given lists of numbers then the corresponding elements in those are paired to make the specifications of the colorized mandalas:

In[28]:=
Table[
 SeedRandom[122];
 ResourceFunction["RandomMandala"]["Radius" -> {8, 4}, "RotationalSymmetryOrder" -> rs, "ConnectingFunction" -> FilledCurve@*BezierCurve, ColorFunction -> "Rainbow", FaceForm -> {Opacity[0.7]}, EdgeForm -> {White, Opacity[1]}, PlotLabel -> Row[{"order:", Spacer[2], rs}]], {rs, {{4, 2}, {6, 3}, {5, 10}}}]
Out[28]=

SymmetricSeed (1) 

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

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

Properties and Relations (2) 

Using combinations of settings for ColorFunction, EdgeForm, and FaceForm can produce certain more nuanced mandala effects than, say, just using ColorFunction:

In[30]:=
Table[
 SeedRandom[89];
 ResourceFunction["RandomMandala"]["Radius" -> {8, 6, 4}, "RotationalSymmetryOrder" -> {12, 6, 3}, "ConnectingFunction" -> FilledCurve@*BezierCurve, ColorFunction -> "RustTones", ImageSize -> 300, opts], {opts, {{FaceForm -> {Opacity[0.7]}, EdgeForm -> {White, Thickness[0.006], Opacity[1]}}, {}}}]
Out[30]=

RandomMandala can be used in more or less the same way as the resource function RandomScribble. Here, RandomMandala is used with the resource function TexturizePolygons:

In[31]:=
SeedRandom[5353];
ResourceFunction["TexturizePolygons"][{"Dodecahedron", "Net"}, Table[ResourceFunction["RandomMandala"][
   ColorFunction -> ColorData["Rainbow"]], 4], "Granularity" -> "Polygon"]
Out[32]=

Here, the resource function RandomScribble is used with the resource function TexturizePolygons:

In[33]:=
SeedRandom[2323];
ResourceFunction["TexturizePolygons"][{"Dodecahedron", "Net"}, Table[ResourceFunction["RandomScribble"][
   "NumberOfStrokes" -> RandomInteger[{600, 820}, 2], ColorFunction -> ColorData["Rainbow"]], 4], "Granularity" -> "Polygon"]
Out[34]=

Possible Issues (1) 

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[35]:=
SeedRandom[23];
rotOrders = RandomReal[{0, 10}, 5]
Out[27]=
In[36]:=
Table[(SeedRandom[32]; ResourceFunction["RandomMandala"][
   "RotationalSymmetryOrder" -> r]), {r, rotOrders}]
Out[36]=
In[37]:=
Table[(SeedRandom[1]; ResourceFunction["RandomMandala"][
   "RotationalSymmetryOrder" -> r]), {r, rotOrders}]
Out[37]=

Neat Examples (4) 

A table of random mandalas

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

A table of random colorized mandalas

In[39]:=
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 -> "DarkRainbow", "ConnectingFunction" -> FilledCurve@*BezierCurve, "SymmetricSeed" -> True, FaceForm -> {Opacity[0.7]}, EdgeForm -> {LightBlue, Opacity[1]}, ImageSize -> 150], 25], 6]
Out[39]=

A table of “open” colorized mandalas

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

Colored mandala images by blending (4) 

Make a list of random mandalas:

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

Make images of the generated mandala graphics:

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

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

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

Make a collage:

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

Version History

  • 2.3.0 – 04 December 2023
  • 2.2.0 – 18 April 2022
  • 2.1.0 – 20 December 2021
  • 2.0.0 – 23 October 2019
  • 1.0.0 – 11 October 2019

Source Metadata

Related Resources

Author Notes

The Python RandomMandala package was implemented in order to compare it with this repository function. (And, hence, compare Python and Wolfram Language.)

License Information