Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HalleyFractal.cs
1using System;
2using System.Numerics;
3using System.Text;
4using SkiaSharp;
10
12{
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 {
122 string ColorExpression = null;
123 SKColor[] Palette;
124 double[] Coefficients = null;
125 Complex[] CoefficientsZ = null;
126 ILambdaExpression f = null;
127 ScriptNode fDef = null;
128 double rc, ic;
129 double dr;
130 Complex R;
131 int dimx, dimy;
132 int c = Arguments.Length;
133 int i = 0;
134 object Obj;
135
136 Obj = Arguments[i++].AssociatedObjectValue;
137 if (Obj is Complex z)
138 {
139 rc = z.Real;
140 ic = z.Imaginary;
141 }
142 else
143 {
144 rc = Expression.ToDouble(Obj);
145 ic = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
146 }
147
148 if (i >= c)
149 throw new ScriptRuntimeException("Insufficient parameters in call to HalleyFractal().", this);
150
151 dr = Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
152
153 if (i < c && ((Obj = Arguments[i].AssociatedObjectValue) is double || Obj is Complex))
154 {
155 R = Expression.ToComplex(Obj);
156 i++;
157 }
158 else
159 {
160 R = Complex.One;
161
162 if (i < c && this.Arguments[i] is null)
163 i++;
164 }
165
166 if (i < c)
167 {
168 if (Arguments[i] is DoubleVector)
169 Coefficients = (double[])Arguments[i++].AssociatedObjectValue;
170 else if (Arguments[i] is ComplexVector)
171 CoefficientsZ = (Complex[])Arguments[i++].AssociatedObjectValue;
172 /*else if (Parameters[i] is RealPolynomial)
173 Coefficients = ((RealPolynomial)Arguments[i++].AssociatedObjectValue).Coefficients;
174 else if (Parameters[i] is ComplexPolynomial)
175 CoefficientsZ = ((ComplexPolynomial)Arguments[i++].AssociatedObjectValue).Coefficients;*/
176 else if (Arguments[i] is IVector)
177 {
178 IVector Vector = (IVector)Arguments[i++];
179 int j, d = Vector.Dimension;
180
181 CoefficientsZ = new Complex[d];
182 for (j = 0; j < d; j++)
183 CoefficientsZ[j] = Expression.ToComplex(Vector.GetElement(j).AssociatedObjectValue);
184 }
185 else if (Arguments[i].AssociatedObjectValue is ILambdaExpression)
186 {
188 if (f.NrArguments != 1)
189 throw new ScriptRuntimeException("Lambda expression in calls to HalleyFractal() must be of one variable.", this);
190
191 fDef = this.Arguments[i++];
192 }
193 else
194 {
195 throw new ScriptRuntimeException("Parameter " + (i + 1).ToString() +
196 " in call to HalleyFractal has to be a vector of numbers, containing coefficients " +
197 "of the polynomial to use. Now it was of type " + Arguments[i].GetType().FullName,
198 this);
199 }
200 }
201 else
202 throw new ScriptRuntimeException("Missing coefficients or lambda expression.", this);
203
204 if (i < c && !(this.Arguments[i] is null) && Arguments[i] is ObjectVector)
205 {
206 ColorExpression = this.Arguments[i].SubExpression;
208 }
209 else
210 {
211 Palette = ColorModels.RandomLinearAnalogousHSL.CreatePalette(128, 4, out int Seed, this, Variables);
212 ColorExpression = "RandomLinearAnalogousHSL(128,4," + Seed.ToString() + ")";
213
214 if (i < c && this.Arguments[i] is null)
215 i++;
216 }
217
218 if (i < c)
219 dimx = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
220 else
221 dimx = 320;
222
223 if (i < c)
224 dimy = (int)Expression.ToDouble(Arguments[i++].AssociatedObjectValue);
225 else
226 dimy = 200;
227
228 if (i < c)
229 {
230 throw new ScriptRuntimeException("Parameter mismatch in call to HalleyFractal(z,dr[,R][,Coefficients][,Palette][,dimx[,dimy]]).",
231 this);
232 }
233
234 if (dimx <= 0 || dimx > 5000 || dimy <= 0 || dimy > 5000)
235 throw new ScriptRuntimeException("Image size must be within 1x1 to 5000x5000", this);
236
237 if (!(f is null))
238 {
239 return CalcHalley(Variables, rc, ic, dr, R, f, fDef, Palette, dimx, dimy,
240 this, this.FractalZoomScript,
241 new object[] { Palette, dimx, dimy, R, fDef, ColorExpression });
242 }
243 else if (!(CoefficientsZ is null))
244 {
245 return CalcHalley(Variables, rc, ic, dr, R, CoefficientsZ, Palette, dimx, dimy,
246 this, this.FractalZoomScript,
247 new object[] { Palette, dimx, dimy, R, CoefficientsZ, ColorExpression });
248 }
249 else
250 {
251 return CalcHalley(Variables, rc, ic, dr, R, Coefficients, Palette, dimx, dimy,
252 this, this.FractalZoomScript,
253 new object[] { Palette, dimx, dimy, R, Coefficients, ColorExpression });
254 }
255 }
256
257 private string FractalZoomScript(double r, double i, double Size, object State)
258 {
259 object[] Parameters = (object[])State;
260 int DimX = (int)Parameters[1];
261 int DimY = (int)Parameters[2];
262 Complex R = (Complex)Parameters[3];
263 double[] Coefficients = Parameters[4] as double[];
264 string ColorExpression = (string)Parameters[5];
265
266 StringBuilder sb = new StringBuilder();
267
268 sb.Append("HalleyFractal((");
269 sb.Append(Expression.ToString(r));
270 sb.Append(',');
271 sb.Append(Expression.ToString(i));
272 sb.Append("),");
273 sb.Append(Expression.ToString(Size / 4));
274 sb.Append(',');
275 sb.Append(Expression.ToString(R));
276 sb.Append(',');
277
278 if (Parameters[4] is ScriptNode fDef)
279 sb.Append(fDef.SubExpression);
280 else if (Parameters[4] is Complex[] CoefficientsZ)
281 sb.Append(Expression.ToString(CoefficientsZ));
282 else
283 sb.Append(Expression.ToString(Coefficients));
284
285 if (!string.IsNullOrEmpty(ColorExpression))
286 {
287 sb.Append(',');
288 sb.Append(ColorExpression);
289 }
290
291 sb.Append(',');
292 sb.Append(DimX.ToString());
293 sb.Append(',');
294 sb.Append(DimY.ToString());
295 sb.Append(')');
296
297 return sb.ToString();
298 }
299
315 public static FractalGraph CalcHalley(Variables Variables, double rCenter, double iCenter, double rDelta, Complex R,
316 double[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node,
317 FractalZoomScript FractalZoomScript, object State)
318 {
319 byte[] reds;
320 byte[] greens;
321 byte[] blues;
322 double RRe = R.Real;
323 double RIm = R.Imaginary;
324 double r0, i0, r1, i1;
325 double dr, di;
326 double r, i;
327 double zr, zi, zr2, zi2, zr3, zi3, zr4, zi4, zr5, zi5, zr6, zi6;
328 double aspect;
329 double Temp;
330 int x, y;
331 int n, N;
332 int index;
333 int Degree = Coefficients.Length - 1;
334 SKColor cl;
335
336 N = Palette.Length;
337 reds = new byte[N];
338 greens = new byte[N];
339 blues = new byte[N];
340
341 for (x = 0; x < N; x++)
342 {
343 cl = Palette[x];
344 reds[x] = cl.Red;
345 greens[x] = cl.Green;
346 blues[x] = cl.Blue;
347 }
348
349 if (Degree < 3)
350 {
351 Array.Resize(ref Coefficients, 4);
352 while (Degree < 3)
353 Coefficients[++Degree] = 0;
354 }
355
356 double[] Prim = new double[Degree];
357 for (x = 1; x <= Degree; x++)
358 Prim[x - 1] = x * Coefficients[x];
359
360 double[] Bis = new double[Degree - 1];
361 for (x = 1; x < Degree; x++)
362 Bis[x - 1] = x * Prim[x];
363
364 Array.Reverse(Bis);
365 Array.Reverse(Prim);
366 Coefficients = (double[])Coefficients.Clone();
367 Array.Reverse(Coefficients);
368
369 int size = Width * Height * 4;
370 double Conv = 1e-10;
371 double Div = 1e10;
372 byte[] rgb = new byte[size];
373
374 rDelta *= 0.5;
375 r0 = rCenter - rDelta;
376 r1 = rCenter + rDelta;
377
378 aspect = ((double)Width) / Height;
379
380 i0 = iCenter - rDelta / aspect;
381 i1 = iCenter + rDelta / aspect;
382
383 dr = (r1 - r0) / Width;
384 di = (i1 - i0) / Height;
385
386 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
387 {
388 for (x = 0, r = r0; x < Width; x++, r += dr)
389 {
390 zr = r;
391 zi = i;
392
393 n = 0;
394 do
395 {
396 // f:
397 zr2 = zi2 = 0;
398 foreach (double C in Coefficients)
399 {
400 Temp = zr2 * zr - zi2 * zi + C;
401 zi2 = zr2 * zi + zi2 * zr;
402 zr2 = Temp;
403 }
404
405 // f':
406 zr3 = zi3 = 0;
407 foreach (double C in Prim)
408 {
409 Temp = zr3 * zr - zi3 * zi + C;
410 zi3 = zr3 * zi + zi3 * zr;
411 zr3 = Temp;
412 }
413
414 // f":
415 zr4 = zi4 = 0;
416 foreach (double C in Bis)
417 {
418 Temp = zr4 * zr - zi4 * zi + C;
419 zi4 = zr4 * zi + zi4 * zr;
420 zr4 = Temp;
421 }
422
423 // 2*f*f'
424
425 zr5 = 2 * (zr2 * zr3 - zi2 * zi3);
426 zi5 = 2 * (zr2 * zi3 + zi2 * zr3);
427
428 // 2f'^2-f*f"
429
430 zr6 = 2 * (zr3 * zr3 - zi3 * zi3) - (zr2 * zr4 - zi2 * zi4);
431 zi6 = 4 * zr3 * zi3 - (zr2 * zi4 + zr4 * zi2);
432
433 // R*2*f*f'/2f'^2-f*f"
434
435 Temp = 1.0 / (zr6 * zr6 + zi6 * zi6);
436 zr4 = (zr5 * zr6 + zi5 * zi6) * Temp;
437 zi4 = (zi5 * zr6 - zr5 * zi6) * Temp;
438
439 // R*2*f*f'/(2f'^2-f*f")
440 Temp = zr4 * RRe - zi4 * RIm;
441 zi4 = zr4 * RIm + zi4 * RRe;
442 zr4 = Temp;
443
444 zr -= zr4;
445 zi -= zi4;
446
447 Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
448 }
449 while ((Temp > Conv) && (Temp < Div) && (n++ < N));
450
451 if (Temp < Conv && n < N)
452 {
453 rgb[index++] = blues[n];
454 rgb[index++] = greens[n];
455 rgb[index++] = reds[n];
456 }
457 else
458 {
459 rgb[index++] = 0;
460 rgb[index++] = 0;
461 rgb[index++] = 0;
462 }
463
464 rgb[index++] = 255;
465 }
466 }
467
468 PixelInformation Pixels = new PixelInformationRaw(SKColorType.Bgra8888, rgb, Width, Height, Width << 2);
469 return new FractalGraph(Variables, Pixels, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State);
470 }
471
475 public static FractalGraph CalcHalley(Variables Variables, double rCenter, double iCenter, double rDelta, Complex R,
476 Complex[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node,
477 FractalZoomScript FractalZoomScript, object State)
478 {
479 byte[] reds;
480 byte[] greens;
481 byte[] blues;
482 double RRe = R.Real;
483 double RIm = R.Imaginary;
484 double r0, i0, r1, i1;
485 double dr, di;
486 double r, i;
487 double zr, zi, zr2, zi2, zr3, zi3, zr4, zi4, zr5, zi5, zr6, zi6;
488 double aspect;
489 double Temp;
490 int x, y;
491 int n, N;
492 int index;
493 int Degree = Coefficients.Length - 1;
494 SKColor cl;
495
496 N = Palette.Length;
497 reds = new byte[N];
498 greens = new byte[N];
499 blues = new byte[N];
500
501 for (x = 0; x < N; x++)
502 {
503 cl = Palette[x];
504 reds[x] = cl.Red;
505 greens[x] = cl.Green;
506 blues[x] = cl.Blue;
507 }
508
509 if (Degree < 3)
510 {
511 Array.Resize(ref Coefficients, 4);
512 while (Degree < 3)
513 Coefficients[++Degree] = Complex.Zero;
514 }
515
516 Complex[] Prim = new Complex[Degree];
517 for (x = 1; x <= Degree; x++)
518 Prim[x - 1] = x * Coefficients[x];
519
520 Complex[] Bis = new Complex[Degree - 1];
521 for (x = 1; x < Degree; x++)
522 Bis[x - 1] = x * Prim[x];
523
524 Array.Reverse(Bis);
525 Array.Reverse(Prim);
526 Coefficients = (Complex[])Coefficients.Clone();
527 Array.Reverse(Coefficients);
528
529 int j, c = Prim.Length;
530 int c2 = c - 1;
531 double[] ReC = new double[c + 1];
532 double[] ImC = new double[c + 1];
533 double[] RePrim = new double[c];
534 double[] ImPrim = new double[c];
535 double[] ReBis = new double[c2];
536 double[] ImBis = new double[c2];
537 Complex z;
538
539 for (j = 0; j < c; j++)
540 {
541 z = Coefficients[j];
542 ReC[j] = z.Real;
543 ImC[j] = z.Imaginary;
544
545 z = Prim[j];
546 RePrim[j] = z.Real;
547 ImPrim[j] = z.Imaginary;
548
549 if (j < c2)
550 {
551 z = Bis[j];
552 ReBis[j] = z.Real;
553 ImBis[j] = z.Imaginary;
554 }
555 }
556
557 z = Coefficients[j];
558 ReC[j] = z.Real;
559 ImC[j] = z.Imaginary;
560
561 int size = Width * Height * 4;
562 double Conv = 1e-10;
563 double Div = 1e10;
564 byte[] rgb = new byte[size];
565
566 rDelta *= 0.5;
567 r0 = rCenter - rDelta;
568 r1 = rCenter + rDelta;
569
570 aspect = ((double)Width) / Height;
571
572 i0 = iCenter - rDelta / aspect;
573 i1 = iCenter + rDelta / aspect;
574
575 dr = (r1 - r0) / Width;
576 di = (i1 - i0) / Height;
577
578 for (y = 0, i = i0, index = 0; y < Height; y++, i += di)
579 {
580 for (x = 0, r = r0; x < Width; x++, r += dr)
581 {
582 zr = r;
583 zi = i;
584
585 n = 0;
586 do
587 {
588 // f:
589 zr2 = zi2 = 0;
590 for (j = 0; j <= c; j++)
591 {
592 Temp = zr2 * zr - zi2 * zi + ReC[j];
593 zi2 = zr2 * zi + zi2 * zr + ImC[j];
594 zr2 = Temp;
595 }
596
597 // f':
598 zr3 = zi3 = 0;
599 for (j = 0; j < c; j++)
600 {
601 Temp = zr3 * zr - zi3 * zi + RePrim[j];
602 zi3 = zr3 * zi + zi3 * zr + ImPrim[j];
603 zr3 = Temp;
604 }
605
606 // f":
607 zr4 = zi4 = 0;
608 for (j = 0; j < c2; j++)
609 {
610 Temp = zr4 * zr - zi4 * zi + ReBis[j];
611 zi4 = zr4 * zi + zi4 * zr + ImBis[j];
612 zr4 = Temp;
613 }
614
615 // 2*f*f'
616
617 zr5 = 2 * (zr2 * zr3 - zi2 * zi3);
618 zi5 = 2 * (zr2 * zi3 + zi2 * zr3);
619
620 // 2f'^2-f*f"
621
622 zr6 = 2 * (zr3 * zr3 - zi3 * zi3) - (zr2 * zr4 - zi2 * zi4);
623 zi6 = 4 * zr3 * zi3 - (zr2 * zi4 + zr4 * zi2);
624
625 // R*2*f*f'/2f'^2-f*f"
626
627 Temp = 1.0 / (zr6 * zr6 + zi6 * zi6);
628 zr4 = (zr5 * zr6 + zi5 * zi6) * Temp;
629 zi4 = (zi5 * zr6 - zr5 * zi6) * Temp;
630
631 // R*2*f*f'/(2f'^2-f*f")
632 Temp = zr4 * RRe - zi4 * RIm;
633 zi4 = zr4 * RIm + zi4 * RRe;
634 zr4 = Temp;
635
636 zr -= zr4;
637 zi -= zi4;
638
639 Temp = Math.Sqrt(zr4 * zr4 + zi4 * zi4);
640 }
641 while ((Temp > Conv) && (Temp < Div) && (n++ < N));
642
643 if (Temp < Conv && n < N)
644 {
645 rgb[index++] = blues[n];
646 rgb[index++] = greens[n];
647 rgb[index++] = reds[n];
648 }
649 else
650 {
651 rgb[index++] = 0;
652 rgb[index++] = 0;
653 rgb[index++] = 0;
654 }
655
656 rgb[index++] = 255;
657 }
658 }
659
660 PixelInformation Pixels = new PixelInformationRaw(SKColorType.Bgra8888, rgb, Width, Height, Width << 2);
661 return new FractalGraph(Variables, Pixels, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State);
662 }
663
667 public static FractalGraph CalcHalley(Variables Variables, double rCenter, double iCenter, double rDelta, Complex R,
668 ILambdaExpression f, ScriptNode _, SKColor[] Palette, int Width, int Height, ScriptNode Node,
669 FractalZoomScript FractalZoomScript, object State)
670 {
671 byte[] reds;
672 byte[] greens;
673 byte[] blues;
674 double RRe = R.Real;
675 double RIm = R.Imaginary;
676 double r0, i0, r1, i1;
677 double dr, di;
678 double r, i;
679 double aspect;
680 int x, y;
681 int n, N;
682 SKColor cl;
683
684 N = Palette.Length;
685 reds = new byte[N];
686 greens = new byte[N];
687 blues = new byte[N];
688
689 for (x = 0; x < N; x++)
690 {
691 cl = Palette[x];
692 reds[x] = cl.Red;
693 greens[x] = cl.Green;
694 blues[x] = cl.Blue;
695 }
696
697 Variables v = new Variables();
698 Variables.CopyTo(v);
699
700 string ParameterName;
701 if (!(f is IDifferentiable Differentiable) ||
702 !(Differentiable.Differentiate(ParameterName = Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim))
703 {
704 throw new ScriptRuntimeException("Lambda expression not differentiable.", Node);
705 }
706
707 if (!(fPrim is IDifferentiable Differentiable2) ||
708 !(Differentiable2.Differentiate(ParameterName, v) is ILambdaExpression fBis))
709 {
710 throw new ScriptRuntimeException("Lambda expression not twice differentiable.", Node);
711 }
712
713 int size = Width * Height * 4;
714 double Conv = 1e-10;
715 double Div = 1e10;
716 byte[] rgb = new byte[size];
717
718 Complex[] Row;
719 Complex[] Row2;
720 Complex[] Row3;
721 Complex[] Row4;
722 int[] Offset;
723 IElement[] P = new IElement[1];
724 int j, c, x2;
725 IElement Obj, Obj2, Obj3;
726 double Mod;
727 Complex z, z2, z3;
728 Complex R2 = R * 2;
729
730 rDelta *= 0.5;
731 r0 = rCenter - rDelta;
732 r1 = rCenter + rDelta;
733
734 aspect = ((double)Width) / Height;
735
736 i0 = iCenter - rDelta / aspect;
737 i1 = iCenter + rDelta / aspect;
738
739 dr = (r1 - r0) / Width;
740 di = (i1 - i0) / Height;
741
742 for (y = 0, i = i0; y < Height; y++, i += di)
743 {
744 Row = new Complex[Width];
745 Offset = new int[Width];
746
747 c = Width;
748 for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4)
749 {
750 Row[x] = new Complex(r, i);
751 Offset[x] = x2;
752 }
753
754 n = 0;
755 while (n < N && c > 0)
756 {
757 n++;
758 P[0] = new ComplexVector(Row);
759 Obj = f.Evaluate(P, v);
760 Obj2 = fPrim.Evaluate(P, v);
761 Obj3 = fBis.Evaluate(P, v);
762 Row2 = Obj.AssociatedObjectValue as Complex[];
763 Row3 = Obj2.AssociatedObjectValue as Complex[];
764 Row4 = Obj3.AssociatedObjectValue as Complex[];
765
766 if (Row2 is null || Row3 is null || Row4 is null)
767 {
768 throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " +
769 "and return complex vectors of equal length. Type returned: " +
770 Obj.GetType().FullName + ", " + Obj2.GetType().FullName + " and " + Obj3.GetType().FullName,
771 Node);
772 }
773 else if (Row2.Length != c || Row3.Length != c)
774 {
775 throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " +
776 "and return complex vectors of equal length. Length returned: " +
777 Row2.Length.ToString() + ", " + Row3.Length.ToString() + " and " + Row4.Length.ToString() +
778 ". Expected: " + c.ToString(), Node);
779 }
780
781 for (x = x2 = 0; x < c; x++)
782 {
783 j = Offset[x];
784 z = Row2[x];
785 z2 = Row3[x];
786 z3 = Row4[x];
787
788 z = R2 * z * z2 / (2 * z2 * z2 - z * z3);
789 Row[x] -= z;
790
791 Mod = z.Magnitude;
792
793 if (Mod > Conv && Mod < Div)
794 {
795 if (x != x2)
796 Offset[x2] = j;
797
798 x2++;
799 }
800 else
801 {
802 if (n >= N)
803 {
804 rgb[j++] = 0;
805 rgb[j++] = 0;
806 rgb[j++] = 0;
807 }
808 else
809 {
810 rgb[j++] = blues[n];
811 rgb[j++] = greens[n];
812 rgb[j++] = reds[n];
813 }
814
815 rgb[j++] = 255;
816 }
817 }
818
819 if (x2 < x)
820 {
821 Array.Resize(ref Row, x2);
822 Array.Resize(ref Offset, x2);
823 c = x2;
824 }
825 }
826 }
827
828 PixelInformation Pixels = new PixelInformationRaw(SKColorType.Bgra8888, rgb, Width, Height, Width << 2);
829 return new FractalGraph(Variables, Pixels, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State);
830 }
831
835 public override string FunctionName => nameof(HalleyFractal);
836 }
837}
Class managing a script expression.
Definition: Expression.cs:39
static Complex ToComplex(object Object)
Converts an object to a complex value.
Definition: Expression.cs:4942
static double ToDouble(object Object)
Converts an object to a double value.
Definition: Expression.cs:4824
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition: Expression.cs:4496
HalleyFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, ScriptNode Palette, int Start, int Length, Expression Expression)
TODO
HalleyFractal(ScriptNode z, ScriptNode dr, int Start, int Length, Expression Expression)
TODO
static FractalGraph CalcHalley(Variables Variables, double rCenter, double iCenter, double rDelta, Complex R, Complex[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
HalleyFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, ScriptNode Palette, ScriptNode DimX, int Start, int Length, Expression Expression)
TODO
HalleyFractal(ScriptNode z, ScriptNode dr, ScriptNode R, int Start, int Length, Expression Expression)
TODO
HalleyFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, ScriptNode Palette, ScriptNode DimX, ScriptNode DimY, int Start, int Length, Expression Expression)
TODO
HalleyFractal(ScriptNode z, ScriptNode dr, ScriptNode R, ScriptNode Coefficients, int Start, int Length, Expression Expression)
TODO
static FractalGraph CalcHalley(Variables Variables, double rCenter, double iCenter, double rDelta, Complex R, double[] Coefficients, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
Calculates a Halley Fractal
override IElement Evaluate(IElement[] Arguments, Variables Variables)
TODO
static FractalGraph CalcHalley(Variables Variables, double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode _, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
TODO
Defines a clickable fractal graph in the complex plane.
Definition: FractalGraph.cs:22
static SKColor[] ToPalette(ObjectVector Vector)
TODO
Contains pixel information
Contains pixel information in a raw unencoded format.
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:400
Basic interface for all types of elements.
Definition: IElement.cs:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33
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