32 : base(new
ScriptNode[] { z, f, dr, Palette, DimX, DimY },
43 : base(new
ScriptNode[] { z, f, dr, Palette, DimX },
75 return new string[] {
"z",
"f",
"dr",
"Palette",
"DimX",
"DimY" };
84 string ColorExpression =
null;
95 Obj =
Arguments[i++].AssociatedObjectValue;
108 throw new ScriptRuntimeException(
"Insufficient parameters in call to MandelbrotTopographyFractal().",
this);
110 Obj =
Arguments[i].AssociatedObjectValue;
113 fDef = this.Arguments[i++];
115 if (f.NrArguments != 2)
116 throw new ScriptRuntimeException(
"Lambda expression in calls to MandelbrotTopographyFractal() must be of two variables (z,c).",
this);
131 ColorExpression = this.Arguments[i].SubExpression;
136 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(1024, 16, out
int Seed,
this,
Variables);
137 ColorExpression =
"RandomLinearAnalogousHSL(1024,16," + Seed.ToString() +
")";
139 if (i < c && this.Arguments[i] is
null)
155 throw new ScriptRuntimeException(
"Parameter mismatch in call to MandelbrotSmoothGradientFractal(r,c,dr[,Palette][,dimx[,dimy]]).",
159 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
164 return CalcMandelbrot(rc, ic, dr, f,
Variables, Palette, dimx, dimy,
this, this.FractalZoomScript,
165 new object[] { Palette, dimx, dimy, ColorExpression, fDef });
170 new object[] { Palette, dimx, dimy, ColorExpression, fDef });
174 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
176 object[] Parameters = (
object[])State;
177 int DimX = (int)Parameters[1];
178 int DimY = (int)Parameters[2];
179 string ColorExpression = (string)Parameters[3];
182 StringBuilder sb =
new StringBuilder();
184 sb.Append(
"MandelbrotSmoothGradientFractal((");
196 if (!
string.IsNullOrEmpty(ColorExpression))
199 sb.Append(ColorExpression);
203 sb.Append(DimX.ToString());
205 sb.Append(DimY.ToString());
208 return sb.ToString();
216 FractalZoomScript FractalZoomScript,
object State)
218 double r0, i0, r1, i1;
221 double zr, zi, zrt, zr2, zi2;
228 int Size = Width * Height;
229 double[] ColorIndex =
new double[Size];
233 r0 = rCenter - rDelta;
234 r1 = rCenter + rDelta;
236 aspect = ((double)Width) / Height;
238 i0 = iCenter - rDelta / aspect;
239 i1 = iCenter + rDelta / aspect;
241 dr = (r1 - r0) / Width;
242 di = (i1 - i0) / Height;
244 for (y = 0, i = i0; y < Height; y++, i += di)
246 for (x = 0, r = r0; x < Width; x++, r += dr)
255 while (zr2 + zi2 < 9 && n < N)
259 zi = 2 * zr * zi + i;
267 ColorIndex[Index++] = N;
269 ColorIndex[Index++] = n;
277 FractalGraph.
Diff(ColorIndex, Width, Height, out
double[] dx, out
double[] dy);
289 ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
291 double r0, i0, r1, i1;
300 int Size = Width * Height;
301 double[] ColorIndex =
new double[Size];
309 r0 = rCenter - rDelta;
310 r1 = rCenter + rDelta;
312 aspect = ((double)Width) / Height;
314 i0 = iCenter - rDelta / aspect;
315 i1 = iCenter + rDelta / aspect;
317 dr = (r1 - r0) / Width;
318 di = (i1 - i0) / Height;
320 for (y = 0, i = i0; y < Height; y++, i += di)
322 Complex[] Row =
new Complex[Width];
323 Complex[] Row0 =
new Complex[Width];
324 int[] Offset =
new int[Width];
327 for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++)
329 Row[x] = Row0[x] =
new Complex(r, i);
337 while (n < N && c > 0)
343 Row = Obj.AssociatedObjectValue as Complex[];
348 "and return complex vectors of equal length. Type returned: " +
349 Obj.GetType().FullName, Node);
351 else if (Row.Length != c)
354 "and return complex vectors of equal length. Length returned: " +
355 Row.Length.ToString() +
". Expected: " + c.ToString(), Node);
358 for (x = x2 = 0; x < c; x++)
387 Array.Resize(ref Row, x2);
388 Array.Resize(ref Row0, x2);
389 Array.Resize(ref Offset, x2);
396 for (x = 0; x < c; x++)
409 FractalGraph.
Diff(ColorIndex, Width, Height, out
double[] dx, out
double[] dy);
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 Smooth Fractal Image, where coloring is done in accordance with the ange of t...
static FractalGraph CalcMandelbrot(double rCenter, double iCenter, double rDelta, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables, FractalZoomScript FractalZoomScript, object State)
TODO
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
override string[] DefaultArgumentNames
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
MandelbrotSmoothGradientFractal(ScriptNode z, ScriptNode f, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
override string FunctionName
TODO
Defines a clickable fractal graph in the complex plane.
static void Diff(double[] ColorIndex, int Width, int Height, out double[] dx, out double[] dy)
TODO
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
static void Smooth(double[] ColorIndex, double[] Boundary, int Width, int Height, int N, SKColor[] Palette, ScriptNode Node, Variables Variables)
TODO
static void Angle(double[] ColorIndex, int Width, int Height, int N, double[] dx, double[] dy)
TODO
Handles bitmap-based graphs.
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 Preview(Expression Expression, IElement Result)
Reports a preview of the final result.
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.