Beispiel #1
0
    // Add a flower shape.
    private void CreateFlower()
    {
      // Define single flower petal.
      var petalPath = new Path2F
      {
        new PathKey2F
        {
          Parameter = 0,
          Interpolation = SplineInterpolation.Bezier,
          Point = new Vector2F(0, 0),
          TangentIn = new Vector2F(0, 0),
          TangentOut = new Vector2F(-0.2f, 0.2f)
        },
        new PathKey2F
        {
          Parameter = 1,
          Interpolation = SplineInterpolation.Bezier,
          Point = new Vector2F(0, 1),
          TangentIn = new Vector2F(-0.3f, 1.1f),
          TangentOut = new Vector2F(0.3f, 1.1f)
        },
        new PathKey2F
        {
          Parameter = 2,
          Interpolation = SplineInterpolation.Bezier,
          Point = new Vector2F(0, 0),
          TangentIn = new Vector2F(0.2f, 0.2f),
          TangentOut = new Vector2F(0, 0)
        }
      };

      var petal = new PathFigure2F();
      petal.Segments.Add(petalPath);

      // Duplicate and rotate flower petal several times.
      const int numberOfPetals = 9;
      var flower = new CompositeFigure();
      flower.Children.Add(petal);
      for (int i = 1; i < numberOfPetals; i++)
      {
        var transformedPetal = new TransformedFigure(petal)
        {
          Pose = new Pose(Matrix33F.CreateRotationZ(i * ConstantsF.TwoPi / numberOfPetals))
        };
        flower.Children.Add(transformedPetal);
      }

      var flowerNode = new FigureNode(flower)
      {
        Name = "Flower",
        StrokeThickness = 2,
        StrokeColor = new Vector3F(1, 0.2f, 0.2f),
        FillColor = new Vector3F(1, 0.5f, 0.5f),
        FillAlpha = 1,
        PoseLocal = new Pose(new Vector3F(3, 1, 0)),
        ScaleLocal = new Vector3F(0.5f)
      };
      _scene.Children.Add(flowerNode);
    }
Beispiel #2
0
        private void CreateGate()
        {
            // not gate
            var trianglePath = new Path2F
            {
                new PathKey2F
                {
                    Parameter = 0,
                    Interpolation = SplineInterpolation.Linear,
                    Point = new Vector2F(1, 0),
                },
                new PathKey2F
                {
                    Parameter = 1,
                    Interpolation = SplineInterpolation.Linear,
                    Point = new Vector2F(-0.25f, 0.5f),
                },
                new PathKey2F
                {
                    Parameter = 2,
                    Interpolation = SplineInterpolation.Linear,
                    Point = new Vector2F(-0.25f, -0.5f),
                },
                new PathKey2F
                {
                    Parameter = 3,
                    Interpolation = SplineInterpolation.Linear,
                    Point = new Vector2F(1, 0),
                }
            };

            var triangle = new PathFigure2F();
            triangle.Segments.Add(trianglePath);
            var outPinFigure = new PathFigure2F
            {
                Segments = {
                    new LineSegment2F() { Point1 = new Vector2F(1, 0), Point2 = new Vector2F(1.2f, 0) }
                }
            };

            // Add figure to the scene.
            var notGateNode = new FigureNode(triangle)
            {
                Name = "Not Gate",
                StrokeThickness = 2,
                StrokeColor = new Vector3F(1, 0.2f, 0.2f),
                FillColor = new Vector3F(1, 0.5f, 0.5f),
                FillAlpha = 0.5f,
                PoseLocal = new Pose(new Vector3F(0, 0, 0)),
                ScaleLocal = new Vector3F(1),
                Children = new SceneNodeCollection(3),
            };

            var pinFigure = new PathFigure2F
            {
                Segments =
                {
                    new LineSegment2F { Point1 = new Vector2F(0, 0), Point2 = new Vector2F(0.2f, 0) }
                }
            };
            var pinsFigure = new CompositeFigure();

            var output = new TransformedFigure(pinFigure)
            {
                Pose = new Pose(new Vector3F(1.0f, 0, 0))
            };
            pinsFigure.Children.Add(output);

            var ina = new TransformedFigure(pinFigure)
            {
                Pose = new Pose(new Vector3F(-0.25f - 0.2f, -0.25f, 0))
            };
            pinsFigure.Children.Add(ina);

            var inb = new TransformedFigure(pinFigure)
            {
                Pose = new Pose(new Vector3F(-0.25f - 0.2f, 0.25f, 0))
            };
            pinsFigure.Children.Add(inb);

            notGateNode.Children.Add(new FigureNode(pinsFigure)
            {
                Name = "Pins",
                StrokeThickness = 2,
                StrokeColor = new Vector3F(0, 0, 0),
                PoseLocal = new Pose(new Vector3F(0, 0, 0)),
                ScaleLocal = new Vector3F(1f),
            });


            Scene.Children.Add(notGateNode);
        }
Beispiel #3
0
    // Add a chain-like figure using TransformedFigure and CompositeFigure.
    private void CreateChain()
    {
      var ellipse = new EllipseFigure
      {
        IsFilled = false,
        RadiusX = 1f,
        RadiusY = 1f,
      };

      var compositeFigure = new CompositeFigure();
      for (int i = 0; i < 9; i++)
      {
        var transformedEllipse = new TransformedFigure(ellipse)
        {
          Scale = new Vector3F(0.4f, 0.2f, 1),
          Pose = new Pose(new Vector3F(-2 + i * 0.5f, 0, 0), Matrix33F.CreateRotationX(ConstantsF.PiOver2 * (i % 2)))
        };
        compositeFigure.Children.Add(transformedEllipse);
      }

      _scene.Children.Add(new FigureNode(compositeFigure)
      {
        Name = "Chain",
        StrokeThickness = 2,
        StrokeColor = new Vector3F(0.1f),
        StrokeAlpha = 1,
        PoseLocal = new Pose(new Vector3F(0, 3, 0)),
      });
    }