24 private const double LimitPercentChange = 0.00025;
28 private readonly
double r0, i0, r1, i1, size;
29 private readonly
object state;
30 private readonly
int width;
31 private readonly
int height;
32 private readonly
bool invertY;
67 this.invertY = InvertY;
68 this.width = Pixels.
Width;
69 this.height = Pixels.
Height;
84 double r = X * (this.r1 - this.r0) / this.width + this.r0;
88 i = this.i0 - Y * (this.i0 - this.i1) / this.height;
90 i = this.i1 - Y * (this.i1 - this.i0) / this.height;
92 if (this.fractalZoomScript is
null)
95 return this.fractalZoomScript(r, i, this.size, this.state);
104 SKColor[] Palette =
new SKColor[c];
106 for (i = 0; i < c; i++)
115 public static void Smooth(
double[] ColorIndex,
double[] Boundary,
int Width,
int Height,
int N,
133 int Size = Width * Height;
134 double[] Delta =
new double[Size];
140 int DynamicPixels = Size;
143 DateTime LastPreview = DateTime.Now;
146 for (Index = 0; Index < Size; Index++)
148 if (Boundary[Index] >= 0 || ColorIndex[Index] >= N)
152 DateTime Start = DateTime.Now;
153 TimeSpan Limit =
new TimeSpan(1, 0, 0);
155 while (100 * Sum / DynamicPixels > LimitPercentChange && Iterations < 50000 && (DateTime.Now - Start) < Limit)
159 for (y = Index = 0; y < Height; y++)
161 for (x = 0; x < Width; x++)
170 d = 2 * ColorIndex[Index];
171 if (x == 0 || x == Width - 1)
174 uxx = ColorIndex[Index - 1] - d + ColorIndex[Index + 1];
176 if (y == 0 || y == Height - 1)
179 uyy = ColorIndex[Index - Width] - d + ColorIndex[Index + Width];
181 d = 0.2 * (uxx + uyy);
187 for (Index = 0; Index < Size; Index++)
188 ColorIndex[Index] += Delta[Index];
193 if ((TP - LastPreview).TotalSeconds > 5)
202 Variables.
Status(
Node.
Expression,
"Smoothing. Change: " + (100 * Sum / DynamicPixels).
ToString(
"F3") +
"%, Limit: " + LimitPercentChange.ToString(
"F3") +
"%, Iterations: " + Iterations.ToString());
214 public static void Smooth(
double[] R,
double[] G,
double[] B,
double[] A,
215 double[] BoundaryR,
double[] BoundaryG,
double[] BoundaryB,
double[] BoundaryA,
233 int Size = Width * Height;
234 double[] DeltaR =
new double[Size];
235 double[] DeltaG =
new double[Size];
236 double[] DeltaB =
new double[Size];
237 double[] DeltaA =
new double[Size];
243 int DynamicPixels = Size;
246 DateTime LastPreview = DateTime.Now;
249 for (Index = 0; Index < Size; Index++)
251 if (BoundaryR[Index] >= 0)
255 DateTime Start = DateTime.Now;
256 TimeSpan Limit =
new TimeSpan(1, 0, 0);
258 while (100 * Sum / DynamicPixels > LimitPercentChange && Iterations < 50000 && (DateTime.Now - Start) < Limit)
262 for (y = Index = 0; y < Height; y++)
264 for (x = 0; x < Width; x++)
266 if (BoundaryR[Index] >= 0 || BoundaryG[Index] >= 0 || BoundaryB[Index] >= 0 || BoundaryA[Index] >= 0)
276 if (x == 0 || x == Width - 1)
279 uxx = R[Index - 1] - d + R[Index + 1];
281 if (y == 0 || y == Height - 1)
284 uyy = R[Index - Width] - d + R[Index + Width];
286 d = 0.2 * (uxx + uyy);
291 if (x == 0 || x == Width - 1)
294 uxx = G[Index - 1] - d + G[Index + 1];
296 if (y == 0 || y == Height - 1)
299 uyy = G[Index - Width] - d + G[Index + Width];
301 d = 0.2 * (uxx + uyy);
306 if (x == 0 || x == Width - 1)
309 uxx = B[Index - 1] - d + B[Index + 1];
311 if (y == 0 || y == Height - 1)
314 uyy = B[Index - Width] - d + B[Index + Width];
316 d = 0.2 * (uxx + uyy);
321 if (x == 0 || x == Width - 1)
324 uxx = A[Index - 1] - d + A[Index + 1];
326 if (y == 0 || y == Height - 1)
329 uyy = A[Index - Width] - d + A[Index + Width];
331 d = 0.2 * (uxx + uyy);
339 for (Index = 0; Index < Size; Index++)
341 R[Index] += DeltaR[Index];
342 G[Index] += DeltaG[Index];
343 B[Index] += DeltaB[Index];
344 A[Index] += DeltaA[Index];
350 if ((TP - LastPreview).TotalSeconds > 5)
359 Variables.
Status(
Node.
Expression,
"Smoothing. Change: " + (100 * Sum / DynamicPixels).
ToString(
"F3") +
"%, Limit: " + LimitPercentChange.ToString(
"F3") +
"%, Iterations: " + Iterations.ToString());
371 public static double[]
FindBoundaries(
double[] ColorIndex,
int Width,
int Height)
375 double[] Boundary = (
double[])ColorIndex.Clone();
385 if (d <= d2 && d > d2 - 2)
387 d2 = ColorIndex[Width];
388 if (d <= d2 && d > d2 - 2)
394 for (x = 2; x < Width; x++, Index++)
396 d = ColorIndex[Index];
398 d2 = ColorIndex[Index + 1];
399 if (d > d2 || d <= d2 - 2)
402 d2 = ColorIndex[Index - 1];
403 if (d > d2 || d <= d2 - 2)
406 d2 = ColorIndex[Index + Width];
407 if (d > d2 || d <= d2 - 2)
410 Boundary[Index] = -1;
413 d2 = ColorIndex[Index];
414 if (d <= d2 && d > d2 - 2)
416 d2 = ColorIndex[Index - 1];
417 if (d <= d2 && d > d2 - 2)
419 d2 = ColorIndex[Index + Width];
420 if (d <= d2 && d > d2 - 2)
421 Boundary[Index] = -1;
427 for (y = 2; y < Height; y++)
429 d = ColorIndex[Index];
431 d2 = ColorIndex[Index + 1];
432 if (d <= d2 && d > d2 - 2)
434 d2 = ColorIndex[Index - Width];
435 if (d <= d2 && d > d2 - 2)
437 d2 = ColorIndex[Index + Width];
438 if (d <= d2 && d > d2 - 2)
439 Boundary[Index] = -1;
445 for (x = 2; x < Width; x++, Index++)
447 d = ColorIndex[Index];
449 d2 = ColorIndex[Index + 1];
450 if (d > d2 || d <= d2 - 2)
453 d2 = ColorIndex[Index - 1];
454 if (d > d2 || d <= d2 - 2)
457 d2 = ColorIndex[Index + Width];
458 if (d > d2 || d <= d2 - 2)
461 d2 = ColorIndex[Index - Width];
462 if (d > d2 || d <= d2 - 2)
465 Boundary[Index] = -1;
468 d = ColorIndex[Index];
470 d2 = ColorIndex[Index - 1];
471 if (d <= d2 && d > d2 - 2)
473 d2 = ColorIndex[Index - Width];
474 if (d <= d2 && d > d2 - 2)
476 d2 = ColorIndex[Index + Width];
477 if (d <= d2 && d > d2 - 2)
478 Boundary[Index] = -1;
485 d = ColorIndex[Index];
487 d2 = ColorIndex[Index + 1];
488 if (d <= d2 && d > d2 - 2)
490 d2 = ColorIndex[Index - Width];
491 if (d <= d2 && d > d2 - 2)
492 Boundary[Index] = -1;
497 for (x = 2; x < Width; x++, Index++)
499 d = ColorIndex[Index];
501 d2 = ColorIndex[Index + 1];
502 if (d > d2 || d <= d2 - 2)
505 d2 = ColorIndex[Index - 1];
506 if (d > d2 || d <= d2 - 2)
509 d2 = ColorIndex[Index - Width];
510 if (d > d2 || d <= d2 - 2)
513 Boundary[Index] = -1;
516 d = ColorIndex[Index];
518 d2 = ColorIndex[Index - 1];
519 if (d <= d2 && d > d2 - 2)
521 d2 = ColorIndex[Index - Width];
522 if (d <= d2 && d > d2 - 2)
523 Boundary[Index] = -1;
536 int[] Boundary = (
int[])ColorIndex.Clone();
546 if (d <= d2 && d > d2 - 2)
548 d2 = ColorIndex[Width];
549 if (d <= d2 && d > d2 - 2)
555 for (x = 2; x < Width; x++, Index++)
557 d = ColorIndex[Index];
559 d2 = ColorIndex[Index + 1];
560 if (d > d2 || d <= d2 - 2)
563 d2 = ColorIndex[Index - 1];
564 if (d > d2 || d <= d2 - 2)
567 d2 = ColorIndex[Index + Width];
568 if (d > d2 || d <= d2 - 2)
571 Boundary[Index] = -1;
574 d2 = ColorIndex[Index];
575 if (d <= d2 && d > d2 - 2)
577 d2 = ColorIndex[Index - 1];
578 if (d <= d2 && d > d2 - 2)
580 d2 = ColorIndex[Index + Width];
581 if (d <= d2 && d > d2 - 2)
582 Boundary[Index] = -1;
588 for (y = 2; y < Height; y++)
590 d = ColorIndex[Index];
592 d2 = ColorIndex[Index + 1];
593 if (d <= d2 && d > d2 - 2)
595 d2 = ColorIndex[Index - Width];
596 if (d <= d2 && d > d2 - 2)
598 d2 = ColorIndex[Index + Width];
599 if (d <= d2 && d > d2 - 2)
600 Boundary[Index] = -1;
606 for (x = 2; x < Width; x++, Index++)
608 d = ColorIndex[Index];
610 d2 = ColorIndex[Index + 1];
611 if (d > d2 || d <= d2 - 2)
614 d2 = ColorIndex[Index - 1];
615 if (d > d2 || d <= d2 - 2)
618 d2 = ColorIndex[Index + Width];
619 if (d > d2 || d <= d2 - 2)
622 d2 = ColorIndex[Index - Width];
623 if (d > d2 || d <= d2 - 2)
626 Boundary[Index] = -1;
629 d = ColorIndex[Index];
631 d2 = ColorIndex[Index - 1];
632 if (d <= d2 && d > d2 - 2)
634 d2 = ColorIndex[Index - Width];
635 if (d <= d2 && d > d2 - 2)
637 d2 = ColorIndex[Index + Width];
638 if (d <= d2 && d > d2 - 2)
639 Boundary[Index] = -1;
646 d = ColorIndex[Index];
648 d2 = ColorIndex[Index + 1];
649 if (d <= d2 && d > d2 - 2)
651 d2 = ColorIndex[Index - Width];
652 if (d <= d2 && d > d2 - 2)
653 Boundary[Index] = -1;
658 for (x = 2; x < Width; x++, Index++)
660 d = ColorIndex[Index];
662 d2 = ColorIndex[Index + 1];
663 if (d > d2 || d <= d2 - 2)
666 d2 = ColorIndex[Index - 1];
667 if (d > d2 || d <= d2 - 2)
670 d2 = ColorIndex[Index - Width];
671 if (d > d2 || d <= d2 - 2)
674 Boundary[Index] = -1;
677 d = ColorIndex[Index];
679 d2 = ColorIndex[Index - 1];
680 if (d <= d2 && d > d2 - 2)
682 d2 = ColorIndex[Index - Width];
683 if (d <= d2 && d > d2 - 2)
693 public static (
double[],
double[],
double[],
double[])
FindBoundaries(
double[] R,
double[] G,
double[] B,
double[] A,
int Width,
int Height)
697 double[] BoundaryR = (
double[])R.Clone();
698 double[] BoundaryG = (
double[])G.Clone();
699 double[] BoundaryB = (
double[])B.Clone();
700 double[] BoundaryA = (
double[])A.Clone();
720 if (dR <= dR2 && dR > dR2 - 2 &&
721 dG <= dG2 && dG > dG2 - 2 &&
722 dB <= dB2 && dB > dB2 - 2 &&
723 dA <= dA2 && dA > dA2 - 2)
730 if (dR <= dR2 && dR > dR2 - 2 &&
731 dG <= dG2 && dG > dG2 - 2 &&
732 dB <= dB2 && dB > dB2 - 2 &&
733 dA <= dA2 && dA > dA2 - 2)
744 for (x = 2; x < Width; x++, Index++)
756 if (dR > dR2 || dR <= dR2 - 2 &&
757 dG > dG2 || dG <= dG2 - 2 &&
758 dB > dB2 || dB <= dB2 - 2 &&
759 dA > dA2 || dA <= dA2 - 2)
769 if (dR > dR2 || dR <= dR2 - 2 &&
770 dG > dG2 || dG <= dG2 - 2 &&
771 dB > dB2 || dB <= dB2 - 2 &&
772 dA > dA2 || dA <= dA2 - 2)
777 dR2 = R[Index + Width];
778 dG2 = G[Index + Width];
779 dB2 = B[Index + Width];
780 dA2 = A[Index + Width];
782 if (dR > dR2 || dR <= dR2 - 2 &&
783 dG > dG2 || dG <= dG2 - 2 &&
784 dB > dB2 || dB <= dB2 - 2 &&
785 dA > dA2 || dA <= dA2 - 2)
790 BoundaryR[Index] = -1;
791 BoundaryG[Index] = -1;
792 BoundaryB[Index] = -1;
793 BoundaryA[Index] = -1;
801 if (dR <= dR2 && dR > dR2 - 2 &&
802 dG <= dG2 && dG > dG2 - 2 &&
803 dB <= dB2 && dB > dB2 - 2 &&
804 dA <= dA2 && dA > dA2 - 2)
811 if (dR <= dR2 && dR > dR2 - 2 &&
812 dG <= dG2 && dG > dG2 - 2 &&
813 dB <= dB2 && dB > dB2 - 2 &&
814 dA <= dA2 && dA > dA2 - 2)
816 dR2 = R[Index + Width];
817 dG2 = G[Index + Width];
818 dB2 = B[Index + Width];
819 dA2 = A[Index + Width];
821 if (dR <= dR2 && dR > dR2 - 2 &&
822 dG <= dG2 && dG > dG2 - 2 &&
823 dB <= dB2 && dB > dB2 - 2 &&
824 dA <= dA2 && dA > dA2 - 2)
826 BoundaryR[Index] = -1;
827 BoundaryG[Index] = -1;
828 BoundaryB[Index] = -1;
829 BoundaryA[Index] = -1;
836 for (y = 2; y < Height; y++)
848 if (dR <= dR2 && dR > dR2 - 2 &&
849 dG <= dG2 && dG > dG2 - 2 &&
850 dB <= dB2 && dB > dB2 - 2 &&
851 dA <= dA2 && dA > dA2 - 2)
853 dR2 = R[Index - Width];
854 dG2 = G[Index - Width];
855 dB2 = B[Index - Width];
856 dA2 = A[Index - Width];
858 if (dR <= dR2 && dR > dR2 - 2 &&
859 dG <= dG2 && dG > dG2 - 2 &&
860 dB <= dB2 && dB > dB2 - 2 &&
861 dA <= dA2 && dA > dA2 - 2)
863 dR2 = R[Index + Width];
864 dG2 = G[Index + Width];
865 dB2 = B[Index + Width];
866 dA2 = A[Index + Width];
868 if (dR <= dR2 && dR > dR2 - 2 &&
869 dG <= dG2 && dG > dG2 - 2 &&
870 dB <= dB2 && dB > dB2 - 2 &&
871 dA <= dA2 && dA > dA2 - 2)
873 BoundaryR[Index] = -1;
874 BoundaryG[Index] = -1;
875 BoundaryB[Index] = -1;
876 BoundaryA[Index] = -1;
883 for (x = 2; x < Width; x++, Index++)
895 if (dR > dR2 || dR <= dR2 - 2 &&
896 dG > dG2 || dG <= dG2 - 2 &&
897 dB > dB2 || dB <= dB2 - 2 &&
898 dA > dA2 || dA <= dA2 - 2)
908 if (dR > dR2 || dR <= dR2 - 2 &&
909 dG > dG2 || dG <= dG2 - 2 &&
910 dB > dB2 || dB <= dB2 - 2 &&
911 dA > dA2 || dA <= dA2 - 2)
916 dR2 = R[Index + Width];
917 dG2 = G[Index + Width];
918 dB2 = B[Index + Width];
919 dA2 = A[Index + Width];
921 if (dR > dR2 || dR <= dR2 - 2 &&
922 dG > dG2 || dG <= dG2 - 2 &&
923 dB > dB2 || dB <= dB2 - 2 &&
924 dA > dA2 || dA <= dA2 - 2)
929 dR2 = R[Index - Width];
930 dG2 = G[Index - Width];
931 dB2 = B[Index - Width];
932 dA2 = A[Index - Width];
934 if (dR > dR2 || dR <= dR2 - 2 &&
935 dG > dG2 || dG <= dG2 - 2 &&
936 dB > dB2 || dB <= dB2 - 2 &&
937 dA > dA2 || dA <= dA2 - 2)
942 BoundaryR[Index] = -1;
943 BoundaryG[Index] = -1;
944 BoundaryB[Index] = -1;
945 BoundaryA[Index] = -1;
958 if (dR <= dR2 && dR > dR2 - 2 &&
959 dG <= dG2 && dG > dG2 - 2 &&
960 dB <= dB2 && dB > dB2 - 2 &&
961 dA <= dA2 && dA > dA2 - 2)
963 dR2 = R[Index - Width];
964 dG2 = G[Index - Width];
965 dB2 = B[Index - Width];
966 dA2 = A[Index - Width];
968 if (dR <= dR2 && dR > dR2 - 2 &&
969 dG <= dG2 && dG > dG2 - 2 &&
970 dB <= dB2 && dB > dB2 - 2 &&
971 dA <= dA2 && dA > dA2 - 2)
973 dR2 = R[Index + Width];
974 dG2 = G[Index + Width];
975 dB2 = B[Index + Width];
976 dA2 = A[Index + Width];
978 if (dR <= dR2 && dR > dR2 - 2 &&
979 dG <= dG2 && dG > dG2 - 2 &&
980 dB <= dB2 && dB > dB2 - 2 &&
981 dA <= dA2 && dA > dA2 - 2)
983 BoundaryR[Index] = -1;
984 BoundaryG[Index] = -1;
985 BoundaryB[Index] = -1;
986 BoundaryA[Index] = -1;
1004 if (dR <= dR2 && dR > dR2 - 2 &&
1005 dG <= dG2 && dG > dG2 - 2 &&
1006 dB <= dB2 && dB > dB2 - 2 &&
1007 dA <= dA2 && dA > dA2 - 2)
1009 dR2 = R[Index - Width];
1010 dG2 = G[Index - Width];
1011 dB2 = B[Index - Width];
1012 dA2 = A[Index - Width];
1014 if (dR <= dR2 && dR > dR2 - 2 &&
1015 dG <= dG2 && dG > dG2 - 2 &&
1016 dB <= dB2 && dB > dB2 - 2 &&
1017 dA <= dA2 && dA > dA2 - 2)
1019 BoundaryR[Index] = -1;
1020 BoundaryG[Index] = -1;
1021 BoundaryB[Index] = -1;
1022 BoundaryA[Index] = -1;
1028 for (x = 2; x < Width; x++, Index++)
1040 if (dR > dR2 || dR <= dR2 - 2 &&
1041 dG > dG2 || dG <= dG2 - 2 &&
1042 dB > dB2 || dB <= dB2 - 2 &&
1043 dA > dA2 || dA <= dA2 - 2)
1053 if (dR > dR2 || dR <= dR2 - 2 &&
1054 dG > dG2 || dG <= dG2 - 2 &&
1055 dB > dB2 || dB <= dB2 - 2 &&
1056 dA > dA2 || dA <= dA2 - 2)
1061 dR2 = R[Index - Width];
1062 dG2 = G[Index - Width];
1063 dB2 = B[Index - Width];
1064 dA2 = A[Index - Width];
1066 if (dR > dR2 || dR <= dR2 - 2 &&
1067 dG > dG2 || dG <= dG2 - 2 &&
1068 dB > dB2 || dB <= dB2 - 2 &&
1069 dA > dA2 || dA <= dA2 - 2)
1074 BoundaryR[Index] = -1;
1075 BoundaryG[Index] = -1;
1076 BoundaryB[Index] = -1;
1077 BoundaryA[Index] = -1;
1090 if (dR <= dR2 && dR > dR2 - 2 &&
1091 dG <= dG2 && dG > dG2 - 2 &&
1092 dB <= dB2 && dB > dB2 - 2 &&
1093 dA <= dA2 && dA > dA2 - 2)
1095 dR2 = R[Index - Width];
1096 dG2 = G[Index - Width];
1097 dB2 = B[Index - Width];
1098 dA2 = A[Index - Width];
1100 if (dR <= dR2 && dR > dR2 - 2 &&
1101 dG <= dG2 && dG > dG2 - 2 &&
1102 dB <= dB2 && dB > dB2 - 2 &&
1103 dA <= dA2 && dA > dA2 - 2)
1105 BoundaryR[Index] = -1;
1106 BoundaryG[Index] = -1;
1107 BoundaryB[Index] = -1;
1108 BoundaryA[Index] = -1;
1112 return (BoundaryR, BoundaryG, BoundaryB, BoundaryA);
1120 int N = Palette.Length;
1121 int Size = Width * Height;
1122 int Size4 = Size * 4;
1123 byte[] rgb =
new byte[Size4];
1136 greens =
new byte[N];
1137 blues =
new byte[N];
1139 for (x = 0; x < N; x++)
1143 greens[x] = cl.Green;
1147 for (Index = Index2 = 0; Index < Size; Index++)
1149 d = ColorIndex[Index];
1152 if (ci < 0 || ci >= N)
1157 rgb[Index2++] = 255;
1159 else if (ci == N - 1)
1161 rgb[Index2++] = blues[ci];
1162 rgb[Index2++] = greens[ci];
1163 rgb[Index2++] = reds[ci];
1164 rgb[Index2++] = 255;
1170 Component = (int)(blues[ci + 1] * d + blues[ci] * (1 - d) + 0.5);
1171 if (Component > 255)
1172 rgb[Index2++] = 255;
1174 rgb[Index2++] = (byte)Component;
1176 Component = (int)(greens[ci + 1] * d + greens[ci] * (1 - d) + 0.5);
1177 if (Component > 255)
1178 rgb[Index2++] = 255;
1180 rgb[Index2++] = (byte)Component;
1182 Component = (int)(reds[ci + 1] * d + reds[ci] * (1 - d) + 0.5);
1183 if (Component > 255)
1184 rgb[Index2++] = 255;
1186 rgb[Index2++] = (byte)Component;
1188 rgb[Index2++] = 255;
1200 int N = Palette.Length;
1201 byte[] reds =
new byte[N];
1202 byte[] greens =
new byte[N];
1203 byte[] blues =
new byte[N];
1207 for (x = 0; x < N; x++)
1211 greens[x] = cl.Green;
1215 int Size = Width * Height;
1216 int Size4 = Size * 4;
1217 byte[] rgb =
new byte[Size4];
1221 for (Index = Index2 = 0; Index < Size; Index++)
1223 d = ColorIndex[Index];
1225 if (d < 0 || d >= N)
1230 rgb[Index2++] = 255;
1234 rgb[Index2++] = blues[d];
1235 rgb[Index2++] = greens[d];
1236 rgb[Index2++] = reds[d];
1237 rgb[Index2++] = 255;
1249 int Size = Width * Height;
1250 int Size4 = Size * 4;
1251 byte[] rgb =
new byte[Size4];
1256 for (Index = Index2 = 0; Index < Size; Index++)
1258 ci = (int)(B[Index] + 0.5);
1259 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1261 ci = (int)(G[Index] + 0.5);
1262 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1264 ci = (int)(R[Index] + 0.5);
1265 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1267 ci = (int)(A[Index] + 0.5);
1268 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1277 public static void Diff(
double[] ColorIndex,
int Width,
int Height, out
double[] dx, out
double[] dy)
1279 int Size = Width * Height;
1280 int Widthm1 = Width - 1;
1281 int Heightm1 = Height - 1;
1284 dx =
new double[Size];
1285 dy =
new double[Size];
1287 dx[0] = ColorIndex[1] - ColorIndex[0];
1288 dy[0] = ColorIndex[Height] - ColorIndex[0];
1290 for (i = x = 1; x < Widthm1; x++, i++)
1292 dx[i] = (ColorIndex[i + 1] - ColorIndex[i - 1]) * 0.5;
1293 dy[i] = ColorIndex[i + Width] - ColorIndex[i];
1296 dx[i] = ColorIndex[i] - ColorIndex[i - 1];
1297 dy[i] = ColorIndex[i + Width] - ColorIndex[i];
1300 for (y = 1; y < Heightm1; y++)
1302 dx[i] = ColorIndex[i + 1] - ColorIndex[i];
1303 dy[i] = (ColorIndex[i + Width] - ColorIndex[i - Width]) * 0.5;
1306 for (x = 1; x < Widthm1; x++, i++)
1308 dx[i] = (ColorIndex[i + 1] - ColorIndex[i - 1]) * 0.5;
1309 dy[i] = (ColorIndex[i + Width] - ColorIndex[i - Width]) * 0.5;
1312 dx[i] = ColorIndex[i] - ColorIndex[i - 1];
1313 dy[i] = (ColorIndex[i + Width] - ColorIndex[i - Width]) * 0.5;
1317 dx[i] = ColorIndex[i + 1] - ColorIndex[i];
1318 dy[i] = ColorIndex[i] - ColorIndex[i - Width];
1321 for (x = 1; x < Widthm1; x++, i++)
1323 dx[i] = (ColorIndex[i + 1] - ColorIndex[i - 1]) * 0.5;
1324 dy[i] = ColorIndex[i] - ColorIndex[i - Width];
1327 dx[i] = ColorIndex[i] - ColorIndex[i - 1];
1328 dy[i] = ColorIndex[i] - ColorIndex[i - Width];
1334 public static void Abs(
double[] ColorIndex,
int Width,
int Height,
double[] dx,
double[] dy)
1336 int i, c = Width * Height;
1339 for (i = 0; i < c; i++)
1344 ColorIndex[i] = Math.Sqrt(x * x + y * y);
1351 public static void Angle(
double[] ColorIndex,
int Width,
int Height,
int N,
double[] dx,
double[] dy)
1353 int i, c = Width * Height;
1354 double x, y,
Scale = N / (2.0 * Math.PI);
1356 for (i = 0; i < c; i++)
1361 if (x == 0 && y == 0)
1364 ColorIndex[i] = (Math.Atan2(y, x) + Math.PI) *
Scale;
Class managing a script expression.
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Defines a clickable fractal graph in the complex plane.
override string GetBitmapClickScript(double X, double Y, object[] States)
Graph.GetBitmapClickScript
static void Abs(double[] ColorIndex, int Width, int Height, double[] dx, double[] dy)
TODO
static PixelInformation ToPixels(int[] ColorIndex, int Width, int Height, SKColor[] Palette)
TODO
static int[] FindBoundaries(int[] ColorIndex, int Width, int Height)
TODO
static void Smooth(double[] R, double[] G, double[] B, double[] A, double[] BoundaryR, double[] BoundaryG, double[] BoundaryB, double[] BoundaryA, int Width, int Height, ScriptNode Node, Variables Variables)
TODO
FractalGraph(Variables Variables)
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 PixelInformation ToPixels(double[] R, double[] G, double[] B, double[] A, int Width, int Height)
TODO
ScriptNode Node
Node generating the graph.
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
FractalGraph(Variables Variables, PixelInformation Pixels, double r0, double i0, double r1, double i1, double Size, bool InvertY, ScriptNode Node, FractalZoomScript FractalZoomScript, object State)
Defines a clickable fractal graph in the complex plane.
Handles bitmap-based graphs.
static SKPoint[] Scale(IVector VectorX, IVector VectorY, IElement MinX, IElement MaxX, IElement MinY, IElement MaxY, double OffsetX, double OffsetY, double Width, double Height, Dictionary< string, double > XLabelPositions, Dictionary< string, double > YLabelPositions)
Scales two vectors of equal size to points in a rectangular area.
static SKColor ToColor(object Object)
Converts an object to a color.
Base class for all nodes in a parsed script tree.
Expression Expression
Expression of which the node is a part.
override int Dimension
Dimension of vector.
override IElement GetElement(int Index)
Gets an element of the vector.
TextWriter ConsoleOut
Console out interface. Can be used by functions and script to output data to the console.
void Preview(Expression Expression, IElement Result)
Reports a preview of the final result.
bool HandlesPreview
If previews are desired.
void Status(Expression Expression, string Result)
Reports current status of execution.
delegate string FractalZoomScript(double r, double i, double Size, object State)
Generates new script when zoomed.