Exemple #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // TODO: use this.Content to load your game content here
            _drawingContext = new DrawingContext(GraphicsDevice, GraphicsBackend.OpenGL);

            _brush1 = new SolidColorBrush(_drawingContext, Color.Black);
            _brush2 = new SolidColorBrush(_drawingContext, Color.Red);
            _brush3 = new SolidColorBrush(_drawingContext, Color.Yellow);
            _brush4 = new SolidColorBrush(_drawingContext, Color.Purple);
            _brush5 = new SolidColorBrush(_drawingContext, Color.Blue);

            _brush6 = new LinearGradientBrush(_drawingContext,
                                              new LinearGradientBrushProperties {
                StartPoint = new Vector2(305, 305),
                EndPoint   = new Vector2(405, 405)
            }, new GradientStopCollection(new[] {
                new GradientStop {
                    Color = Color.Red, Position = 0.0f
                },
                new GradientStop {
                    Color = Color.Yellow, Position = 0.4f
                },
                new GradientStop {
                    Color = Color.Blue, Position = 0.8f
                },
                new GradientStop {
                    Color = Color.Cyan, Position = 1.0f
                }
            }, Gamma.Linear, ExtendMode.Mirror));

            var pathGeometry = new PathGeometry();

            _pathGeometry1 = pathGeometry;

            var sink = pathGeometry.Open();

            sink.BeginFigure(Vector2.Zero);
            sink.AddLine(new Vector2(100, 100));
            sink.AddLine(new Vector2(0, 100));
            sink.EndFigure(FigureEnd.Closed);
            sink.Close();

            pathGeometry   = new PathGeometry();
            _pathGeometry2 = pathGeometry;

            sink = pathGeometry.Open();
            sink.BeginFigure(Vector2.Zero);
            sink.AddBezier(new BezierSegment {
                Point1 = new Vector2(100, 0),
                Point2 = new Vector2(0, 100),
                Point3 = new Vector2(100, 100)
            });
            sink.AddLine(new Vector2(100, 0));
            sink.EndFigure(FigureEnd.Closed);
            sink.Close();

            pathGeometry   = new PathGeometry();
            _pathGeometry3 = pathGeometry;

            sink = pathGeometry.Open();
            sink.BeginFigure(new Vector2(200, 200));
            sink.AddArc(new ArcSegment {
                Size           = new Vector2(50, 50),
                ArcSize        = ArcSize.Large,
                Point          = new Vector2(300, 300),
                RotationAngle  = 0,
                SweepDirection = SweepDirection.Clockwise
            });
            sink.AddArc(new ArcSegment {
                Size           = new Vector2(100, 100),
                ArcSize        = ArcSize.Large,
                Point          = new Vector2(100, 200),
                RotationAngle  = 0,
                SweepDirection = SweepDirection.Clockwise
            });
            sink.EndFigure(FigureEnd.Closed);
            sink.Close();

            _ellipseGeometry4 = new EllipseGeometry(new Ellipse {
                Point   = new Vector2(400, 50),
                RadiusX = 50,
                RadiusY = 10
            });

            _roundedRectangleGeometry5 = new RoundedRectangleGeometry(new RoundedRectangle {
                RadiusX   = 30,
                RadiusY   = 20,
                Rectangle = new RectangleF(0, 300, 100, 100)
            });

            _ellipseGeometry6 = new EllipseGeometry(new Ellipse {
                Point   = new Vector2(350, 300),
                RadiusX = 160,
                RadiusY = 120
            });

            _fontPathGeometry7 = PathGeometry.CreateFromString(_font, "Press space to start");
        }