Re: Writing images from manipulate
- To: mathgroup at smc.vnet.net
- Subject: [mg117669] Re: Writing images from manipulate
- From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
- Date: Tue, 29 Mar 2011 06:57:17 -0500 (EST)
- References: <imfa77$ion$1@smc.vnet.net>
Setting SynchronousUpdating to False (instead of True) will probably help. As far as I can see there is no reason to use nb = CreatePalette[nm = SystemDialogInput["FileSave"]]; nm = SystemDialogInput["FileSave"] on its own will work. What's the purpose of currentgraphic = currentgraphic = ... ? WRT to saving various file types you might like a construction like: SystemDialogInput["FileSave", {Directory[], {"TIFF" -> {"*.tif"}, "JPEG" -> {"*.jpg", "*.jpeg"}, "GIF" -> {"*.gif"}, "PNG" -> {"*.png"}}}] Cheers -- Sjoerd On Mar 24, 12:33 pm, "W. Craig Carter" <ccar... at mit.edu> wrote: > 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 > about it. > > 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 -> Fal= se}, > {{WriteImage, False, "Write Image File"}, {True, False}, > ControlType -> Checkbox, Labeled -> False}, > {{reset, False, "reset to zero"}, {True, False}, ControlType -> Checkb= ox, > 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]]]]) > ]