Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HalleySmoothFractal.cs
1using System;
2using System.Numerics;
3using System.Text;
4using System.Threading.Tasks;
5using SkiaSharp;
12
14{
43 {
48 ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
49 : base(new ScriptNode[] { z, dr, R, Coefficients, Palette, DimX, DimY },
50 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
51 ArgumentType.Normal, ArgumentType.Vector, ArgumentType.Scalar, ArgumentType.Scalar}, Start, Length, Expression)
52 {
53 }
54
59 ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
60 : base(new ScriptNode[] { z, dr, R, Coefficients, Palette, DimX },
61 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
63 {
64 }
65
70 ScriptNode Palette, int Start, int Length, Expression Expression)
71 : base(new ScriptNode[] { z, dr, R, Coefficients, Palette },
72 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
74 {
75 }
76
82 : base(new ScriptNode[] { z, dr, R, Coefficients },
83 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar,
85 {
86 }
87
92 : base(new ScriptNode[] { z, dr, R },
93 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar }, Start, Length, Expression)
94 {
95 }
96
101 : base(new ScriptNode[] { z, dr },
102 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar }, Start, Length, Expression)
103 {
104 }
105
109 public override string[] DefaultArgumentNames
110 {
111 get
112 {
113 return new string[] { "z", "dr", "R", "Coefficients", "Palette", "DimX", "DimY" };
114 }
115 }
116
121 public override bool IsAsynchronous => true;
122
127 {
128 return this.EvaluateAsync(Arguments, Variables).Result;
129 }
130
134 public override async Task<IElement> EvaluateAsync(IElement[] Arguments, Variables Variables)
135 {
136 string ColorExpression = null;
137 SKColor[] Palette;
138 double[] Coefficients = null;
139 Complex[] CoefficientsZ = null;
140 ILambdaExpression f = null;
141 ScriptNode fDef = null;
142 double rc, ic;
143 double dr;
144 Complex R;
145 int dimx, dimy;
146 int c = Arguments.Length;
147 int i = 0;
148 object Obj;
149
150 Obj = Arguments[i++].AssociatedObjectValue;
151 if (Obj is Complex z)
152 {
153 rc = z.Real;
154 ic = z.Imaginary;
155 }
156 else
157 {
158 rc = Expression.ToDouble(Obj);
159 ic = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
160 }
161
162 if (i >= c)
163 throw new ScriptRuntimeException("Insufficient parameters in call to HalleySmoothFractal().", this);
164
165 dr = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
166
167 if (i < c && ((Obj = Arguments[i].AssociatedObjectValue) is double || Obj is Complex))
168 {
169 R = Expression.ToComplex(Obj);
170 i++;
171 }
172 else
173 {
174 R = Complex.One;
175
176 if (i < c && this.Arguments[i] is null)
177 i++;
178 }
179
180 if (i < c)
181 {
182 if (Arguments[i] is DoubleVector)
183 Coefficients = (double[])Arguments[i++].AssociatedObjectValue;
184 else if (Arguments[i] is ComplexVector)
185 CoefficientsZ = (Complex[])Arguments[i++].AssociatedObjectValue;
186 /*else if (Parameters[i] is RealPolynomial)
187 Coefficients = ((RealPolynomial)Arguments[i++].AssociatedObjectValue).Coefficients;
188 else if (Parameters[i] is ComplexPolynomial)
189 CoefficientsZ = ((ComplexPolynomial)Arguments[i++].AssociatedObjectValue).Coefficients;*/
190 else if (Arguments[i] is IVector)
191 {
192 IVector Vector = (IVector)Arguments[i++];
193 int j, d = Vector.Dimension;
194
195 CoefficientsZ = new Complex[d];
196 for (j = 0; j < d; j++)
197 CoefficientsZ[j] = Expression.ToComplex(Vector.GetElement(j).AssociatedObjectValue);
198 }
199 else if (Arguments[i].AssociatedObjectValue is ILambdaExpression)
200 {
202 if (f.NrArguments != 1)
203 throw new ScriptRuntimeException("Lambda expression in calls to HalleySmoothFractal() must be of one variable.", this);
204
205 fDef = this.Arguments[i++];
206 }
207 else
208 {
209 throw new ScriptRuntimeException("Parameter " + (i + 1).ToString() +
210 " in call to HalleySmoothFractal has to be a vector of numbers, containing coefficients " +
211 "of the polynomial to use. Now it was of type " + Arguments[i].GetType().FullName,
212 this);
213 }
214 }
215 else
216 throw new ScriptRuntimeException("Missing coefficients or lambda expression.", this);
217
218 if (i < c && !(this.Arguments[i] is null) && Arguments[i] is ObjectVector)
219 {
220 ColorExpression = this.Arguments[i].SubExpression;
222 }
223 else
224 {
225 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(128, 4, out int Seed, this, Variables);
226 ColorExpression = "RandomLinearAnalogousHSL(128,4," + Seed.ToString() + ")";
227
228 if (i < c && this.Arguments[i] is null)
229 i++;
230 }
231
232 if (i < c)
233 dimx = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
234 else
235 dimx = 320;
236
237 if (i < c)
238 dimy = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
239 else
240 dimy = 200;
241
242 if (i < c)
243 {
244 throw new ScriptRuntimeException("Parameter mismatch in call to HalleySmoothFractal(z,dr[,R][,Coefficients][,Palette][,dimx[,dimy]]).",
245 this);
246 }
247
248 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
249 throw new FractalImageSizeScriptException(this);
250
251 if (!(f is null))
252 {
253 return await CalcHalley(rc, ic, dr, R, f, Variables, Palette, dimx, dimy, this, this.FractalZoomScript,
254 new object[] { Palette, dimx, dimy, R, fDef, ColorExpression });
255 }
256 else if (!(CoefficientsZ is null))
257 {
258 return await CalcHalley(rc, ic, dr, R, CoefficientsZ, Palette, dimx, dimy,
259 this, Variables, this.FractalZoomScript,
260 new object[] { Palette, dimx, dimy, R, CoefficientsZ, ColorExpression });
261 }
262 else
263 {
264 return await CalcHalley(rc, ic, dr, R, Coefficients, Palette, dimx, dimy,
265 this, Variables, this.FractalZoomScript,
266 new object[] { Palette, dimx, dimy, R, Coefficients, ColorExpression });
267 }
268 }
269
270 private string FractalZoomScript(double r, double i, double Size, object State)
271 {
272 object[] Parameters = (object[])State;
273 //SKColor[] Palette = (SKColor[])Parameters[0];
274 int DimX = (int)Parameters[1];
275 int DimY = (int)Parameters[2];
276 Complex R = (Complex)Parameters[3];
277 string ColorExpression = (string)Parameters[5];
278
279 StringBuilder sb = new StringBuilder();
280
281 sb.Append("HalleySmoothFractal((");
282 sb.Append(Expression.ToString(r));
283 sb.Append(',');
284 sb.Append(Expression.ToString(i));
285 sb.Append("),");
286 sb.Append(Expression.ToString(Size / 4));
287 sb.Append(',');
288 sb.Append(Expression.ToString(R));
289 sb.Append(',');
290
291 if (Parameters[4] is ScriptNode fDef)
292 sb.Append(fDef.SubExpression);
293 else if (Parameters[4] is Complex[] CoefficientsZ)
294 sb.Append(Expression.ToString(CoefficientsZ));
295 else if (Parameters[4] is double[] Coefficients)
296 sb.Append(Expression.ToString(Coefficients));
297
298 if (!string.IsNullOrEmpty(ColorExpression))
299 {
300 sb.Append(',');
301 sb.Append(ColorExpression);
302 }
303
304 sb.Append(',');
305 sb.Append(DimX.ToString());
306 sb.Append(',');
307 sb.Append(DimY.ToString());
308 sb.Append(')');
309
310 return sb.ToString();
311 }
312
316 public static async Task<FractalGraph> CalcHalley(double rCenter, double iCenter, double rDelta, Complex R,
317 double[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables,
318 FractalZoomScript FractalZoomScript, object State)
319 {
320 double RRe = R.Real;
321 double RIm = R.Imaginary;
322 double r0, i0, r1, i1;
323 double dr, di;
324 double r, i;
325 double zr, zi, zr2, zi2, zr3, zi3, zr4, zi4, zr5, zi5, zr6, zi6;
326 double aspect;
327 double Temp;
328 int x, y;
329 int n, N;
330 int index;
331 int Degree = Coefficients.Length - 1;
332
333 N = Palette.Length;
334
335 if (Degree < 3)
336 {
337 Array.Resize(ref Coefficients, 4);
338 while (Degree < 3)
339 Coefficients[++Degree] = 0;
340 }
341
342 double[] Prim = new double[Degree];
343 for (x = 1; x <= Degree; x++)
344 Prim[x - 1] = x * Coefficients[x];
345
346 double[] Bis = new double[Degree - 1];
347 for (x = 1; x < Degree; x++)
348 Bis[x - 1] = x * Prim[x];
349
350 Array.Reverse(Bis);
351 Array.Reverse(Prim);
352 Coefficients = (double[])Coefficients.Clone();
353 Array.Reverse(Coefficients);
354
355 int size = Width * Height;
356 double[] ColorIndex = new double[size];
357 double Conv = 1e-10;
358 double Div = 1e10;
359
360 rDelta *= 0.5;
361 r0 = rCenter - rDelta;
362 r1 = rCenter + rDelta;
363
364 aspect = ((double)Width) / Height;
365
366 i0 = iCenter - rDelta / aspect;
367 i1 = iCenter + rDelta / aspect;
368
369 dr = (r1 - r0) / Width;
370 di = (i1 - i0) / Height;
371
372 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
373 {
374 for (x = 0, r = r0; x < Width; x++, r += dr)
375 {
376 zr = r;
377 zi = i;
378
379 n = 0;
380 do
381 {
382 // f:
383 zr2 = zi2 = 0;
384 foreach (double C in Coefficients)
385 {
386 Temp = zr2 * zr - zi2 * zi + C;
387 zi2 = zr2 * zi + zi2 * zr;
388 zr2 = Temp;
389 }
390
391 // f':
392 zr3 = zi3 = 0;
393 foreach (double C in Prim)
394 {
395 Temp = zr3 * zr - zi3 * zi + C;
396 zi3 = zr3 * zi + zi3 * zr;
397 zr3 = Temp;
398 }
399
400 // f":
401 zr4 = zi4 = 0;
402 foreach (double C in Bis)
403 {
404 Temp = zr4 * zr - zi4 * zi + C;
405 zi4 = zr4 * zi + zi4 * zr;
406 zr4 = Temp;
407 }
408
409 // 2*f*f'
410
411 zr5 = 2 * (zr2 * zr3 - zi2 * zi3);
412 zi5 = 2 * (zr2 * zi3 + zi2 * zr3);
413
414 // 2f'^2-f*f"
415
416 zr6 = 2 * (zr3 * zr3 - zi3 * zi3) - (zr2 * zr4 - zi2 * zi4);
417 zi6 = 4 * zr3 * zi3 - (zr2 * zi4 + zr4 * zi2);
418
419 // 2*f*f'/(2f'^2-f*f")
420
421 Temp = 1.0 / (zr6 * zr6 + zi6 * zi6);
422 zr4 = (zr5 * zr6 + zi5 * zi6) * Temp;
423 zi4 = (zi5 * zr6 - zr5 * zi6) * Temp;
424
425 // R*2*f*f'/(2f'^2-f*f")
426 Temp = zr4 * RRe - zi4 * RIm;
427 zi4 = zr4 * RIm + zi4 * RRe;
428 zr4 = Temp;
429
430 zr -= zr4;
431 zi -= zi4;
432
433 Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
434 }
435 while ((Temp > Conv) && (Temp < Div) && (n++ < N));
436
437 if (Temp < Conv && n < N)
438 ColorIndex[index++] = n;
439 else
440 ColorIndex[index++] = N;
441 }
442 }
443
444 await Variables.Preview(Node.Expression, new GraphBitmap(Variables, FractalGraph.ToPixels(ColorIndex, Width, Height, Palette)));
445
446 double[] Boundary = FractalGraph.FindBoundaries(ColorIndex, Width, Height);
447 await FractalGraph.Smooth(ColorIndex, Boundary, Width, Height, N, Palette, Node, Variables);
448
449 return new FractalGraph(Variables, FractalGraph.ToPixels(ColorIndex, Width, Height, Palette),
450 r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State);
451 }
452
456 public static async Task<FractalGraph> CalcHalley(double rCenter, double iCenter, double rDelta, Complex R,
457 Complex[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables,
458 FractalZoomScript FractalZoomScript, object State)
459 {
460 double RRe = R.Real;
461 double RIm = R.Imaginary;
462 double r0, i0, r1, i1;
463 double dr, di;
464 double r, i;
465 double zr, zi, zr2, zi2, zr3, zi3, zr4, zi4, zr5, zi5, zr6, zi6;
466 double aspect;
467 double Temp;
468 int x, y;
469 int n, N;
470 int index;
471 int Degree = Coefficients.Length - 1;
472
473 N = Palette.Length;
474
475 if (Degree < 3)
476 {
477 Array.Resize(ref Coefficients, 4);
478 while (Degree < 3)
479 Coefficients[++Degree] = Complex.Zero;
480 }
481
482 Complex[] Prim = new Complex[Degree];
483 for (x = 1; x <= Degree; x++)
484 Prim[x - 1] = x * Coefficients[x];
485
486 Complex[] Bis = new Complex[Degree - 1];
487 for (x = 1; x < Degree; x++)
488 Bis[x - 1] = x * Prim[x];
489
490 Array.Reverse(Bis);
491 Array.Reverse(Prim);
492 Coefficients = (Complex[])Coefficients.Clone();
493 Array.Reverse(Coefficients);
494
495 int j, c = Prim.Length;
496 int c2 = c - 1;
497 double[] ReC = new double[c + 1];
498 double[] ImC = new double[c + 1];
499 double[] RePrim = new double[c];
500 double[] ImPrim = new double[c];
501 double[] ReBis = new double[c2];
502 double[] ImBis = new double[c2];
503 Complex z;
504
505 for (j = 0; j < c; j++)
506 {
507 z = Coefficients[j];
508 ReC[j] = z.Real;
509 ImC[j] = z.Imaginary;
510
511 z = Prim[j];
512 RePrim[j] = z.Real;
513 ImPrim[j] = z.Imaginary;
514
515 if (j < c2)
516 {
517 z = Bis[j];
518 ReBis[j] = z.Real;
519 ImBis[j] = z.Imaginary;
520 }
521 }
522
523 z = Coefficients[j];
524 ReC[j] = z.Real;
525 ImC[j] = z.Imaginary;
526
527 int size = Width * Height;
528 double[] ColorIndex = new double[size];
529 double Conv = 1e-10;
530 double Div = 1e10;
531
532 rDelta *= 0.5;
533 r0 = rCenter - rDelta;
534 r1 = rCenter + rDelta;
535
536 aspect = ((double)Width) / Height;
537
538 i0 = iCenter - rDelta / aspect;
539 i1 = iCenter + rDelta / aspect;
540
541 dr = (r1 - r0) / Width;
542 di = (i1 - i0) / Height;
543
544 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
545 {
546 for (x = 0, r = r0; x < Width; x++, r += dr)
547 {
548 zr = r;
549 zi = i;
550
551 n = 0;
552 do
553 {
554 // f:
555 zr2 = zi2 = 0;
556 for (j = 0; j <= c; j++)
557 {
558 Temp = zr2 * zr - zi2 * zi + ReC[j];
559 zi2 = zr2 * zi + zi2 * zr + ImC[j];
560 zr2 = Temp;
561 }
562
563 // f':
564 zr3 = zi3 = 0;
565 for (j = 0; j < c; j++)
566 {
567 Temp = zr3 * zr - zi3 * zi + RePrim[j];
568 zi3 = zr3 * zi + zi3 * zr + ImPrim[j];
569 zr3 = Temp;
570 }
571
572 // f":
573 zr4 = zi4 = 0;
574 for (j = 0; j < c2; j++)
575 {
576 Temp = zr4 * zr - zi4 * zi + ReBis[j];
577 zi4 = zr4 * zi + zi4 * zr + ImBis[j];
578 zr4 = Temp;
579 }
580
581 // 2*f*f'
582
583 zr5 = 2 * (zr2 * zr3 - zi2 * zi3);
584 zi5 = 2 * (zr2 * zi3 + zi2 * zr3);
585
586 // 2f'^2-f*f"
587
588 zr6 = 2 * (zr3 * zr3 - zi3 * zi3) - (zr2 * zr4 - zi2 * zi4);
589 zi6 = 4 * zr3 * zi3 - (zr2 * zi4 + zr4 * zi2);
590
591 // R*2*f*f'/2f'^2-f*f"
592
593 Temp = 1.0 / (zr6 * zr6 + zi6 * zi6);
594 zr4 = (zr5 * zr6 + zi5 * zi6) * Temp;
595 zi4 = (zi5 * zr6 - zr5 * zi6) * Temp;
596
597 // R*2*f*f'/(2f'^2-f*f")
598 Temp = zr4 * RRe - zi4 * RIm;
599 zi4 = zr4 * RIm + zi4 * RRe;
600 zr4 = Temp;
601
602 zr -= zr4;
603 zi -= zi4;
604
605 Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
606 }
607 while ((Temp > Conv) && (Temp < Div) && (n++ < N));
608
609 if (Temp < Conv && n < N)
610 ColorIndex[index++] = n;
611 else
612 ColorIndex[index++] = N;
613 }
614 }
615
616 await Variables.Preview(Node.Expression, new GraphBitmap(Variables, FractalGraph.ToPixels(ColorIndex, Width, Height, Palette)));
617
618 double[] Boundary = FractalGraph.FindBoundaries(ColorIndex, Width, Height);
619 await FractalGraph.Smooth(ColorIndex, Boundary, Width, Height, N, Palette, Node, Variables);
620
621 return new FractalGraph(Variables, FractalGraph.ToPixels(ColorIndex, Width, Height, Palette),
622 r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State);
623 }
624
628 public static async Task<FractalGraph> CalcHalley(double rCenter, double iCenter, double rDelta, Complex R,
629 ILambdaExpression f, Variables Variables, SKColor[] Palette, int Width, int Height,
630 ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
631 {
632 double RRe = R.Real;
633 double RIm = R.Imaginary;
634 double r0, i0, r1, i1;
635 double dr, di;
636 double r, i;
637 double aspect;
638 int x, y;
639 int n, N;
640
641 N = Palette.Length;
642
643 Variables v = new Variables();
644 Variables.CopyTo(v);
645
646 string ParameterName;
647 if (!(f is IDifferentiable Differentiable) ||
648 !(Differentiable.Differentiate(ParameterName = Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim))
649 {
650 throw new ScriptRuntimeException("Lambda expression not differentiable.", Node);
651 }
652
653 if (!(fPrim is IDifferentiable Differentiable2) ||
654 !(Differentiable2.Differentiate(ParameterName, v) is ILambdaExpression fBis))
655 {
656 throw new ScriptRuntimeException("Lambda expression not twice differentiable.", Node);
657 }
658
659 int size = Width * Height;
660 double[] ColorIndex = new double[size];
661 double Conv = 1e-10;
662 double Div = 1e10;
663
664 Complex[] Row;
665 Complex[] Row2;
666 Complex[] Row3;
667 Complex[] Row4;
668 int[] Offset;
669 IElement[] P = new IElement[1];
670 int j, c, x2;
671 IElement Obj, Obj2, Obj3;
672 double Mod;
673 Complex z, z2, z3;
674 Complex R2 = R * 2;
675
676 rDelta *= 0.5;
677 r0 = rCenter - rDelta;
678 r1 = rCenter + rDelta;
679
680 aspect = ((double)Width) / Height;
681
682 i0 = iCenter - rDelta / aspect;
683 i1 = iCenter + rDelta / aspect;
684
685 dr = (r1 - r0) / Width;
686 di = (i1 - i0) / Height;
687
688 for (y = 0, i = i0; y < Height; y++, i += di)
689 {
690 Row = new Complex[Width];
691 Offset = new int[Width];
692
693 c = Width;
694 for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++)
695 {
696 Row[x] = new Complex(r, i);
697 Offset[x] = x2;
698 }
699
700 n = 0;
701 while (n < N && c > 0)
702 {
703 n++;
704 P[0] = new ComplexVector(Row);
705 Obj = f.Evaluate(P, v);
706 Obj2 = fPrim.Evaluate(P, v);
707 Obj3 = fBis.Evaluate(P, v);
708 Row2 = Obj.AssociatedObjectValue as Complex[];
709 Row3 = Obj2.AssociatedObjectValue as Complex[];
710 Row4 = Obj3.AssociatedObjectValue as Complex[];
711
712 if (Row2 is null || Row3 is null || Row4 is null)
713 {
714 throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " +
715 "and return complex vectors of equal length. Type returned: " +
716 Obj.GetType().FullName + ", " + Obj2.GetType().FullName + " and " + Obj3.GetType().FullName,
717 Node);
718 }
719 else if (Row2.Length != c || Row3.Length != c)
720 {
721 throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " +
722 "and return complex vectors of equal length. Length returned: " +
723 Row2.Length.ToString() + ", " + Row3.Length.ToString() + " and " + Row4.Length.ToString() +
724 ". Expected: " + c.ToString(), Node);
725 }
726
727 for (x = x2 = 0; x < c; x++)
728 {
729 j = Offset[x];
730 z = Row2[x];
731 z2 = Row3[x];
732 z3 = Row4[x];
733
734 z = R2 * z * z2 / (2 * z2 * z2 - z * z3);
735 Row[x] -= z;
736
737 Mod = z.Magnitude;
738
739 if (Mod > Conv && Mod < Div)
740 {
741 if (x != x2)
742 Offset[x2] = j;
743
744 x2++;
745 }
746 else
747 {
748 if (n >= N)
749 ColorIndex[j++] = N;
750 else
751 ColorIndex[j++] = n;
752 }
753 }
754
755 if (x2 < x)
756 {
757 Array.Resize(ref Row, x2);
758 Array.Resize(ref Offset, x2);
759 c = x2;
760 }
761 }
762 }
763
764 await Variables.Preview(Node.Expression, new GraphBitmap(Variables, FractalGraph.ToPixels(ColorIndex, Width, Height, Palette)));
765
766 double[] Boundary = FractalGraph.FindBoundaries(ColorIndex, Width, Height);
767 await FractalGraph.Smooth(ColorIndex, Boundary, Width, Height, N, Palette, Node, Variables);
768
769 return new FractalGraph(Variables, FractalGraph.ToPixels(ColorIndex, Width, Height, Palette),
770 r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State);
771 }
772
776 public override string FunctionName => nameof(HalleySmoothFractal);
777 }
778}
Class managing a script expression.
Definition: Expression.cs:41
static Complex ToComplex(object Object)
Converts an object to a complex value.
Definition: Expression.cs:5228
static double ToDouble(object Object)
Converts an object to a double value.
Definition: Expression.cs:5110
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition: Expression.cs:4760
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
TODO
HalleySmoothFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
HalleySmoothFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, int Start, int Length, Expression Expression)
TODO
static async Task< FractalGraph > CalcHalley(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
static async Task< FractalGraph > CalcHalley(double rCenter, double iCenter, double rDelta, Complex R, Complex[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables, FractalZoomScript FractalZoomScript, object State)
TODO
HalleySmoothFractal(ScriptNode z, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
HalleySmoothFractal(ScriptNode z, ScriptNode dr, ScriptNode R, int Start, int Length, Expression Expression)
TODO
HalleySmoothFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
static async Task< FractalGraph > CalcHalley(double rCenter, double iCenter, double rDelta, Complex R, double[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node, Variables Variables, FractalZoomScript FractalZoomScript, object State)
TODO
HalleySmoothFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
Exception thrown if an image with invalid size is requested.
Defines a clickable fractal graph in the complex plane.
Definition: FractalGraph.cs:23
static async Task Smooth(double[] ColorIndex, double[] Boundary, int Width, int Height, int N, SKColor[] Palette, ScriptNode Node, Variables Variables)
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
Handles bitmap-based graphs.
Definition: GraphBitmap.cs:13
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
override string ToString()
Definition: ScriptNode.cs:359
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
void CopyTo(Variables Variables)
Copies available variables to another variable collection.
Definition: Variables.cs:334
async Task Preview(Expression Expression, IElement Result)
Reports a preview of the final result.
Definition: Variables.cs:407
Basic interface for all types of elements.
Definition: IElement.cs:21
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:34
Basic interface for vectors.
Definition: IVector.cs:9
int Dimension
Dimension of vector.
Definition: IVector.cs:14
IElement GetElement(int Index)
Gets an element of the vector.
Base interface for lambda expressions.
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.
Definition: IFunction.cs:9