31 : base(new
ScriptNode[] { z, f, dr, Palette, DimX, DimY },
42 : base(new
ScriptNode[] { z, f, dr, Palette, DimX },
74 return new string[] {
"z",
"f",
"dr",
"Palette",
"DimX",
"DimY" };
83 string ColorExpression =
null;
94 Obj =
Arguments[i++].AssociatedObjectValue;
107 throw new ScriptRuntimeException(
"Insufficient parameters in call to MandelbrotTopographyFractal().",
this);
109 Obj =
Arguments[i].AssociatedObjectValue;
112 fDef = this.Arguments[i++];
114 if (f.NrArguments != 2)
115 throw new ScriptRuntimeException(
"Lambda expression in calls to MandelbrotTopographyFractal() must be of two variables (z,c).",
this);
130 ColorExpression = this.Arguments[i].SubExpression;
135 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(1024, 16, out
int Seed,
this,
Variables);
136 ColorExpression =
"RandomLinearAnalogousHSL(1024,16," + Seed.ToString() +
")";
138 if (i < c && this.Arguments[i] is
null)
154 throw new ScriptRuntimeException(
"Parameter mismatch in call to MandelbrotTopographyFractal(r,c,dr[,Palette][,dimx[,dimy]]).",
158 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
163 return CalcMandelbrot(rc, ic, dr, f,
Variables, Palette, dimx, dimy,
this, this.FractalZoomScript,
164 new object[] { Palette, dimx, dimy, ColorExpression, fDef });
169 new object[] { Palette, dimx, dimy, ColorExpression, fDef });
173 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
175 object[] Parameters = (
object[])State;
176 int DimX = (int)Parameters[1];
177 int DimY = (int)Parameters[2];
178 string ColorExpression = (string)Parameters[3];
181 StringBuilder sb =
new StringBuilder();
183 sb.Append(
"MandelbrotTopographyFractal((");
195 if (!
string.IsNullOrEmpty(ColorExpression))
198 sb.Append(ColorExpression);
202 sb.Append(DimX.ToString());
204 sb.Append(DimY.ToString());
207 return sb.ToString();
214 SKColor[] Palette,
int Width,
int Height,
ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
216 double r0, i0, r1, i1;
219 double zr, zi, zrt, zr2, zi2;
226 int Size = Width * Height;
227 int[] ColorIndex =
new int[Size];
231 r0 = rCenter - rDelta;
232 r1 = rCenter + rDelta;
234 aspect = ((double)Width) / Height;
236 i0 = iCenter - rDelta / aspect;
237 i1 = iCenter + rDelta / aspect;
239 dr = (r1 - r0) / Width;
240 di = (i1 - i0) / Height;
242 for (y = 0, i = i0; y < Height; y++, i += di)
244 for (x = 0, r = r0; x < Width; x++, r += dr)
253 while (zr2 + zi2 < 9 && n < N)
257 zi = 2 * zr * zi + i;
265 ColorIndex[Index++] = N;
267 ColorIndex[Index++] = n;
282 ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
284 double r0, i0, r1, i1;
293 int Size = Width * Height;
294 int[] ColorIndex =
new int[Size];
302 r0 = rCenter - rDelta;
303 r1 = rCenter + rDelta;
305 aspect = ((double)Width) / Height;
307 i0 = iCenter - rDelta / aspect;
308 i1 = iCenter + rDelta / aspect;
310 dr = (r1 - r0) / Width;
311 di = (i1 - i0) / Height;
313 for (y = 0, i = i0; y < Height; y++, i += di)
315 Complex[] Row =
new Complex[Width];
316 Complex[] Row0 =
new Complex[Width];
317 int[] Offset =
new int[Width];
320 for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++)
322 Row[x] = Row0[x] =
new Complex(r, i);
330 while (n < N && c > 0)
336 Row = Obj.AssociatedObjectValue as Complex[];
341 "and return complex vectors of equal length. Type returned: " +
342 Obj.GetType().FullName, Node);
344 else if (Row.Length != c)
347 "and return complex vectors of equal length. Length returned: " +
348 Row.Length.ToString() +
". Expected: " + c.ToString(), Node);
351 for (x = x2 = 0; x < c; x++)
380 Array.Resize(ref Row, x2);
381 Array.Resize(ref Row0, x2);
382 Array.Resize(ref Offset, x2);
389 for (x = 0; x < c; x++)
Script runtime exception.
Class managing a script expression.
static IElement Encapsulate(object Value)
Encapsulates an object.
static double ToDouble(object Object)
Converts an object to a double value.
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Calculates a Mandelbrot Topography Fractal Image
override string FunctionName
TODO
static FractalGraph CalcMandelbrot(double rCenter, double iCenter, double rDelta, ILambdaExpression f, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
MandelbrotTopographyFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
MandelbrotTopographyFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
MandelbrotTopographyFractal(ScriptNode z, ScriptNode f, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
override string[] DefaultArgumentNames
TODO
static FractalGraph CalcMandelbrot(Variables Variables, double rCenter, double iCenter, double rDelta, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
MandelbrotTopographyFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
Defines a clickable fractal graph in the complex plane.
static PixelInformation ToPixels(double[] ColorIndex, int Width, int Height, SKColor[] Palette)
TODO
static SKColor[] ToPalette(ObjectVector Vector)
TODO
static double[] FindBoundaries(double[] ColorIndex, int Width, int Height)
TODO
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
string SubExpression
Sub-expression defining the node.
Expression Expression
Expression of which the node is a part.
int Start
Start position in script expression.
void CopyTo(Variables Variables)
Copies available variables to another variable collection.
Basic interface for all types of elements.
Base interface for lambda expressions.
IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the lambda expression.
delegate string FractalZoomScript(double r, double i, double Size, object State)
Generates new script when zoomed.
ArgumentType
Type of parameter used in a function definition or a lambda definition.