Esempio n. 1
0
        protected override void Initialize()
        {
            base.Initialize();

            _pointButton     = new Button(12, 12, "Point", _font, () => SwitchShape(DemoShape.Point), _spriteBatch);
            _rectButton      = new Button(12, 42, "Rectangle", _font, () => SwitchShape(DemoShape.Rectangle), _spriteBatch);
            _aaSegmentButton = new Button(12, 72, "AA Segment", _font, () => SwitchShape(DemoShape.AASegment), _spriteBatch);
            _segmentButton   = new Button(12, 102, "Segment", _font, () => SwitchShape(DemoShape.Segment), _spriteBatch);
            _circleButton    = new Button(12, 132, "Circle", _font, () => SwitchShape(DemoShape.Circle), _spriteBatch);
            _fanButton       = new Button(12, 162, "Fan", _font, () => SwitchShape(DemoShape.Fan), _spriteBatch);

            _radiusUpButton   = new Button(250, 12, "Radius Up", _font, RadiusUp, _spriteBatch);
            _radiusDownButton = new Button(250, 42, "Radius Down", _font, RadiusDown, _spriteBatch);

            _nextDirectionButton = new Button(500, 12, "Direction change", _font, DirectionChange, _spriteBatch);

            _shapeButtons = new[]
            {
                _pointButton, _rectButton, _aaSegmentButton, _segmentButton, _circleButton, _fanButton,
            };
            _shapes = new Dictionary <DemoShape, IGridShape>
            {
                [DemoShape.Point]     = new GridPoint(Center),
                [DemoShape.Rectangle] =
                    new GridRectangle(
                        GridBoundingBox.FromMinMax(
                            Center.X - _radius, Center.Y - _radius, Center.X + _radius, Center.Y + _radius)),
                [DemoShape.AASegment] = new GridAASegment(Center, Center.Translation(0, _radius)),
                [DemoShape.Segment]   = new GridSegment(Center, Center.Translation(10, 10)),
                [DemoShape.Circle]    = new GridCircle(Center, _radius),
                [DemoShape.Fan]       = new GridFan(Center, _radius, _direction8),
            };

            SwitchShape(DemoShape.Point);
        }
Esempio n. 2
0
        public void TestTranslation(int x, int y)
        {
            var c  = new GridCoordinatePair(10, 10);
            var c2 = c.Translation(x, y);

            Assert.Equal(10 + x, c2.X);
            Assert.Equal(10 + y, c2.Y);
        }