コード例 #1
0
        protected override void StartAnimation()
        {
            //GlyphPosAnimation.Create(Bits[0], MemoryGlyph.Position, 1200, ()=>
            //{
            //    MemoryGlyph = Bits[0];
            //    Bits[0] = null;
            //});
            Bits[0].PathAnimation("Translate", new List <Vector2>
            {
                Bits[0].Translate,
                new Vector2(1, Delta * 2 + 2),
                MemoryGlyph.Translate
            }, 10, (from, to) => (from - to).Length);

            //Bit.Animation("Position", MemoryGlyph.Position, 1000);


            MemoryGlyph.PathAnimation("Translate",
                                      new List <Vector2>
            {
                MemoryGlyph.Translate,
                new Vector2(Delta * 5 + 1, Delta * 2 + 2),
                new Vector2(Delta * 5 + 1, Delta + 2),
                new Vector2(Delta * 6 + 1, Delta + 2)
            }, 10, (from, to) => (from - to).Length, () =>
            {
                EndAnimation(MemoryGlyph, 0);
                MemoryGlyph = Bits[0];
                Bits[0]     = null;
            });
        }
コード例 #2
0
        public StreamingSource(int[] message, SimpleShader simpleShader)
            : base(simpleShader, 0, 1)
        {
            Message = message;

            Size = new Vector2(Delta * (Message.Length + 1), Delta * 2);

            InstasingList.Add(new VisualUniforms(Color4.Black));
            for (int i = 0; i < Message.Length; i++)
            {
                var bit   = message[i];
                var glyph = new Glyph7x5(bit == 0?'0':'1',
                                         new Vector2(Delta * i + 4, 2),
                                         SimpleShader);
                BitMessage.Add(glyph);
                Childrens.Add(glyph);
            }
            var vertices = new List <Vector2>();

            vertices.AddRange(Polyline(new[]
            {
                new Vector2(Delta * Message.Length, 0),
                new Vector2(-1, 0),
                new Vector2(-1, Delta * 2),
                new Vector2(Delta * Message.Length, Delta * 2)
            }, 2));

            CreateOutput(0, ConnectorOrientation.Right, new Vector2(Delta * (Message.Length + 1), 0));

            Shape = vertices.ToArray();
        }
コード例 #3
0
        protected void EndAnimation(Glyph7x5 bit, int outputIndex)
        {
            if (outputIndex >= OutCount)
            {
                return;
            }

            Outputs[outputIndex].TransmitBit(bit);
        }
コード例 #4
0
            private GlyphPosAnimation(Glyph7x5 glyph, Vector2 to, uint ms, Action action = null)
            {
                To    = to;
                Glyph = glyph;
                Old   = Glyph.Translate;

                center = new Vector2(to.X, Old.Y);
                a      = To.X - Old.X;
                b      = To.Y - Old.Y;
                this.Animation("N", 1.0d, ms, () => { Dispose(); action?.Invoke(); });
            }
コード例 #5
0
 public StreamingVisual(SimpleShader simpleShader, int inCount, int outCount)
     : base(simpleShader)
 {
     _frame = new DrawingVisual(simpleShader);
     _frame.InstasingList.Add(new VisualUniforms(new Color4(0, 0, 1f, 0.3f)));
     _frame.IsVisible = false;
     Childrens.Add(_frame);
     InCount  = inCount;
     OutCount = outCount;
     Inputs   = new Edge[inCount];
     Outputs  = new Edge[outCount];
     Bits     = new Glyph7x5[inCount];
 }
コード例 #6
0
        protected override void StartAnimation()
        {
            Bits[0].Animation("Translate", new Vector2(Delta, Delta), 100, () =>
            {
                CloneBit = new Glyph7x5(Bits[0].Char, Bits[0].Translate, SimpleShader);
                CloneBit.InstasingList[0].Color = Color4.Black;
                Childrens.Add(CloneBit);
                Bits[0].Animation("Translate", OutputConnectors[0].Translate, 100, () =>
                {
                    EndAnimation(Bits[0], 0);
                    Bits[0] = null;
                });

                CloneBit.Animation("Translate", OutputConnectors[1].Translate, 100, () =>
                {
                    EndAnimation(CloneBit, 1);
                    CloneBit = null;
                });
            });
        }
コード例 #7
0
        protected override void StartAnimation()
        {
            for (int i = 0; i < BitMessage.Count - 1; i++)
            {
                BitMessage[i].Animation("Translate", BitMessage[i + 1].Translate, 500);
            }
            var last = BitMessage.Last();

            last.Animation("Translate",
                           new Vector2(Delta * (Message.Length + 1) + 1, 2), 500, () =>
            {
                EndAnimation(last, 0);
                BitMessage.Remove(last);

                var glyph = new Glyph7x5('0',
                                         new Vector2(4, 2),
                                         SimpleShader);
                BitMessage.Insert(0, glyph);
                Childrens.Add(glyph);
            });
        }
コード例 #8
0
        public StreamingSummator(SimpleShader simpleShader, int inCount)
            : base(simpleShader, inCount, 1)
        {
            Size = new Vector2(Delta * 4, Delta * 4);
            InstasingList.Add(new VisualUniforms(Color4.Black));

            var vertices = new List <Vector2>();

            var center = new Vector2(Delta * 2, Delta * 2);

            vertices.AddRange(Round(center, Delta, 2, 60));
            var l = new Vector2(Delta * 1.5f, Delta * 2);
            var r = new Vector2(Delta * 2.5f, Delta * 2);

            vertices.AddRange(Line(l, r, 2));
            var u = new Vector2(Delta * 2, Delta * 2.5f);
            var d = new Vector2(Delta * 2, Delta * 1.5f);

            vertices.AddRange(Line(u, d, 2));

            CreateInput(0, ConnectorOrientation.Left, new Vector2(0, Delta * 2));
            CreateOutput(0, ConnectorOrientation.Right, new Vector2(Delta * 4, Delta * 2));

            if (Up)
            {
                CreateInput(1, ConnectorOrientation.Top, new Vector2(Delta * 2, Delta * 4));
            }
            else if (Down)
            {
                CreateInput(1, ConnectorOrientation.Bottom, new Vector2(Delta * 2, 0));
            }

            Shape = vertices.ToArray();

            GlyphPlus = new Glyph7x5(' ', new Vector2(Delta * 1, -5), SimpleShader);
            Childrens.Add(GlyphPlus);

            GlyphEqual = new Glyph7x5(' ', new Vector2(Delta * 3, -5), SimpleShader);
            Childrens.Add(GlyphEqual);
        }
コード例 #9
0
        protected override void StartAnimation()
        {
            GlyphResult = new Glyph7x5(' ', new Vector2(Delta * 4, -5), SimpleShader);
            Childrens.Add(GlyphResult);

            Bits[0].Animation("Translate", new Vector2(0, -5), 500, () =>
            {
                GlyphResult.Char = Bits.Count(x => x.Char == '1') % 2 == 1 ? '1' : '0';
                GlyphResult.Animation("Translate", GlyphResult.Translate, 400, () =>
                {
                    GlyphPlus.Char  = ' ';
                    GlyphEqual.Char = ' ';
                    for (int i = 0; i < Bits.Length; i++)
                    {
                        var localI = i;
                        Bits[localI].Animation("Translate", Bits[localI].Translate, 200, () =>
                        {
                            Childrens.Remove(Bits[localI]);
                            Bits[localI] = null;
                        });
                        Bits[i].Char = ' ';
                    }
                    GlyphResult.Animation("Translate", new Vector2(Delta * 4 + 2, Delta * 2 + 2), 200, () =>
                    {
                        EndAnimation(GlyphResult, 0);
                        GlyphResult = null;
                    });
                });
            });

            for (int i = 1; i < Bits.Length; i++)
            {
                int localI = i;
                Bits[localI].Animation("Translate", new Vector2(Delta * 2, -5), 500);
            }
            GlyphPlus.Char  = '+';
            GlyphEqual.Char = '=';
        }
コード例 #10
0
        public StreamingRegister(SimpleShader simpleShader)
            : base(simpleShader, 1, 1)
        {
            Size = new Vector2(Delta * 6, Delta * 2);
            InstasingList.Add(new VisualUniforms(Color4.Black));
            var vertices = new List <Vector2>();

            vertices.AddRange(Rectangle(
                                  new Vector2(Delta, 0),
                                  new Vector2(Delta * 5, Delta * 2), 2));
            Shape = vertices.ToArray();

            CreateInput(0, ConnectorOrientation.Left, new Vector2(0, Delta));
            CreateOutput(0, ConnectorOrientation.Right, new Vector2(Delta * 6, Delta));

            GlyphWord.CollectionChanged += (s, e) =>
            {
                if (e.NewItems != null)
                {
                    foreach (Glyph7x5 glyph in e.NewItems)
                    {
                        Childrens.Add(glyph);
                    }
                }
                if (e.OldItems != null)
                {
                    foreach (Glyph7x5 glyph in e.OldItems)
                    {
                        Childrens.Remove(glyph);
                    }
                }
            };

            Word        = _word;
            MemoryGlyph = new Glyph7x5('0', new Vector2(Delta * 2.5f, Delta * 2 + 2), SimpleShader);
            Childrens.Add(MemoryGlyph);
        }
コード例 #11
0
 public void Dispose()
 {
     Glyph = null;
 }
コード例 #12
0
 public static void Create(Glyph7x5 glyph, Vector2 to, uint ms, Action action = null)
 {
     new GlyphPosAnimation(glyph, to, ms, action);
 }