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