Zoom to world position

Since github is secure against code contributions I figured I would place this here. At least I can find it later.
These are new zoom functions for the MonoGame.Extended OrthographicCamera class

    public void ZoomIn(float deltaZoom, Vector2 zoomCenter)
    {
        float pastZoom = Zoom;
        ClampZoom(Zoom + deltaZoom);
        Position += (zoomCenter - Origin - Position) * ((Zoom - pastZoom) / Zoom);
    }

    public void ZoomOut(float deltaZoom, Vector2 zoomCenter)
    {
        float pastZoom = Zoom;
        ClampZoom(Zoom - deltaZoom);
        Position += (zoomCenter - Origin - Position) * ((Zoom - pastZoom) / Zoom);
    }

They can be called like this.

        _worldPosition = _camera.ScreenToWorld(mouseState.Position.ToVector2());


        // zoom targeting the mouse
        int previousMouseWheelValue = currentMouseWheelValue;
        currentMouseWheelValue = Mouse.GetState().ScrollWheelValue;
        if (currentMouseWheelValue > previousMouseWheelValue)
        {
            _camera.ZoomIn(1 / 12f, _worldPosition);
        }
        if (currentMouseWheelValue < previousMouseWheelValue)
        {
            _camera.ZoomOut(1 / 12f, _worldPosition);
        }

What do you mean by “secure against code contributions”? You can fork, clone and submit pull requests just like every other open source project.

I actually quite like the new functions you’ve implemented here. When I get around to it I’ll probably include them in the library.

I’ve raised a github issue so that I can get back to it later.