Writing images from manipulate

• To: mathgroup at smc.vnet.net
• Subject: [mg117621] Writing images from manipulate
• From: "W. Craig Carter" <ccarter at mit.edu>
• Date: Thu, 24 Mar 2011 06:32:20 -0500 (EST)

```Dear MathGroup,
I am teaching a laboratory course. As part of one laboratory, students
run a simulation on their laptops and then use a generated image in
their lab reports.

I have a method of writing images from Manipulate, ***but it fails on
some but not all*** windows laptops that the students use.

I've made as simplified representation of the code and am pasting it
here. I hope that it is not too long to receive some advice.

The relevant bit is at the If[WriteImage,..] part.  Is there a more
reliable way to save the image?

Also, I am wondering if the constant reevaluation of the
If[Evolution=="go",...] part can be avoided, or should I not worry

Just running the Manipulate will give a self-explanatory idea of what
the code is doing., Thanks Craig

seeds = RandomReal[{0, 1}, {20, 2}]
radii = ConstantArray[0, {20}]
colors =  Hue /@ RandomReal[{0, 1}, {20}]

Manipulate[

If[reset,
radii = ConstantArray[0, {20}]; reset = False;
currentgraphic =
currentgraphic =
Graphics[
GraphicsComplex[seeds,
Map[{colors[[#]], Disk[#, radii[[#]]]} &, Range[20]]]]];

If[WriteImage,(*works on a mac, works on *some* windows*)

nb = CreatePalette[nm = SystemDialogInput["FileSave"]];
WriteImage = False;
Export[nm, currentgraphic];
NotebookClose[nb]
];

If[Evolution == "Go", (*constant evaluation of the if?*)
radii += RandomReal[{0, .0001}, {20}];
currentgraphic =
Graphics[
GraphicsComplex[seeds,
Map[{colors[[#]], Disk[#, radii[[#]]]} &, Range[20]]]];
];
currentgraphic,

{Evolution, {"Stop", "Go"}, ControlType -> RadioButton, Labeled -> False},
{{WriteImage, False, "Write Image File"}, {True, False},
ControlType -> Checkbox, Labeled -> False},
{{reset, False, "reset to zero"}, {True, False}, ControlType -> Checkbox,
Labeled -> False},
TextCell[
"Use .tiff, .gif, or .jpeg, etc, file extensions explicitly for image file \
formats"],
SynchronousUpdating -> True,
Initialization -> (
currentgraphic =
currentgraphic =
Graphics[
GraphicsComplex[seeds,
Map[{colors[[#]], Disk[#, radii[[#]]]} &, Range[20]]]])
]

```

• Prev by Date: Re: Using Nearest on a group of points
• Next by Date: Re: Using Nearest on a group of points
• Previous by thread: Re: Applying a condition to a symbolic matrix
• Next by thread: Re: Writing images from manipulate