2using System.Threading.Tasks;
25 private const double LimitPercentChange = 0.00025;
29 private readonly
double r0, i0, r1, i1, size;
30 private readonly
object state;
31 private readonly
int width;
32 private readonly
int height;
33 private readonly
bool invertY;
76 this.invertY = InvertY;
77 this.width = Pixels.
Width;
78 this.height = Pixels.
Height;
93 double r = X * (this.r1 - this.r0) / this.width + this.r0;
97 i = this.i0 - Y * (this.i0 - this.i1) / this.height;
99 i = this.i1 - Y * (this.i1 - this.i0) / this.height;
101 if (this.fractalZoomScript is
null)
104 return this.fractalZoomScript(r, i, this.size, this.state);
113 SKColor[] Palette =
new SKColor[c];
115 for (i = 0; i < c; i++)
124 public static async Task
Smooth(
double[] ColorIndex,
double[] Boundary,
int Width,
int Height,
int N,
142 int Size = Width * Height;
143 double[] Delta =
new double[Size];
149 int DynamicPixels = Size;
152 DateTime LastPreview = DateTime.Now;
155 for (Index = 0; Index < Size; Index++)
157 if (Boundary[Index] >= 0 || ColorIndex[Index] >= N)
161 DateTime Start = DateTime.Now;
162 TimeSpan Limit =
new TimeSpan(1, 0, 0);
164 while (100 * Sum / DynamicPixels > LimitPercentChange && Iterations < 50000 && (DateTime.Now - Start) < Limit)
168 for (y = Index = 0; y < Height; y++)
170 for (x = 0; x < Width; x++)
179 d = 2 * ColorIndex[Index];
180 if (x == 0 || x == Width - 1)
183 uxx = ColorIndex[Index - 1] - d + ColorIndex[Index + 1];
185 if (y == 0 || y == Height - 1)
188 uyy = ColorIndex[Index - Width] - d + ColorIndex[Index + Width];
190 d = 0.2 * (uxx + uyy);
196 for (Index = 0; Index < Size; Index++)
197 ColorIndex[Index] += Delta[Index];
202 if ((TP - LastPreview).TotalSeconds > 5)
211 await
Variables.
Status(
Node.
Expression,
"Smoothing. Change: " + (100 * Sum / DynamicPixels).
ToString(
"F3") +
"%, Limit: " + LimitPercentChange.ToString(
"F3") +
"%, Iterations: " + Iterations.ToString());
223 public static async Task
Smooth(
double[] R,
double[] G,
double[] B,
double[] A,
224 double[] BoundaryR,
double[] BoundaryG,
double[] BoundaryB,
double[] BoundaryA,
242 int Size = Width * Height;
243 double[] DeltaR =
new double[Size];
244 double[] DeltaG =
new double[Size];
245 double[] DeltaB =
new double[Size];
246 double[] DeltaA =
new double[Size];
252 int DynamicPixels = Size;
255 DateTime LastPreview = DateTime.Now;
258 for (Index = 0; Index < Size; Index++)
260 if (BoundaryR[Index] >= 0)
264 DateTime Start = DateTime.Now;
265 TimeSpan Limit =
new TimeSpan(1, 0, 0);
267 while (100 * Sum / DynamicPixels > LimitPercentChange && Iterations < 50000 && (DateTime.Now - Start) < Limit)
271 for (y = Index = 0; y < Height; y++)
273 for (x = 0; x < Width; x++)
275 if (BoundaryR[Index] >= 0 || BoundaryG[Index] >= 0 || BoundaryB[Index] >= 0 || BoundaryA[Index] >= 0)
285 if (x == 0 || x == Width - 1)
288 uxx = R[Index - 1] - d + R[Index + 1];
290 if (y == 0 || y == Height - 1)
293 uyy = R[Index - Width] - d + R[Index + Width];
295 d = 0.2 * (uxx + uyy);
300 if (x == 0 || x == Width - 1)
303 uxx = G[Index - 1] - d + G[Index + 1];
305 if (y == 0 || y == Height - 1)
308 uyy = G[Index - Width] - d + G[Index + Width];
310 d = 0.2 * (uxx + uyy);
315 if (x == 0 || x == Width - 1)
318 uxx = B[Index - 1] - d + B[Index + 1];
320 if (y == 0 || y == Height - 1)
323 uyy = B[Index - Width] - d + B[Index + Width];
325 d = 0.2 * (uxx + uyy);
330 if (x == 0 || x == Width - 1)
333 uxx = A[Index - 1] - d + A[Index + 1];
335 if (y == 0 || y == Height - 1)
338 uyy = A[Index - Width] - d + A[Index + Width];
340 d = 0.2 * (uxx + uyy);
348 for (Index = 0; Index < Size; Index++)
350 R[Index] += DeltaR[Index];
351 G[Index] += DeltaG[Index];
352 B[Index] += DeltaB[Index];
353 A[Index] += DeltaA[Index];
359 if ((TP - LastPreview).TotalSeconds > 5)
368 await
Variables.
Status(
Node.
Expression,
"Smoothing. Change: " + (100 * Sum / DynamicPixels).
ToString(
"F3") +
"%, Limit: " + LimitPercentChange.ToString(
"F3") +
"%, Iterations: " + Iterations.ToString());
380 public static double[]
FindBoundaries(
double[] ColorIndex,
int Width,
int Height)
384 double[] Boundary = (
double[])ColorIndex.Clone();
394 if (d <= d2 && d > d2 - 2)
396 d2 = ColorIndex[Width];
397 if (d <= d2 && d > d2 - 2)
403 for (x = 2; x < Width; x++, Index++)
405 d = ColorIndex[Index];
407 d2 = ColorIndex[Index + 1];
408 if (d > d2 || d <= d2 - 2)
411 d2 = ColorIndex[Index - 1];
412 if (d > d2 || d <= d2 - 2)
415 d2 = ColorIndex[Index + Width];
416 if (d > d2 || d <= d2 - 2)
419 Boundary[Index] = -1;
422 d2 = ColorIndex[Index];
423 if (d <= d2 && d > d2 - 2)
425 d2 = ColorIndex[Index - 1];
426 if (d <= d2 && d > d2 - 2)
428 d2 = ColorIndex[Index + Width];
429 if (d <= d2 && d > d2 - 2)
430 Boundary[Index] = -1;
436 for (y = 2; y < Height; y++)
438 d = ColorIndex[Index];
440 d2 = ColorIndex[Index + 1];
441 if (d <= d2 && d > d2 - 2)
443 d2 = ColorIndex[Index - Width];
444 if (d <= d2 && d > d2 - 2)
446 d2 = ColorIndex[Index + Width];
447 if (d <= d2 && d > d2 - 2)
448 Boundary[Index] = -1;
454 for (x = 2; x < Width; x++, Index++)
456 d = ColorIndex[Index];
458 d2 = ColorIndex[Index + 1];
459 if (d > d2 || d <= d2 - 2)
462 d2 = ColorIndex[Index - 1];
463 if (d > d2 || d <= d2 - 2)
466 d2 = ColorIndex[Index + Width];
467 if (d > d2 || d <= d2 - 2)
470 d2 = ColorIndex[Index - Width];
471 if (d > d2 || d <= d2 - 2)
474 Boundary[Index] = -1;
477 d = ColorIndex[Index];
479 d2 = ColorIndex[Index - 1];
480 if (d <= d2 && d > d2 - 2)
482 d2 = ColorIndex[Index - Width];
483 if (d <= d2 && d > d2 - 2)
485 d2 = ColorIndex[Index + Width];
486 if (d <= d2 && d > d2 - 2)
487 Boundary[Index] = -1;
494 d = ColorIndex[Index];
496 d2 = ColorIndex[Index + 1];
497 if (d <= d2 && d > d2 - 2)
499 d2 = ColorIndex[Index - Width];
500 if (d <= d2 && d > d2 - 2)
501 Boundary[Index] = -1;
506 for (x = 2; x < Width; x++, Index++)
508 d = ColorIndex[Index];
510 d2 = ColorIndex[Index + 1];
511 if (d > d2 || d <= d2 - 2)
514 d2 = ColorIndex[Index - 1];
515 if (d > d2 || d <= d2 - 2)
518 d2 = ColorIndex[Index - Width];
519 if (d > d2 || d <= d2 - 2)
522 Boundary[Index] = -1;
525 d = ColorIndex[Index];
527 d2 = ColorIndex[Index - 1];
528 if (d <= d2 && d > d2 - 2)
530 d2 = ColorIndex[Index - Width];
531 if (d <= d2 && d > d2 - 2)
532 Boundary[Index] = -1;
545 int[] Boundary = (
int[])ColorIndex.Clone();
555 if (d <= d2 && d > d2 - 2)
557 d2 = ColorIndex[Width];
558 if (d <= d2 && d > d2 - 2)
564 for (x = 2; x < Width; x++, Index++)
566 d = ColorIndex[Index];
568 d2 = ColorIndex[Index + 1];
569 if (d > d2 || d <= d2 - 2)
572 d2 = ColorIndex[Index - 1];
573 if (d > d2 || d <= d2 - 2)
576 d2 = ColorIndex[Index + Width];
577 if (d > d2 || d <= d2 - 2)
580 Boundary[Index] = -1;
583 d2 = ColorIndex[Index];
584 if (d <= d2 && d > d2 - 2)
586 d2 = ColorIndex[Index - 1];
587 if (d <= d2 && d > d2 - 2)
589 d2 = ColorIndex[Index + Width];
590 if (d <= d2 && d > d2 - 2)
591 Boundary[Index] = -1;
597 for (y = 2; y < Height; y++)
599 d = ColorIndex[Index];
601 d2 = ColorIndex[Index + 1];
602 if (d <= d2 && d > d2 - 2)
604 d2 = ColorIndex[Index - Width];
605 if (d <= d2 && d > d2 - 2)
607 d2 = ColorIndex[Index + Width];
608 if (d <= d2 && d > d2 - 2)
609 Boundary[Index] = -1;
615 for (x = 2; x < Width; x++, Index++)
617 d = ColorIndex[Index];
619 d2 = ColorIndex[Index + 1];
620 if (d > d2 || d <= d2 - 2)
623 d2 = ColorIndex[Index - 1];
624 if (d > d2 || d <= d2 - 2)
627 d2 = ColorIndex[Index + Width];
628 if (d > d2 || d <= d2 - 2)
631 d2 = ColorIndex[Index - Width];
632 if (d > d2 || d <= d2 - 2)
635 Boundary[Index] = -1;
638 d = ColorIndex[Index];
640 d2 = ColorIndex[Index - 1];
641 if (d <= d2 && d > d2 - 2)
643 d2 = ColorIndex[Index - Width];
644 if (d <= d2 && d > d2 - 2)
646 d2 = ColorIndex[Index + Width];
647 if (d <= d2 && d > d2 - 2)
648 Boundary[Index] = -1;
655 d = ColorIndex[Index];
657 d2 = ColorIndex[Index + 1];
658 if (d <= d2 && d > d2 - 2)
660 d2 = ColorIndex[Index - Width];
661 if (d <= d2 && d > d2 - 2)
662 Boundary[Index] = -1;
667 for (x = 2; x < Width; x++, Index++)
669 d = ColorIndex[Index];
671 d2 = ColorIndex[Index + 1];
672 if (d > d2 || d <= d2 - 2)
675 d2 = ColorIndex[Index - 1];
676 if (d > d2 || d <= d2 - 2)
679 d2 = ColorIndex[Index - Width];
680 if (d > d2 || d <= d2 - 2)
683 Boundary[Index] = -1;
686 d = ColorIndex[Index];
688 d2 = ColorIndex[Index - 1];
689 if (d <= d2 && d > d2 - 2)
691 d2 = ColorIndex[Index - Width];
692 if (d <= d2 && d > d2 - 2)
702 public static (
double[],
double[],
double[],
double[])
FindBoundaries(
double[] R,
double[] G,
double[] B,
double[] A,
int Width,
int Height)
706 double[] BoundaryR = (
double[])R.Clone();
707 double[] BoundaryG = (
double[])G.Clone();
708 double[] BoundaryB = (
double[])B.Clone();
709 double[] BoundaryA = (
double[])A.Clone();
729 if (dR <= dR2 && dR > dR2 - 2 &&
730 dG <= dG2 && dG > dG2 - 2 &&
731 dB <= dB2 && dB > dB2 - 2 &&
732 dA <= dA2 && dA > dA2 - 2)
739 if (dR <= dR2 && dR > dR2 - 2 &&
740 dG <= dG2 && dG > dG2 - 2 &&
741 dB <= dB2 && dB > dB2 - 2 &&
742 dA <= dA2 && dA > dA2 - 2)
753 for (x = 2; x < Width; x++, Index++)
765 if (dR > dR2 || dR <= dR2 - 2 &&
766 dG > dG2 || dG <= dG2 - 2 &&
767 dB > dB2 || dB <= dB2 - 2 &&
768 dA > dA2 || dA <= dA2 - 2)
778 if (dR > dR2 || dR <= dR2 - 2 &&
779 dG > dG2 || dG <= dG2 - 2 &&
780 dB > dB2 || dB <= dB2 - 2 &&
781 dA > dA2 || dA <= dA2 - 2)
786 dR2 = R[Index + Width];
787 dG2 = G[Index + Width];
788 dB2 = B[Index + Width];
789 dA2 = A[Index + Width];
791 if (dR > dR2 || dR <= dR2 - 2 &&
792 dG > dG2 || dG <= dG2 - 2 &&
793 dB > dB2 || dB <= dB2 - 2 &&
794 dA > dA2 || dA <= dA2 - 2)
799 BoundaryR[Index] = -1;
800 BoundaryG[Index] = -1;
801 BoundaryB[Index] = -1;
802 BoundaryA[Index] = -1;
810 if (dR <= dR2 && dR > dR2 - 2 &&
811 dG <= dG2 && dG > dG2 - 2 &&
812 dB <= dB2 && dB > dB2 - 2 &&
813 dA <= dA2 && dA > dA2 - 2)
820 if (dR <= dR2 && dR > dR2 - 2 &&
821 dG <= dG2 && dG > dG2 - 2 &&
822 dB <= dB2 && dB > dB2 - 2 &&
823 dA <= dA2 && dA > dA2 - 2)
825 dR2 = R[Index + Width];
826 dG2 = G[Index + Width];
827 dB2 = B[Index + Width];
828 dA2 = A[Index + Width];
830 if (dR <= dR2 && dR > dR2 - 2 &&
831 dG <= dG2 && dG > dG2 - 2 &&
832 dB <= dB2 && dB > dB2 - 2 &&
833 dA <= dA2 && dA > dA2 - 2)
835 BoundaryR[Index] = -1;
836 BoundaryG[Index] = -1;
837 BoundaryB[Index] = -1;
838 BoundaryA[Index] = -1;
845 for (y = 2; y < Height; y++)
857 if (dR <= dR2 && dR > dR2 - 2 &&
858 dG <= dG2 && dG > dG2 - 2 &&
859 dB <= dB2 && dB > dB2 - 2 &&
860 dA <= dA2 && dA > dA2 - 2)
862 dR2 = R[Index - Width];
863 dG2 = G[Index - Width];
864 dB2 = B[Index - Width];
865 dA2 = A[Index - Width];
867 if (dR <= dR2 && dR > dR2 - 2 &&
868 dG <= dG2 && dG > dG2 - 2 &&
869 dB <= dB2 && dB > dB2 - 2 &&
870 dA <= dA2 && dA > dA2 - 2)
872 dR2 = R[Index + Width];
873 dG2 = G[Index + Width];
874 dB2 = B[Index + Width];
875 dA2 = A[Index + Width];
877 if (dR <= dR2 && dR > dR2 - 2 &&
878 dG <= dG2 && dG > dG2 - 2 &&
879 dB <= dB2 && dB > dB2 - 2 &&
880 dA <= dA2 && dA > dA2 - 2)
882 BoundaryR[Index] = -1;
883 BoundaryG[Index] = -1;
884 BoundaryB[Index] = -1;
885 BoundaryA[Index] = -1;
892 for (x = 2; x < Width; x++, Index++)
904 if (dR > dR2 || dR <= dR2 - 2 &&
905 dG > dG2 || dG <= dG2 - 2 &&
906 dB > dB2 || dB <= dB2 - 2 &&
907 dA > dA2 || dA <= dA2 - 2)
917 if (dR > dR2 || dR <= dR2 - 2 &&
918 dG > dG2 || dG <= dG2 - 2 &&
919 dB > dB2 || dB <= dB2 - 2 &&
920 dA > dA2 || dA <= dA2 - 2)
925 dR2 = R[Index + Width];
926 dG2 = G[Index + Width];
927 dB2 = B[Index + Width];
928 dA2 = A[Index + Width];
930 if (dR > dR2 || dR <= dR2 - 2 &&
931 dG > dG2 || dG <= dG2 - 2 &&
932 dB > dB2 || dB <= dB2 - 2 &&
933 dA > dA2 || dA <= dA2 - 2)
938 dR2 = R[Index - Width];
939 dG2 = G[Index - Width];
940 dB2 = B[Index - Width];
941 dA2 = A[Index - Width];
943 if (dR > dR2 || dR <= dR2 - 2 &&
944 dG > dG2 || dG <= dG2 - 2 &&
945 dB > dB2 || dB <= dB2 - 2 &&
946 dA > dA2 || dA <= dA2 - 2)
951 BoundaryR[Index] = -1;
952 BoundaryG[Index] = -1;
953 BoundaryB[Index] = -1;
954 BoundaryA[Index] = -1;
967 if (dR <= dR2 && dR > dR2 - 2 &&
968 dG <= dG2 && dG > dG2 - 2 &&
969 dB <= dB2 && dB > dB2 - 2 &&
970 dA <= dA2 && dA > dA2 - 2)
972 dR2 = R[Index - Width];
973 dG2 = G[Index - Width];
974 dB2 = B[Index - Width];
975 dA2 = A[Index - Width];
977 if (dR <= dR2 && dR > dR2 - 2 &&
978 dG <= dG2 && dG > dG2 - 2 &&
979 dB <= dB2 && dB > dB2 - 2 &&
980 dA <= dA2 && dA > dA2 - 2)
982 dR2 = R[Index + Width];
983 dG2 = G[Index + Width];
984 dB2 = B[Index + Width];
985 dA2 = A[Index + Width];
987 if (dR <= dR2 && dR > dR2 - 2 &&
988 dG <= dG2 && dG > dG2 - 2 &&
989 dB <= dB2 && dB > dB2 - 2 &&
990 dA <= dA2 && dA > dA2 - 2)
992 BoundaryR[Index] = -1;
993 BoundaryG[Index] = -1;
994 BoundaryB[Index] = -1;
995 BoundaryA[Index] = -1;
1013 if (dR <= dR2 && dR > dR2 - 2 &&
1014 dG <= dG2 && dG > dG2 - 2 &&
1015 dB <= dB2 && dB > dB2 - 2 &&
1016 dA <= dA2 && dA > dA2 - 2)
1018 dR2 = R[Index - Width];
1019 dG2 = G[Index - Width];
1020 dB2 = B[Index - Width];
1021 dA2 = A[Index - Width];
1023 if (dR <= dR2 && dR > dR2 - 2 &&
1024 dG <= dG2 && dG > dG2 - 2 &&
1025 dB <= dB2 && dB > dB2 - 2 &&
1026 dA <= dA2 && dA > dA2 - 2)
1028 BoundaryR[Index] = -1;
1029 BoundaryG[Index] = -1;
1030 BoundaryB[Index] = -1;
1031 BoundaryA[Index] = -1;
1037 for (x = 2; x < Width; x++, Index++)
1049 if (dR > dR2 || dR <= dR2 - 2 &&
1050 dG > dG2 || dG <= dG2 - 2 &&
1051 dB > dB2 || dB <= dB2 - 2 &&
1052 dA > dA2 || dA <= dA2 - 2)
1062 if (dR > dR2 || dR <= dR2 - 2 &&
1063 dG > dG2 || dG <= dG2 - 2 &&
1064 dB > dB2 || dB <= dB2 - 2 &&
1065 dA > dA2 || dA <= dA2 - 2)
1070 dR2 = R[Index - Width];
1071 dG2 = G[Index - Width];
1072 dB2 = B[Index - Width];
1073 dA2 = A[Index - Width];
1075 if (dR > dR2 || dR <= dR2 - 2 &&
1076 dG > dG2 || dG <= dG2 - 2 &&
1077 dB > dB2 || dB <= dB2 - 2 &&
1078 dA > dA2 || dA <= dA2 - 2)
1083 BoundaryR[Index] = -1;
1084 BoundaryG[Index] = -1;
1085 BoundaryB[Index] = -1;
1086 BoundaryA[Index] = -1;
1099 if (dR <= dR2 && dR > dR2 - 2 &&
1100 dG <= dG2 && dG > dG2 - 2 &&
1101 dB <= dB2 && dB > dB2 - 2 &&
1102 dA <= dA2 && dA > dA2 - 2)
1104 dR2 = R[Index - Width];
1105 dG2 = G[Index - Width];
1106 dB2 = B[Index - Width];
1107 dA2 = A[Index - Width];
1109 if (dR <= dR2 && dR > dR2 - 2 &&
1110 dG <= dG2 && dG > dG2 - 2 &&
1111 dB <= dB2 && dB > dB2 - 2 &&
1112 dA <= dA2 && dA > dA2 - 2)
1114 BoundaryR[Index] = -1;
1115 BoundaryG[Index] = -1;
1116 BoundaryB[Index] = -1;
1117 BoundaryA[Index] = -1;
1121 return (BoundaryR, BoundaryG, BoundaryB, BoundaryA);
1129 int N = Palette.Length;
1130 int Size = Width * Height;
1131 int Size4 = Size * 4;
1132 byte[] rgb =
new byte[Size4];
1145 greens =
new byte[N];
1146 blues =
new byte[N];
1148 for (x = 0; x < N; x++)
1152 greens[x] = cl.Green;
1156 for (Index = Index2 = 0; Index < Size; Index++)
1158 d = ColorIndex[Index];
1161 if (ci < 0 || ci >= N)
1166 rgb[Index2++] = 255;
1168 else if (ci == N - 1)
1170 rgb[Index2++] = blues[ci];
1171 rgb[Index2++] = greens[ci];
1172 rgb[Index2++] = reds[ci];
1173 rgb[Index2++] = 255;
1179 Component = (int)(blues[ci + 1] * d + blues[ci] * (1 - d) + 0.5);
1180 if (Component > 255)
1181 rgb[Index2++] = 255;
1183 rgb[Index2++] = (byte)Component;
1185 Component = (int)(greens[ci + 1] * d + greens[ci] * (1 - d) + 0.5);
1186 if (Component > 255)
1187 rgb[Index2++] = 255;
1189 rgb[Index2++] = (byte)Component;
1191 Component = (int)(reds[ci + 1] * d + reds[ci] * (1 - d) + 0.5);
1192 if (Component > 255)
1193 rgb[Index2++] = 255;
1195 rgb[Index2++] = (byte)Component;
1197 rgb[Index2++] = 255;
1209 int N = Palette.Length;
1210 byte[] reds =
new byte[N];
1211 byte[] greens =
new byte[N];
1212 byte[] blues =
new byte[N];
1216 for (x = 0; x < N; x++)
1220 greens[x] = cl.Green;
1224 int Size = Width * Height;
1225 int Size4 = Size * 4;
1226 byte[] rgb =
new byte[Size4];
1230 for (Index = Index2 = 0; Index < Size; Index++)
1232 d = ColorIndex[Index];
1234 if (d < 0 || d >= N)
1239 rgb[Index2++] = 255;
1243 rgb[Index2++] = blues[d];
1244 rgb[Index2++] = greens[d];
1245 rgb[Index2++] = reds[d];
1246 rgb[Index2++] = 255;
1258 int Size = Width * Height;
1259 int Size4 = Size * 4;
1260 byte[] rgb =
new byte[Size4];
1265 for (Index = Index2 = 0; Index < Size; Index++)
1267 ci = (int)(B[Index] + 0.5);
1268 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1270 ci = (int)(G[Index] + 0.5);
1271 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1273 ci = (int)(R[Index] + 0.5);
1274 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1276 ci = (int)(A[Index] + 0.5);
1277 rgb[Index2++] = (byte)(ci < 0 ? 0 : ci > 255 ? 255 : ci);
1286 public static void Diff(
double[] ColorIndex,
int Width,
int Height, out
double[] dx, out
double[] dy)
1288 int Size = Width * Height;
1289 int Widthm1 = Width - 1;
1290 int Heightm1 = Height - 1;
1293 dx =
new double[Size];
1294 dy =
new double[Size];
1296 dx[0] = ColorIndex[1] - ColorIndex[0];
1297 dy[0] = ColorIndex[Height] - ColorIndex[0];
1299 for (i = x = 1; x < Widthm1; x++, i++)
1301 dx[i] = (ColorIndex[i + 1] - ColorIndex[i - 1]) * 0.5;
1302 dy[i] = ColorIndex[i + Width] - ColorIndex[i];
1305 dx[i] = ColorIndex[i] - ColorIndex[i - 1];
1306 dy[i] = ColorIndex[i + Width] - ColorIndex[i];
1309 for (y = 1; y < Heightm1; y++)
1311 dx[i] = ColorIndex[i + 1] - ColorIndex[i];
1312 dy[i] = (ColorIndex[i + Width] - ColorIndex[i - Width]) * 0.5;
1315 for (x = 1; x < Widthm1; x++, i++)
1317 dx[i] = (ColorIndex[i + 1] - ColorIndex[i - 1]) * 0.5;
1318 dy[i] = (ColorIndex[i + Width] - ColorIndex[i - Width]) * 0.5;
1321 dx[i] = ColorIndex[i] - ColorIndex[i - 1];
1322 dy[i] = (ColorIndex[i + Width] - ColorIndex[i - Width]) * 0.5;
1326 dx[i] = ColorIndex[i + 1] - ColorIndex[i];
1327 dy[i] = ColorIndex[i] - ColorIndex[i - Width];
1330 for (x = 1; x < Widthm1; x++, i++)
1332 dx[i] = (ColorIndex[i + 1] - ColorIndex[i - 1]) * 0.5;
1333 dy[i] = ColorIndex[i] - ColorIndex[i - Width];
1336 dx[i] = ColorIndex[i] - ColorIndex[i - 1];
1337 dy[i] = ColorIndex[i] - ColorIndex[i - Width];
1343 public static void Abs(
double[] ColorIndex,
int Width,
int Height,
double[] dx,
double[] dy)
1345 int i, c = Width * Height;
1348 for (i = 0; i < c; i++)
1353 ColorIndex[i] = Math.Sqrt(x * x + y * y);
1360 public static void Angle(
double[] ColorIndex,
int Width,
int Height,
int N,
double[] dx,
double[] dy)
1362 int i, c = Width * Height;
1363 double x, y,
Scale = N / (2.0 * Math.PI);
1365 for (i = 0; i < c; i++)
1370 if (x == 0 && y == 0)
1373 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 async Task Smooth(double[] ColorIndex, double[] Boundary, int Width, int Height, int N, SKColor[] Palette, 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 async Task 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()
Defines a clickable fractal graph in the complex plane.
static SKColor[] ToPalette(ObjectVector Vector)
TODO
static double[] FindBoundaries(double[] ColorIndex, int Width, int Height)
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.
async Task Status(Expression Expression, string Result)
Reports current status of execution.
bool HandlesPreview
If previews are desired.
async Task Preview(Expression Expression, IElement Result)
Reports a preview of the final result.
delegate string FractalZoomScript(double r, double i, double Size, object State)
Generates new script when zoomed.