1

A long time ago they gave me many answers to these questions,

Code that generates a mandala

is it possible to enter text in the center something like "abcde" , without the quotes and maybe with some pretty font

zeros
  • 2,263
  • 1
  • 14
  • 18

1 Answers1

2

Using the function MakeMandala from this answer by Anton Antonov:

SeedRandom[123];
Show[MakeMandala[],
 Epilog -> {White, Disk[{0, 0}, Scaled[.15]], 
   Text[Style["abcd", 
     FontSize -> Scaled[.1], FontFamily -> "Cambria",FontColor -> Red]]}]

enter image description here

SeedRandom[123];

Multicolumn[ Table[Show[MakeMandala[] /. _GrayLevel -> RandomColor[], Background -> Black, Epilog -> {Black, Disk[{0, 0}, Scaled[.15]], Text[Style["abcd", FontSize -> Scaled[.1], FontFamily -> "Cambria", FontColor -> Red]]}], 10], 5]

enter image description here

Update: "how the hollow letters can be placed so that they can be painted":

SeedRandom[123];
textoutlines = MeshPrimitives[
  BoundaryDiscretizeGraphics[
   Text[Style["abcd", 
     FontSize -> 5, FontFamily -> "Cambria", FontColor -> Red]], 
   _Text], 1];

Multicolumn[ Table[Show[MakeMandala[] /. _GrayLevel -> (rc = RandomColor[]), Background -> Black, Epilog -> {Black, Disk[{0, 0}, Scaled[.15]], AbsoluteThickness[.5], rc, textoutlines}, ImageSize -> Medium], 4], 2]

enter image description here

Update 2: Put a frame on mandalas and export to PDF:

textoutlines = MeshPrimitives[
   BoundaryDiscretizeGraphics[
    Text[Style["abcd",
      FontSize -> 5,
      FontFamily -> "Cambria",
       FontColor -> GrayLevel[0.25]]],
    _Text],
   1];

SeedRandom[123];

{rows, columns} = {4, 2};

mandalagrid = Rasterize[Grid@ Table[Show[MakeMandala[], Epilog -> {{White, Disk[{0, 0}, Scaled[.15]]}, AbsoluteThickness[.5], textoutlines}, Frame -> True, FrameTicks -> None, ImagePadding -> 10, ImageSize -> 500], rows, columns], ImageResolution -> 400];

Export["mandalagrid.pdf", mandalagrid]

"mandalagrid.pdf"

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
  • hi , I get this error ,Show::gtype: MakeMandala is not a type of graphics. I have MMA version 13.0 .Is there a way to adapt it for my version? – zeros Jun 02 '23 at 03:05
  • 1
    @zeros, you need to copy the code for functions MakeSeedSegment, MakeSymmetric and MakeMandala from the linked page. – kglr Jun 02 '23 at 03:36
  • It took me a while to integrate it, I haven't worked with MMA for a long time, one last question, how can I add, instead of one line, 2 lines something like
    abc defgh , first line "abc" , second line "defgh" Thanks in advance
    – zeros Jun 02 '23 at 14:14
  • 2
    replace Style["abcd,...] with Style["abc\ndefgh", ...] – kglr Jun 02 '23 at 14:21
  • ,hi , thank ,I forgot to ask how the hollow letters can be placed so that they can be painted – zeros Jun 02 '23 at 17:35
  • ,In the end, I did something similar to what you did but with a white background, if you come here, maybe you can help me with two things, like putting a frame on each image and exporting it to pdf to cut them out. Varying some parameters I have achieved several different ones and I managed to insert 8 in a 216mm x 330mm pdf, any ideas how to make several different ones and export them at the same time. I need them so that some children can entertain themselves by painting them. Thanks for everything – zeros Jun 03 '23 at 04:03
  • 1
    zeros, please see update 2. – kglr Jun 03 '23 at 15:12
  • ,Thank you very much, it has helped me a lot, I wanted to bother you with the last thing: From the page where the main code originates, there is a code snippet that allows to make many mandalas all different. Could you implement that in the code you have written for me to generate a pdf with at least 10 pages, with 8 mandalas in each one, all different,code below – zeros Jun 04 '23 at 02:16
  • code :n = 12; Multicolumn@ MapThread[ If[#1, MakeMandala[MakeSeedSegment[10, #2, #3], #2], MakeMandala[MakeSymmetric[MakeSeedSegment[10, #2, #3, #4, False]], 2 #2] ] &, {RandomChoice[{False, True}, n], RandomChoice[{[Pi]/7, [Pi]/8, [Pi]/6}, n], RandomInteger[{8, 14}, n], RandomChoice[{Line, Polygon, BezierCurve, FilledCurve[BezierCurve[#]] &}, n]}] – zeros Jun 04 '23 at 02:17
  • hi, Did you see my last message, can you enter the code that I left you? – zeros Jun 05 '23 at 15:10
  • zeros, please see this Q/A for exporting to a multiple-page PDF. – kglr Jun 05 '23 at 15:50
  • hi ,Apparently you misunderstood me, my question was how to insert that piece of code in the program that you explained to me to generate multiple mandalas, if these remain uneven when exporting to pdf, I can somehow fix it by editing the pdf. If you haven't gotten bored of me, I'd appreciate any help. – zeros Jun 06 '23 at 17:00