0
$\begingroup$

This piece of code returns 10 pictures all at once as output. However, I would like to save each mandala picture file separately. So design one will have picture1.jpg, design two will have picture2.jpg and design three will have picture3.jpg saved.

n = 10;
data = 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]}]
Export["Picture1.jpg", %]

However, this code only save ALL desings to one jpg file. How can I fix this issue.

Thank you

$\endgroup$
3
  • 3
    $\begingroup$ The Multicolumn[] should be removed first. After that: MapIndexed[Export["picture" <> Apply[IntegerString, #2] <> ".jpg", #] &, data] $\endgroup$ Sep 27, 2018 at 6:48
  • $\begingroup$ Amazing!! Thank you for your help. it worked. $\endgroup$
    – ben olsen
    Sep 27, 2018 at 7:03
  • 2
    $\begingroup$ Some tips: in Mathematica, "everything is an expression". The implication is that it is given that the plots can be stored in a list. They don't just exist in a notebook window, or as pixels on the screen. They're actual Mathematica expressions. Once you know that, all you need is to loop through the list (or rather use Map/Scan or better: MapIndexed) and Export each element. $\endgroup$
    – Szabolcs
    Sep 27, 2018 at 7:45

0

Browse other questions tagged or ask your own question.