Пример #1
0
        public void render(org.mini2Dx.core.Graphics g, float x, float y, float width, float height)
        {
            var newTint      = _setColor.copy().multiply(g.getTint());
            var oldTint      = g.getTint();
            var middleWidth  = (int)(width - _leftWidth - _rightWidth);
            var middleHeight = (int)(height - _topHeight - _bottomHeight);

            g.setTint(newTint);

            _ninePatchRegion.setRegionX(_textureRegionX);
            _ninePatchRegion.setRegionY(_textureRegionY);
            _ninePatchRegion.setRegionWidth((int)_leftWidth);
            _ninePatchRegion.setRegionHeight((int)_topHeight);
            draw(g, _ninePatchRegion, x, y, _leftWidth, _topHeight);
            _ninePatchRegion.setRegionX(_textureRegionX + (int)_leftWidth);
            _ninePatchRegion.setRegionWidth((int)_middleWidth);
            draw(g, _ninePatchRegion, x + _leftWidth, y, middleWidth, _topHeight);
            _ninePatchRegion.setRegionX(_textureRegionX + (int)_rightX);
            _ninePatchRegion.setRegionWidth((int)_rightWidth);
            draw(g, _ninePatchRegion, x + width - _rightWidth, y, _rightWidth, _topHeight);
            _ninePatchRegion.setRegionY(_textureRegionY + (int)_topHeight);
            _ninePatchRegion.setRegionHeight((int)_middleHeight);
            draw(g, _ninePatchRegion, x + width - _rightWidth, y + _topHeight, _rightWidth, middleHeight);
            _ninePatchRegion.setRegionX(_textureRegionX + (int)_leftWidth);
            _ninePatchRegion.setRegionWidth((int)_middleWidth);
            draw(g, _ninePatchRegion, x + _leftWidth, y + _topHeight, middleWidth, middleHeight);
            _ninePatchRegion.setRegionX(_textureRegionX);
            _ninePatchRegion.setRegionWidth((int)_leftWidth);
            draw(g, _ninePatchRegion, x, y + _topHeight, _leftWidth, middleHeight);
            _ninePatchRegion.setRegionY(_textureRegionY + (int)_bottomY);
            _ninePatchRegion.setRegionHeight((int)_bottomHeight);
            draw(g, _ninePatchRegion, x, y + height - _bottomHeight, _leftWidth, _bottomHeight);
            _ninePatchRegion.setRegionX(_textureRegionX + (int)_leftWidth);
            _ninePatchRegion.setRegionWidth((int)_middleWidth);
            draw(g, _ninePatchRegion, x + _leftWidth, y + height - _bottomHeight, middleWidth, _bottomHeight);
            _ninePatchRegion.setRegionX(_textureRegionX + (int)_rightX);
            _ninePatchRegion.setRegionWidth((int)_rightWidth);
            draw(g, _ninePatchRegion, x + width - _rightWidth, y + height - _bottomHeight, _rightWidth, _bottomHeight);
            g.setTint(oldTint);
        }
Пример #2
0
        public void render(org.mini2Dx.core.Graphics g, float x, float y, float width, float height)
        {
            var newTint = _setColor.copy().multiply(g.getTint());
            var oldTint = g.getTint();

            g.setTint(newTint);

            _ninePatchRegion = new MonoGameTextureRegion(_textureRegion);

            _ninePatchRegion.setRegionX(0);
            _ninePatchRegion.setRegionY(0);
            _ninePatchRegion.setRegionWidth((int)_leftWidth);
            _ninePatchRegion.setRegionHeight((int)_topHeight);
            draw(g, _ninePatchRegion, x, y, _leftWidth, _topHeight);
            _ninePatchRegion.setRegionX((int)_leftWidth);
            _ninePatchRegion.setRegionWidth((int)(_textureRegion.getRegionWidth() - _leftWidth - _rightWidth));
            draw(g, _ninePatchRegion, x + _leftWidth, y, width - _leftWidth - _rightWidth, _topHeight);
            _ninePatchRegion.setRegionX((int)(_textureRegion.getRegionWidth() - _rightWidth));
            _ninePatchRegion.setRegionWidth((int)_rightWidth);
            draw(g, _ninePatchRegion, x + width - _rightWidth, y, _rightWidth, _topHeight);
            _ninePatchRegion.setRegionY((int)_topHeight);
            _ninePatchRegion.setRegionHeight((int)(_textureRegion.getRegionHeight() - _topHeight - _bottomHeight));
            draw(g, _ninePatchRegion, x + width - _rightWidth, y + _topHeight, _rightWidth, height - _topHeight - _bottomHeight);
            _ninePatchRegion.setRegionX((int)_leftWidth);
            _ninePatchRegion.setRegionWidth((int)(_textureRegion.getRegionWidth() - _leftWidth - _rightWidth));
            draw(g, _ninePatchRegion, x + _leftWidth, y + _topHeight, width - _leftWidth - _rightWidth, height - _topHeight - _bottomHeight);
            _ninePatchRegion.setRegionX(0);
            _ninePatchRegion.setRegionWidth((int)_leftWidth);
            draw(g, _ninePatchRegion, x, y + _topHeight, _leftWidth, height - _topHeight - _bottomHeight);
            _ninePatchRegion.setRegionY((int)(_textureRegion.getRegionHeight() - _bottomHeight));
            _ninePatchRegion.setRegionHeight((int)_bottomHeight);
            draw(g, _ninePatchRegion, x, y + height - _bottomHeight, _leftWidth, _bottomHeight);
            _ninePatchRegion.setRegionX((int)_leftWidth);
            _ninePatchRegion.setRegionWidth((int)(_textureRegion.getRegionWidth() - _leftWidth - _rightWidth));
            draw(g, _ninePatchRegion, x + _leftWidth, y + height - _bottomHeight, width - _leftWidth - _rightWidth, _bottomHeight);
            _ninePatchRegion.setRegionX((int)(_textureRegion.getRegionWidth() - _rightWidth));
            _ninePatchRegion.setRegionWidth((int)_rightWidth);
            draw(g, _ninePatchRegion, x + width - _rightWidth, y + height - _bottomHeight, _rightWidth, _bottomHeight);
            g.setTint(oldTint);
        }