MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Writing images from manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117656] Re: Writing images from manipulate
  • From: mkrkmr <mkrkmr at gmail.com>
  • Date: Tue, 29 Mar 2011 06:54:44 -0500 (EST)
  • References: <imfa77$ion$1@smc.vnet.net>

The code does not work on my Mac as posted.  If I eliminate the
CreatePalette and NotebookClose (but keep the SystemDialogInput), it
works.  To save an image in a file in the situation you describe, I
usually click on it to select it and use "Save Selection As..." on the
File menu.  I assume there is something similar on Windows.  If you
want to do it programmatically, you might want to check the value
returned by SystemDialogInput is not $Canceled.

As for testing Evolution, it takes very little time -- not enough to
worry about in this application.  (And it's not evaluated constantly
if the setting is "Stop".)  There are ways to control the frequency of
the reevaluation (for instance, with Dynamic[Refresh[..]] and
UpdateInterval) when the setting is "Go".  Right now, it reevaluates
as fast as it can, and that depends on how fast the machine is.

Mike

On Mar 24, 7:33 am, "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]]]])
>  ]



  • Prev by Date: Re: Why Mathematica does not issue a warning when the calculations
  • Next by Date: Re: Importing into Mathematica from URL (PubMed)
  • Previous by thread: Writing images from manipulate
  • Next by thread: Re: Writing images from manipulate