Ejemplo n.º 1
0
        protected void CreateRects(Random rnd)
        {
            PTransformActivity rotActivity;
            P3Path             rect;

            // Create a bunch of animated rectangles
            for (int x = 0; x < 2000; x += 100)
            {
                for (int y = 200; y < 1500; y += 100)
                {
                    int w = 200;
                    int h = 200;
                    rect       = P3Path.CreateRectangle(x, y, w, h);
                    rect.Brush = new SolidBrush(Color.FromArgb(50, Color.Purple.R, Color.Purple.G, Color.Purple.B));
                    rect.Pen   = new Pen(Color.Red, 0);
                    canvas.Layer.AddChild(rect);

                    PMatrix matrix = new PMatrix();
                    matrix.RotateBy(90, x + w / 2, y + h / 2);
                    rotActivity           = rect.AnimateToMatrix(matrix, 5000 + (long)(2000 * rnd.NextDouble()));
                    rotActivity.LoopCount = 1000;
                    rotActivity.Mode      = ActivityMode.SourceToDestinationToSource;
                }
            }
        }
Ejemplo n.º 2
0
        public override void Initialize()
        {
            int numNodes = 50;
            int numEdges = 50;

            // Initialize, and create a layer for the edges (always underneath the nodes)
            PLayer nodeLayer = Canvas.Layer;
            PLayer edgeLayer = new PLayer();

            Canvas.Root.AddChild(edgeLayer);
            Canvas.Camera.AddLayer(0, edgeLayer);
            Random rnd = new Random();

            // Create some random nodes
            // Each node's Tag has an ArrayList used to store associated edges
            for (int i = 0; i < numNodes; i++)
            {
                float  x    = (float)(ClientSize.Width * rnd.NextDouble());
                float  y    = (float)(ClientSize.Height * rnd.NextDouble());
                P3Path node = P3Path.CreateEllipse(x, y, 20, 20);

                node.Tag = new ArrayList();
                nodeLayer.AddChild(node);
            }

            // Create some random edges
            // Each edge's Tag has an ArrayList used to store associated nodes
            for (int i = 0; i < numEdges; i++)
            {
                int n1 = rnd.Next(numNodes);
                int n2 = n1;
                while (n2 == n1)
                {
                    n2 = rnd.Next(numNodes);                      // Make sure we have two distinct nodes.
                }

                PNode  node1 = nodeLayer[n1];
                PNode  node2 = nodeLayer[n2];
                P3Path edge  = P3Path.CreateLine((node1.Bounds.Left + node1.Bounds.Right) / 2, (node1.Bounds.Top + node1.Bounds.Bottom) / 2,
                                                 (node2.Bounds.Left + node2.Bounds.Right) / 2, (node2.Bounds.Top + node2.Bounds.Bottom) / 2);

                ((ArrayList)node1.Tag).Add(edge);
                ((ArrayList)node2.Tag).Add(edge);
                edge.Tag = new ArrayList();
                ((ArrayList)edge.Tag).Add(node1);
                ((ArrayList)edge.Tag).Add(node2);

                edgeLayer.AddChild(edge);
            }

            // Create event handler to move nodes and update edges
            nodeLayer.AddInputEventListener(new NodeDragHandler());
        }
Ejemplo n.º 3
0
        protected void CreateLines()
        {
            // Create a bunch of lines
            for (int x = 0; x < 1000; x += 10)
            {
                P3Path line = P3Path.CreateLine(10, 60, 10 + x, 200);
                line.Pen = new Pen(Color.Orange, 0);
                canvas.Layer.AddChild(line);

                line     = P3Path.CreateLine(500, 60, 1000 - x, 200);
                line.Pen = new Pen(Color.Purple, 0);
                canvas.Layer.AddChild(line);
            }
        }
Ejemplo n.º 4
0
        protected void CreatePath(Random rnd)
        {
            PTransformActivity rotActivity;

            // Create a path
            P3Path path = P3Path.CreateEllipse(0, 0, 100, 100);

            path.Brush = Brushes.Red;
            path.AddLine(0, 0, 20, 20);
            path.AddLine(20, 20, 34, 67);
            path.AddArc(0, 30, 30, 30, 30, 30);
            path.Tolerance = .002f;
            canvas.Layer.AddChild(path);

            PMatrix rMatrix = new PMatrix();
            PointF  center  = PUtil.CenterOfRectangle(path.Bounds);

            rMatrix.RotateBy(90, center.X, center.Y);
            rotActivity           = path.AnimateToMatrix(rMatrix, 2000 + (long)(2000 * rnd.NextDouble()));
            rotActivity.LoopCount = 1000;
            rotActivity.Mode      = ActivityMode.SourceToDestinationToSource;
        }