Exemplo n.º 1
0
        public override void BeforeDraw(MousePoint p)
        {
            // in Initialize, it's too early to get UI values (!!??!!)
            t_skipper       = new Utilities.Iterativ.Skipper(6);
            t_previousPoint = new MousePoint(p.X, p.Y);

            CreateParticles(p.X, p.Y);
            t_attractor = new Effects.Particles.Attractor(new Engine.Calc.Vector(p.X, p.Y), t_force, t_expression, t_intensity);
        }
Exemplo n.º 2
0
        private void ThreadedProcess()
        {
            t_workflow.AllowInvalidate = true;

            Engine.Effects.Particles.Attractor attr1 = new Particles.Attractor(new Engine.Calc.Vector(400, 600));
            Engine.Effects.Particles.Attractor attr2 = new Particles.Attractor(new Engine.Calc.Vector(800, 600));

            Engine.Effects.Particles.Attractor[] attrs = new Particles.Attractor[2];
            attrs[0] = attr1;
            attrs[1] = attr2;

            Engine.Effects.Particles.ForceParticle[] fp = new Particles.ForceParticle[100];

            for (int i = 0; i < fp.Length; i++)
            {
                double variance = Engine.Calc.Math.Rand.NextDouble() + 1;

                fp[i] = new Particles.ForceParticle(600, 300, 10f + (float)variance, -50f + (float)variance);
            }

            // move the particles simulating animation
            for (int i = 0; i < 5000; i++)
            {
                for (int j = 0; j < fp.Length; j++)
                {
                    fp[j].Update(attrs);

                    Engine.Color.Cell c = Engine.Application.UISelectedValues.SelectedColor;
                    // draw a line between last position and current position
                    List <MousePoint> points = LinearInterpolate(fp[j].PreviousPoint, new Point((int)Math.Round(fp[j].Position.X), (int)Math.Round(fp[j].Position.Y)));

                    foreach (MousePoint p in points)
                    {
                        if (t_imageProcessed.IsOutOfBounds(p.X, p.Y))
                        {
                            continue;
                        }
                        Engine.Color.Cell img = t_imageProcessed.GetPixel(p.X, p.Y, Surface.PixelRetrievalOptions.ReturnEdgePixel);

                        t_imageProcessed.SetPixel(Engine.Calc.Color.FastAlphaBlend(c, img), p.X, p.Y, Surface.PixelSetOptions.Ignore);
                    }
                }
            }

            base.PostProcess();
        }