/* This script is supplied with the Mand2000 demo and release */
/* versions and may be freely distributed. */
/* Copyright 1993 Cygnus Software. */

/* An ARexx script for imitating the Demo Mode of the earlier */
/* versions of Mand2000.  This script zooms in (with pauses for */
/* calculations) towards various beautiful locations specified */
/* in the script.  When it reaches them it resets and zooms towards */
/* another location. */


portname = address()	/* Retrieve the current port name. */
/* If the portname does not start with MAND2000 then this script must */
/* have been run with rx, rather than from Mand2000.  Therefore we */
/* need to set the port name.  We do not always set the port name */
/* because it is better to let Mand2000 set it for us, so that */
/* this script can be used with windows other than the one with */
/* port name MAND2000.1. */
if (left(portname, 8) ~= "MAND2000") THEN
	address 'MAND2000.1'

options results

/*
	The  following code sets up the coordinates of the pictures to
zoom  towards  when  running  the  demo.   The format should be fairly
obvious  from  the  examples below.  IMPORTANT:  before adding any new
locations, or making any other changes to this file, be sure to make a
backup  copy, as it is very easy to make syntax errors which will make
this script stop working.

	The  name  of  the location must be enclosed in quotes.  The X
and  Y  coordinates  are  the coordinates of the center of the spot to
zoom  towards.   Zooms  is the number of zooms to do before going onto
the  next  picture.   Type  is the fractal type.  Usually this will be
'Mandelbrot'  or  'Mandelbrot  Julia'.   If you specify Julia then you
should also specify JuliaReal and JuliaImaginary (see Julia Boot as an
example)  as  these  specify the Julia's seed location.  If you have a
math  coprocessor  (68881,  68882  or  68040)  then  you also have the
MandCubed  and  MandFourth  fractal  types, and their associated julia
sets - see the help on set location for details.

	It  is very important when entering new numbers to ensure that
your  numbers  are  correct - no spaces or commas allowed in numbers -
and  that  the index number is the same for all the lines describing a
particular location.  The index number is the number immediately after
'Pictures'.  It is also very important to enclose the location numbers
in quotes, as in the examples below.  If you don't then ARexx will try
to  interpret  the  numbers.   Usually  this  is okay, but many of the
numbers  have more digits of accuracy than ARexx can handle, and these
extra digits will get lost without the quoting.

	Because  the  demo  code  jumps  through the list in numerical
order  (not  necessarily  in  the order they are defined in the file -
although  right now that is the same thing) it is important that there
be  no  gaps  in  the  list.   For  instance,  it  must go Pictures.0,
Pictures.1,  Pictures.2,  etc.   It  is  also important that the final
entry  have  a  zoom  count  of  zero so that the code will no when to
return to the first entry.

	Forgetting to adjust the index number of the terminating entry
is  the  single  most common error when adding entries to this script.
Its  index number MUST be one larger than the index number of the last
entry.

	Currently  this  script  is set up so that if you run it, then
stop,  then  run  it  again,  it  will  resume on the same picture you
stopped  on  (although  not  the  same zoom level).  If this behaviour
causes  problems, or if this script encounters an error and ends up in
an  undefined  state,  comment  out  the  line  below  which  says 'if
(DemoPictureNum   =  "")  THEN'  by  enclosing  it  in  ARexx  comment
delimiters,  like  this '/* if (DemoPictureNum = "") */'.  Do not type
the  quotes.   The  line  is  clearly  marked and is shortly after the
StartDemo:  label.

	If you run this script several times in a row without stopping
it,  you  will  end  up with multiple 'Stop Demo' entries in your user
menu.   These can be removed by repeatedly selecting 'Stop Demo' until
they are all gone.

	If  for  some  reason  you  can  not  get  this script to stop
running,  you  may  need to exit Mand2000.  This should only happen if
there is a bug in the ARexx script.

	For  more  information,  consult  your  ARexx  manual  or  the
Mand2000 ARexx documentation.
	*/

Pictures.0.Name = "Twelve arms"
Pictures.0.X = "-.7764"
Pictures.0.Y = "0.1346"
Pictures.0.Zooms = 12
Pictures.0.Type = "Mandelbrot"

Pictures.1.Name = "Dragon"
Pictures.1.X = "-1.25269"
Pictures.1.Y = "-0.04164"
Pictures.1.Zooms = 12
Pictures.1.Type = "Mandelbrot"

Pictures.2.Name = "Off axis filaments"
Pictures.2.X = "-1.74910040"
Pictures.2.Y = "-0.00034817"
Pictures.2.Zooms = 25
Pictures.2.Type = "Mandelbrot"

Pictures.3.Name = "Six arms"
Pictures.3.X = "-.8627"
Pictures.3.Y = "0.2648"
Pictures.3.Zooms = 10
Pictures.3.Type = "Mandelbrot"

Pictures.4.Name = "Julia Boot"
Pictures.4.X = "0"
Pictures.4.Y = "0"
Pictures.4.JuliaReal = "0.329"
Pictures.4.JuliaImaginary = "0.041"
Pictures.4.Zooms = 4
Pictures.4.Type = "Mandelbrot JULIA"

Pictures.5.Name = "Nautilus"
Pictures.5.X = "-1.98540769643288"
Pictures.5.Y =  "0.00000000000470"
Pictures.5.Zooms = 38
Pictures.5.Type = "Mandelbrot"

Pictures.6.Name = "Paisley"
Pictures.6.X = "0.306594"
Pictures.6.Y = "0.023627"
Pictures.6.Zooms = 10
Pictures.6.Type = "Mandelbrot"

Pictures.7.Name = "Russian circles"
Pictures.7.X = "-1.98540769644835784"
Pictures.7.Y =  "0.0"
Pictures.7.Zooms = 50
Pictures.7.Type = "Mandelbrot"



Pictures.8.Zooms = 0	/* This marks the end of the list. */



/* Parse out the command option.  This script is called when the */
/* user wants demo mode started, when the user wants demo mode terminated */
/* and whenever one of the demo frames is finished. */

parse arg command

command = upper(command)	/* Make sure the command is in upper case. */

if (command = START) then
	CALL StartDemo()
else if (command = STOP) then
	CALL StopDemo()
else
	CALL ContinueDemo()

Exit



StartDemo:
	DemoPictureNum = GETCLIP("DemoPictureNum")
	/* Comment out the following line if you want this script to always */
	/* restart at frame zero when you rerun it. */
	if (DemoPictureNum = "") THEN
		DO
		DemoPictureNum = 0
		CALL SETCLIP("DemoPictureNum", DemoPictureNum)
		END
	CALL NewLocation()
	EVENTACTION PICTUREDONE Demo

	/* Put a command in the user menu for stopping the movie creation. */
	menu '"------------------------"'
	menu '"Stop Demo"' Demo stop
	RETURN 0



StopDemo:
	/* Tell Mand2000 not to call this script any more. */
	EVENTACTION PICTUREDONE
	/* Remove the `stop iter movie' menu. */
	CLEARNMENUS 2
	DISPLAYMESSAGE off
	RETURN 0



ContinueDemo:
	DemoPictureNum = GETCLIP("DemoPictureNum")
	GETATTR stem PROJ
	if (PROJ.NumZooms >= Pictures.DemoPictureNum.Zooms) THEN DO
		DemoPictureNum = DemoPictureNum + 1
		if (Pictures.DemoPictureNum.Zooms = 0) THEN	/* End of list */
			DemoPictureNum = 0
		CALL SETCLIP("DemoPictureNum", DemoPictureNum)
		CALL NewLocation()
		RETURN 0
		END
	ZoomInToFloat Pictures.DemoPictureNum.X Pictures.DemoPictureNum.Y
	RETURN 0



NewLocation:
	RESET
	SETFRACTALTYPE Pictures.DemoPictureNum.Type
	if (Pictures.DemoPictureNum.JuliaReal ~= "") THEN
		SETJULIA Pictures.DemoPictureNum.JuliaReal Pictures.DemoPictureNum.JuliaImaginary
	/* Remove the comments on the following line if you want the pictures */
	/* name printed to the CLI when a new pictures starts calculating. */
	/* say Pictures.DemoPictureNum.Name*/

	/* Comment out the following line if you don't want the status window. */
	DisplayMessage 0 0 prompt "Calculating:" Pictures.DemoPictureNum.Name
	RETURN 0
