private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = this.CreateGraphics(); Obj1.Paint(g); Obj2.Paint(g); }
protected override void Write(ClientProcessor psr, NWriter wtr) { wtr.Write(Time); Position.Write(wtr); Obj1.Write(wtr); Obj2.Write(wtr); }
protected override void Write(NWriter wtr) { wtr.Write(Time); Position.Write(wtr); Obj1.Write(wtr); Obj2.Write(wtr); }
private async Task Push(DateTime Timestamp, string Message, string Function, bool CloseIfNoTabs) { try { DateTime Now = DateTime.Now; if ((Now - this.tabIdTimestamp).TotalSeconds > 2 || this.tabIds is null || this.tabIds.Length == 0) { this.tabIds = ClientEvents.GetTabIDsForLocation(this.resource, true, "SnifferId", this.snifferId); this.tabIdTimestamp = Now; } if (this.feedbackCheck && Message.StartsWith("{") && Message.EndsWith("}")) { try { object Parsed = JSON.Parse(Message); if (Parsed is IDictionary <string, object> Obj && Obj.TryGetValue("data", out object Temp) && Temp is IDictionary <string, object> Obj2 && Obj2.TryGetValue("timestamp", out object Timestamp2) && Obj2.TryGetValue("message", out object Message2) && (this.outgoing?.ContainsKey(this.ToJson(Timestamp2, Message2)) ?? true)) { return; } } catch (Exception) { // Ignore } } string Data = this.ToJson(XML.Encode(Timestamp), Message); this.outgoing?.Add(Data, true); int Tabs = await ClientEvents.PushEvent(this.tabIds, Function, Data, true, this.userVariable, this.privileges); if (CloseIfNoTabs && Tabs <= 0 && (Now - this.created).TotalSeconds >= 5) { await this.Close(); } } catch (Exception ex) { Log.Critical(ex); } }
// Affiche le nom du joueur qui doit faire effectuer son tour ainsi que ses objectifs public void Tour() { validationObj(); Obj2.Hide(); Obj3.Hide(); Obj1.Hide(); Obj4.Hide(); Obj5.Hide(); nbreobjok.Text = listeJoueur[jEnCours].nbreObjOk.ToString(); act = Action.Indefinie; MessageBox.Show("C'est à " + listeJoueur[jEnCours].nom + " de jouer."); if (listeJoueur[jEnCours].main.Count() >= 1) { Obj1.Text = listeJoueur[jEnCours].main[0].objectif; Obj1.Show(); } if (listeJoueur[jEnCours].main.Count() >= 2) { Obj2.Text = listeJoueur[jEnCours].main[1].objectif; Obj2.Show(); } if (listeJoueur[jEnCours].main.Count() >= 3) { Obj3.Text = listeJoueur[jEnCours].main[2].objectif; Obj3.Show(); } if (listeJoueur[jEnCours].main.Count() >= 4) { Obj4.Text = listeJoueur[jEnCours].main[3].objectif; Obj4.Show(); } if (listeJoueur[jEnCours].main.Count() >= 5) { Obj5.Text = listeJoueur[jEnCours].main[4].objectif; Obj5.Show(); } estomacJaune.Text = listeJoueur[jEnCours].nbreBambouJaune.ToString(); estomacRose.Text = listeJoueur[jEnCours].nbreBambouRose.ToString(); estomacVert.Text = listeJoueur[jEnCours].nbreBambouVert.ToString(); }
public void Issue199() { using (var memStream = new MemoryStream()) { SerializationContext.Default.GetSerializer <Obj1>().Pack(memStream, new Obj1 { Id = "1", Items = new List <string> { "a", "b" } }); memStream.Seek(0, SeekOrigin.Begin); var serializer2 = SerializationContext.Default.GetSerializer <Obj2>(); // this call throws Obj2 obj = serializer2.Unpack(memStream); } }
private void MouseCtrl(object sender, System.Windows.Forms.MouseEventArgs e) { //while (ClientRectangle.Contains(PointToClient(MousePosition))) mouse_x = Control.MousePosition.X - this.Location.X - 8; mouse_y = Control.MousePosition.Y - this.Location.Y - 30; Graphics g = this.CreateGraphics(); int wheel = e.Delta; Task task1 = Task.Run(() => { Obj1.DataCheck(Obj1.isInsideSmth(mouse_x, mouse_y), wheel); Obj2.DataCheck(Obj2.isInsideSmth(mouse_x, mouse_y), wheel); }); Task task2 = Task.Run(() => { Obj1.Paint_MouseHover(Obj1.isInsideSmth(mouse_x, mouse_y), g, k); Obj2.Paint_MouseHover(Obj2.isInsideSmth(mouse_x, mouse_y), g, k); Obj1.Paint(g); Obj2.Paint(g); }); task1.Wait(); task2.Wait(); Thread.Sleep(55); k = 0; }
public Obj2Wrapper(Obj2 obj) { this._obj = obj; }
public Bambouseraie(ArrayList joueurs, int nbrej) { InitializeComponent(); baseDessin = zoneJardin.CreateGraphics(); #region Initialisation du tableau contenant les parcelles nbreParcelle = zoneJardin.Height / tailleParcelle; tableauParcelle = new Parcelle[nbreParcelle, nbreParcelle]; int xParcelle = 0; int yParcelle = 0; int ligne = 0; int colonne = 0; for (xParcelle = 0; xParcelle < zoneJardin.Height; xParcelle += (tailleParcelle + 1)) { for (yParcelle = 0; yParcelle < zoneJardin.Height; yParcelle += (tailleParcelle + 1)) { tableauParcelle[ligne, colonne] = new Parcelle(ligne, colonne, xParcelle, yParcelle, tailleParcelle); ligne++; } ligne = 0; colonne++; } #endregion #region Initialisation affichage objectif Obj1.Hide(); Obj2.Hide(); Obj3.Hide(); Obj4.Hide(); Obj5.Hide(); #endregion #region Intialisation de la pioche int maxPioche = nbrej * 6 + 10; piocheP = new List <Carte>(); Random rand = new Random(); for (int i = 0; i < maxPioche; i++) { pioche.Add(new Carte(rand.Next(1, 4))); } #endregion #region Initialisation du tableau des joueurs nbrejoueur = nbrej; listeJoueur = (Joueur[])joueurs.ToArray(typeof(Joueur)); #endregion #region Définition de l'étang tableauParcelle[4, 4].etang = true; tableauParcelle[4, 4].irriguee = true; tableauParcelle[4, 4].jardinier = true; tableauParcelle[4, 4].panda = true; tableauParcelle[4, 4].choixCouleur(Color.Blue); #endregion #region Initialisation des pinceaux contour = new Pen(Color.Black); police = new Font("Arial", 20); formatTexte = new StringFormat(); formatTexte.Alignment = StringAlignment.Center; formatTexte.LineAlignment = StringAlignment.Center; #endregion #region Définition des images string dossierimg = "C:/Users/Alice/Documents/Visual Studio 2013/Projects/Takenoko/TakenokoVisuel/img/"; jardinier = new Acteur(dossierimg + "jardinier.png", tableauParcelle[4, 4].dimension.X, tableauParcelle[4, 4].dimension.Y, tableauParcelle[4, 4], tailleInformation); int xpanda = tableauParcelle[4, 4].dimension.X + tailleParcelle - tailleInformation; panda = new Acteur(dossierimg + "panda.png", xpanda, tableauParcelle[4, 4].dimension.Y, tableauParcelle[4, 4], tailleInformation); #endregion }
public static FractalGraph CalcNewton(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { byte[] reds; byte[] greens; byte[] blues; double RRe = R.Real; double RIm = R.Imaginary; double r0, i0, r1, i1; double dr, di; double r, i; double aspect; int x, y; int n, N; SKColor cl; Complex z; N = Palette.Length; reds = new byte[N]; greens = new byte[N]; blues = new byte[N]; for (x = 0; x < N; x++) { cl = Palette[x]; reds[x] = cl.Red; greens[x] = cl.Green; blues[x] = cl.Blue; } Variables v = new Variables(); Variables.CopyTo(v); if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } int size = Width * Height * 4; double Conv = 1e-10; double Div = 1e10; byte[] rgb = new byte[size]; Complex[] Row; Complex[] Row2; Complex[] Row3; int[] Offset; IElement[] P = new IElement[1]; int j, c, x2; IElement Obj, Obj2; double Mod; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; if (Row2 == null || Row3 == null) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + " and " + Obj2.GetType().FullName, Node); } else if (Row2.Length != c || Row3.Length != c) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Length returned: " + Row2.Length.ToString() + " and " + Row3.Length.ToString() + ". Expected: " + c.ToString(), Node); } for (x = x2 = 0; x < c; x++) { j = Offset[x]; z = R * Row2[x] / Row3[x]; Row[x] -= z; Mod = z.Magnitude; if (Mod > Conv && Mod < Div) { if (x != x2) { Offset[x2] = j; } x2++; } else { if (n >= N) { rgb[j++] = 0; rgb[j++] = 0; rgb[j++] = 0; } else { rgb[j++] = blues[n]; rgb[j++] = greens[n]; rgb[j++] = reds[n]; } rgb[j++] = 255; } } if (x2 < x) { Array.Resize <Complex>(ref Row, x2); Array.Resize <int>(ref Offset, x2); c = x2; } } } using (SKData Data = SKData.Create(new MemoryStream(rgb))) { SKImage Bitmap = SKImage.FromPixelData(new SKImageInfo(Width, Height, SKColorType.Bgra8888), Data, Width * 4); return(new FractalGraph(Bitmap, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State)); } }
public static FractalGraph CalcNewton(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, int N, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { double RRe = R.Real; double RIm = R.Imaginary; List <double> AttractorsR = new List <double>(); List <double> AttractorsI = new List <double>(); List <int> AttractorColors = new List <int>(); double[] AttractorsR2 = new double[0]; double[] AttractorsI2 = new double[0]; int[] AttractorsColors2 = new int[0]; double r0, i0, r1, i1; double dr, di; double r, i; double zr, zi; double aspect; int x, y, b, c, d; int NrAttractors = 0; int n; int index; Variables v = new Variables(); Variables.CopyTo(v); if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } int size = Width * Height * 4; double Conv = 1e-10; double Div = 1e10; double Conv2 = Conv * 2; byte[] rgb = new byte[size]; Complex[] Row; Complex[] Row2; Complex[] Row3; int[] Offset; IElement[] P = new IElement[1]; int j, x2; IElement Obj, Obj2; double Mod; Complex z; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0, index = 0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; if (Row2 == null || Row3 == null) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + " and " + Obj2.GetType().FullName, Node); } else if (Row2.Length != c || Row3.Length != c) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Length returned: " + Row2.Length.ToString() + " and " + Row3.Length.ToString() + ". Expected: " + c.ToString(), Node); } for (x = x2 = 0; x < c; x++) { j = Offset[x]; z = R * Row2[x] / Row3[x]; Row[x] -= z; Mod = z.Magnitude; if (Mod > Conv && Mod < Div) { if (x != x2) { Offset[x2] = j; } x2++; } else { if (n >= N) { rgb[j++] = 0; rgb[j++] = 0; rgb[j++] = 0; } else { zr = z.Real; zi = z.Imaginary; for (b = 0; b < NrAttractors; b++) { if (Math.Abs(AttractorsR2[b] - zr) < Conv2 && Math.Abs(AttractorsI2[b] - zi) < Conv2) { break; } } if (b == NrAttractors) { AttractorsR.Add(zr); AttractorsI.Add(zi); int p1 = ~((b % 6) + 1); int p2 = ((b / 6) % 7); int Red = (p1 & 1) != 0 ? 255 : 0; int Green = (p1 & 2) != 0 ? 255 : 0; int Blue = (p1 & 4) != 0 ? 255 : 0; if ((p2 & 1) != 0) { Red >>= 1; } if ((p2 & 2) != 0) { Green >>= 1; } if ((p2 & 4) != 0) { Blue >>= 1; } Blue <<= 8; Blue |= Green; Blue <<= 8; Blue |= Red; AttractorColors.Add(Blue); AttractorsR2 = AttractorsR.ToArray(); AttractorsI2 = AttractorsI.ToArray(); AttractorsColors2 = AttractorColors.ToArray(); NrAttractors++; } b = AttractorColors[b]; d = (byte)b; rgb[index++] = (byte)((d * (N - n + 1)) / N); b >>= 8; d = (byte)b; rgb[index++] = (byte)((d * (N - n + 1)) / N); b >>= 8; d = (byte)b; rgb[index++] = (byte)((d * (N - n + 1)) / N); } rgb[j++] = 255; } } if (x2 < x) { Array.Resize <Complex>(ref Row, x2); Array.Resize <int>(ref Offset, x2); c = x2; } } } using (SKData Data = SKData.Create(new MemoryStream(rgb))) { SKImage Bitmap = SKImage.FromPixelData(new SKImageInfo(Width, Height, SKColorType.Bgra8888), Data, Width * 4); return(new FractalGraph(Bitmap, r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State)); } }
public override string ToString() { return(string.Format("Obj1:{0} Obj2:{1} Status:{2}", Obj1.ToString() ?? string.Empty, Obj2.ToString() ?? string.Empty, Status) .Replace("\0", "")); }
public static FractalGraph CalcHalley(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { byte[] reds; byte[] greens; byte[] blues; double RRe = R.Real; double RIm = R.Imaginary; double r0, i0, r1, i1; double dr, di; double r, i; double aspect; int x, y; int n, N; SKColor cl; N = Palette.Length; reds = new byte[N]; greens = new byte[N]; blues = new byte[N]; for (x = 0; x < N; x++) { cl = Palette[x]; reds[x] = cl.Red; greens[x] = cl.Green; blues[x] = cl.Blue; } Variables v = new Variables(); Variables.CopyTo(v); string ParameterName; if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(ParameterName = Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } if (!(fPrim is IDifferentiable Differentiable2) || !(Differentiable2.Differentiate(ParameterName, v) is ILambdaExpression fBis)) { throw new ScriptRuntimeException("Lambda expression not twice differentiable.", Node); } int size = Width * Height * 4; double Conv = 1e-10; double Div = 1e10; byte[] rgb = new byte[size]; Complex[] Row; Complex[] Row2; Complex[] Row3; Complex[] Row4; int[] Offset; IElement[] P = new IElement[1]; int j, c, x2; IElement Obj, Obj2, Obj3; double Mod; Complex z, z2, z3; Complex R2 = R * 2; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Obj3 = fBis.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; Row4 = Obj3.AssociatedObjectValue as Complex[]; if (Row2 is null || Row3 is null || Row4 is null) { throw new ScriptRuntimeException("Lambda expression (and its first and second derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + ", " + Obj2.GetType().FullName + " and " + Obj3.GetType().FullName, Node); }
public void InicializarCofre() { Random.seed = (int)System.DateTime.Now.Ticks; do { numero1 = Random.value; } while (numero1 < 0.00 || numero1 > 0.47); numero1 *= 100; numero1 = (int)numero1; do { numero2 = Random.value; } while (numero2 < 0.00 || numero2 > 0.47); numero2 *= 100; numero2 = (int)numero2; do { numero3 = Random.value; } while (numero3 < 0.00 || numero3 > 0.47); numero3 *= 100; numero3 = (int)numero3; Debug.Log(numero1 + " " + numero2 + " " + numero3); Obj1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + numero1.ToString()); Obj1.GetComponent <ObjetoId>().id = (int)numero1; switch (PersonajeIdPorObjeto((int)numero1)) { case 1: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "princesa"); break; } case 2: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "mago"); break; } case 3: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "caballero"); break; } case 4: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "herrero"); break; } case 5: { Per1.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "vacio"); break; } } Obj2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + numero2.ToString()); Obj2.GetComponent <ObjetoId>().id = (int)numero2; switch (PersonajeIdPorObjeto((int)numero2)) { case 1: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "princesa"); break; } case 2: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "mago"); break; } case 3: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "caballero"); break; } case 4: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "herrero"); break; } case 5: { Per2.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "vacio"); break; } } Obj3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + numero3.ToString()); Obj3.GetComponent <ObjetoId>().id = (int)numero3; switch (PersonajeIdPorObjeto((int)numero3)) { case 1: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "princesa"); break; } case 2: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "mago"); break; } case 3: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "caballero"); break; } case 4: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "herrero"); break; } case 5: { Per3.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/" + "vacio"); break; } } }
public static FractalGraph CalcNewtonSmooth(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { double RRe = R.Real; double RIm = R.Imaginary; double r0, i0, r1, i1; double dr, di; double r, i; double aspect; int x, y; int n, N; N = Palette.Length; if (Width <= 2 || Height <= 2) { throw new ScriptRuntimeException("Width and Height has to be greater than 2.", Node); } Variables v = new Variables(); Variables.CopyTo(v); if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } int Size = Width * Height; double Conv = 1e-10; double Div = 1e10; double[] ColorIndex = new double[Size]; int Index = 0; Complex[] Row; Complex[] Row2; Complex[] Row3; int[] Offset; IElement[] P = new IElement[1]; int j, c, x2; IElement Obj, Obj2; double Mod; Complex z; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; if (Row2 == null || Row3 == null) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + " and " + Obj2.GetType().FullName, Node); } else if (Row2.Length != c || Row3.Length != c) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Length returned: " + Row2.Length.ToString() + " and " + Row3.Length.ToString() + ". Expected: " + c.ToString(), Node); } for (x = x2 = 0; x < c; x++) { j = Offset[x]; z = R * Row2[x] / Row3[x]; Row[x] -= z; Mod = z.Magnitude; if (Mod > Conv && Mod < Div) { if (x != x2) { Offset[x2] = j; } x2++; } else { if (n >= N) { ColorIndex[Index++] = N; } else { ColorIndex[j++] = n; } } } if (x2 < x) { Array.Resize <Complex>(ref Row, x2); Array.Resize <int>(ref Offset, x2); c = x2; } } } Node.Expression.Preview(new GraphBitmap(FractalGraph.ToBitmap(ColorIndex, Width, Height, Palette))); double[] Boundary = FractalGraph.FindBoundaries(ColorIndex, Width, Height); FractalGraph.Smooth(ColorIndex, Boundary, Width, Height, N, Palette, Node, Variables); return(new FractalGraph(FractalGraph.ToBitmap(ColorIndex, Width, Height, Palette), r0, i0, r1, i1, rDelta * 2, true, Node, FractalZoomScript, State)); }
public Facade() { this.obj1 = new Obj1(); this.obj2 = new Obj2(); }
/// <summary> /// Spawna un Obj2 sulla posizione dello spawner /// </summary> public void SpawnObj2() { Obj2 obj = (manager.GetFirstAvaiableObject <Obj2>() as Obj2); obj.SetPosition(transform.position); }
public static FractalGraph CalcNewtonSmooth(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, SKColor[] Palette, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { double RRe = R.Real; double RIm = R.Imaginary; double r0, i0, r1, i1; double dr, di; double r, i; double aspect; int x, y; int n, N; N = Palette.Length; if (Width <= 2 || Height <= 2) { throw new ScriptRuntimeException("Width and Height has to be greater than 2.", Node); } Variables v = new Variables(); Variables.CopyTo(v); if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } int Size = Width * Height; double Conv = 1e-10; double Div = 1e10; double[] ColorIndex = new double[Size]; int Index = 0; Complex[] Row; Complex[] Row2; Complex[] Row3; int[] Offset; IElement[] P = new IElement[1]; int j, c, x2; IElement Obj, Obj2; double Mod; Complex z; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width, r = r0; x < Width; x++, r += dr, x2++) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; if (Row2 is null || Row3 is null) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + " and " + Obj2.GetType().FullName, Node); }
public static FractalGraph CalcNewton(double rCenter, double iCenter, double rDelta, Complex R, ILambdaExpression f, ScriptNode fDef, Variables Variables, int N, int Width, int Height, ScriptNode Node, FractalZoomScript FractalZoomScript, object State) { double RRe = R.Real; double RIm = R.Imaginary; List <double> AttractorsR = new List <double>(); List <double> AttractorsI = new List <double>(); List <int> AttractorColors = new List <int>(); double[] AttractorsR2 = new double[0]; double[] AttractorsI2 = new double[0]; int[] AttractorsColors2 = new int[0]; double r0, i0, r1, i1; double dr, di; double r, i; double zr, zi; double aspect; int x, y, b, c, d; int NrAttractors = 0; int n; int index; Variables v = new Variables(); Variables.CopyTo(v); if (!(f is IDifferentiable Differentiable) || !(Differentiable.Differentiate(Differentiable.DefaultVariableName, v) is ILambdaExpression fPrim)) { throw new ScriptRuntimeException("Lambda expression not differentiable.", Node); } int size = Width * Height * 4; double Conv = 1e-10; double Div = 1e10; double Conv2 = Conv * 2; byte[] rgb = new byte[size]; Complex[] Row; Complex[] Row2; Complex[] Row3; int[] Offset; IElement[] P = new IElement[1]; int j, x2; IElement Obj, Obj2; double Mod; Complex z; rDelta *= 0.5; r0 = rCenter - rDelta; r1 = rCenter + rDelta; aspect = ((double)Width) / Height; i0 = iCenter - rDelta / aspect; i1 = iCenter + rDelta / aspect; dr = (r1 - r0) / Width; di = (i1 - i0) / Height; for (y = 0, i = i0, index = 0; y < Height; y++, i += di) { Row = new Complex[Width]; Offset = new int[Width]; c = Width; for (x = 0, x2 = y * Width * 4, r = r0; x < Width; x++, r += dr, x2 += 4) { Row[x] = new Complex(r, i); Offset[x] = x2; } n = 0; while (n < N && c > 0) { n++; P[0] = Expression.Encapsulate(Row); Obj = f.Evaluate(P, v); Obj2 = fPrim.Evaluate(P, v); Row2 = Obj.AssociatedObjectValue as Complex[]; Row3 = Obj2.AssociatedObjectValue as Complex[]; if (Row2 is null || Row3 is null) { throw new ScriptRuntimeException("Lambda expression (and its first derivative) must be able to accept complex vectors, " + "and return complex vectors of equal length. Type returned: " + Obj.GetType().FullName + " and " + Obj2.GetType().FullName, Node); }