42 : base(new
ScriptNode[] { z, c, dr, Palette, DimX, DimY },
53 : base(new
ScriptNode[] { z, c, dr, Palette, DimX },
85 return new string[] {
"z",
"c",
"dr",
"Palette",
"DimX",
"DimY" };
94 string ColorExpression =
null;
108 Obj =
Arguments[i++].AssociatedObjectValue;
109 if (Obj is Complex z)
124 Obj =
Arguments[i++].AssociatedObjectValue;
128 throw new ScriptRuntimeException(
"Lambda expression in calls to JuliaTopographyFractal() must be of one variable.",
this);
132 fDef = this.Arguments[i - 1];
134 else if (Obj is Complex z2)
155 ColorExpression = this.Arguments[i].SubExpression;
160 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(1024, 16, out
int Seed,
this,
Variables);
161 ColorExpression =
"RandomLinearAnalogousHSL(1024,16," + Seed.ToString() +
")";
163 if (i < c && this.Arguments[i] is
null)
179 throw new ScriptRuntimeException(
"Parameter mismatch in call to JuliaTopographyFractal(z,c|f,dr[,Palette][,dimx[,dimy]]).",
183 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
189 this.FractalZoomScript,
new object[] { Palette, dimx, dimy, r0, i0, ColorExpression, fDef });
193 return CalcJulia(
Variables, rc, ic, r0, i0, dr, Palette, dimx, dimy,
this,
194 this.FractalZoomScript,
new object[] { Palette, dimx, dimy, r0, i0, ColorExpression, fDef });
198 private string FractalZoomScript(
double r,
double i,
double Size,
object State)
200 object[] Parameters = (
object[])State;
201 int DimX = (int)Parameters[1];
202 int DimY = (int)Parameters[2];
203 double r0 = (double)Parameters[3];
204 double i0 = (double)Parameters[4];
205 string ColorExpression = (string)Parameters[5];
208 StringBuilder sb =
new StringBuilder();
210 sb.Append(
"JuliaTopographyFractal((");
230 if (!
string.IsNullOrEmpty(ColorExpression))
233 sb.Append(ColorExpression);
237 sb.Append(DimX.ToString());
239 sb.Append(DimY.ToString());
242 return sb.ToString();
249 SKColor[] Palette,
int Width,
int Height,
ScriptNode Node, FractalZoomScript FractalZoomScript,
object State)
251 double r0, i0, r1, i1;
254 double zr, zi, zrt, zr2, zi2;
263 r0 = rCenter - rDelta;
264 r1 = rCenter + rDelta;
266 aspect = ((double)Width) / Height;
268 i0 = iCenter - rDelta / aspect;
269 i1 = iCenter + rDelta / aspect;
271 dr = (r1 - r0) / Width;
272 di = (i1 - i0) / Height;
274 int Size = Width * Height;
275 int[] ColorIndex =
new int[Size];
277 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
279 for (x = 0, r = r0; x < Width; x++, r += dr)
288 while (zr2 + zi2 < 9 && n < N)
291 zrt = zr2 - zi2 + R0;
292 zi = 2 * zr * zi + I0;
300 ColorIndex[index++]=N;
302 ColorIndex[index++]=n;
317 FractalZoomScript FractalZoomScript,
object State)
319 double r0, i0, r1, i1;
329 r0 = rCenter - rDelta;
330 r1 = rCenter + rDelta;
332 aspect = ((double)Width) / Height;
334 i0 = iCenter - rDelta / aspect;
335 i1 = iCenter + rDelta / aspect;
337 dr = (r1 - r0) / Width;
338 di = (i1 - i0) / Height;
340 int Size = Width * Height;
341 int[] ColorIndex =
new int[Size];
348 for (y = 0, i = i0; y < Height; y++, i += di)
350 Complex[] Row =
new Complex[Width];
351 int[] Offset =
new int[Width];
354 for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++)
356 Row[x] =
new Complex(r, i);
364 while (n < N && c > 0)
369 Row = Obj.AssociatedObjectValue as Complex[];
373 else if (Row.Length != c)
376 for (x = x2 = 0; x < c; x++)
399 Array.Resize(ref Row, x2);
400 Array.Resize(ref Offset, x2);
407 for (x = 0; x < c; x++)
417 return new FractalGraph(
Variables,
FractalGraph.
ToPixels(Boundary, Width, Height, Palette), r0, i0, r1, i1, rDelta * 2,
Script runtime exception.
Class managing a script expression.
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 Julia set Fractal Image
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
static FractalGraph CalcJulia(Variables Variables, double rCenter, double iCenter, double R0, double I0, double rDelta, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
override string[] DefaultArgumentNames
TODO
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
JuliaTopographyFractal(ScriptNode z, ScriptNode c, ScriptNode dr, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
static FractalGraph CalcJulia(double rCenter, double iCenter, ILambdaExpression f, double rDelta, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
override string FunctionName
TODO
Exception thrown if an image with invalid size is requested.
Exception thrown if a lambda expression with invalid type is encountered.
Exception thrown if a lambda expression with invalid type is encountered.
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.
int NrArguments
Number of arguments.
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.