Пример #1
0
        public IntPtr Draw(float x, float y, Action <ISpriteDrawing> pre = null, Action <ISpriteDrawing> post = null)
        {
            _drawing.SetViewport(0, Width, 0, Height);
            _drawing.DestinationTexture = _spriteTexture;
            _drawing.Clear(_settings.EditorBackground);
            pre?.Invoke(_drawing);

            int posX;
            int posY;

            if (SpriteGroup.Count > 0)
            {
                posX = -SpriteGroup.Min(x => Math.Min(x.Left, x.Right));
                posY = -SpriteGroup.Min(x => Math.Min(x.Top, x.Bottom));
            }
            else
            {
                posX = 0;
                posY = 0;
            }


            _renderer.Draw(0, _frameIndex++, posX + x, posY + y);
            _drawing.Flush();

            post?.Invoke(_drawing);
            _drawing.DestinationTexture = null;

            return(TextureId);
        }
Пример #2
0
        public IntPtr Draw(float x, float y)
        {
            _drawing.SetViewport(0, Width, 0, Height);
            _drawing.DestinationTexture = _spriteTexture;
            _drawing.Clear(_settings.EditorBackground);
            _renderer.Draw(0, _frameIndex++, x, y);
            _drawing.Flush();
            _drawing.DestinationTexture = null;

            return(TextureId);
        }
Пример #3
0
        private void DrawCropAtlasTexture()
        {
            var sLeft     = SpriteModel.Sprite.Left;
            var sTop      = SpriteModel.Sprite.Top;
            var sRight    = SpriteModel.Sprite.Right;
            var sBottom   = SpriteModel.Sprite.Bottom;
            var cropColor = _settings.EditorBackground;

            cropColor.A = 0.75f;
            var invertedCropColor = new ColorF(
                1f - cropColor.R, 1f - cropColor.G,
                1f - cropColor.G, 1.0f);

            var context = new SpriteDrawingContext()
                          .SpriteTexture(_atlasTexture)
                          .ColorDefault()
                          .SourceLTRB(0, 0, _cropAtlasTexture.Width, _cropAtlasTexture.Height)
                          .Position(0, 0)
                          .DestinationSize(_cropAtlasTexture.Width, _cropAtlasTexture.Height);

            context.TextureWrapHorizontal(TextureWrapMode.Repeat, 0, _cropAtlasTexture.Width);
            context.TextureWrapVertical(TextureWrapMode.Repeat, 0, _cropAtlasTexture.Height);

            _spriteDrawing.DestinationTexture = _cropAtlasTexture;
            _spriteDrawing.SetViewport(0, _cropAtlasTexture.Width, 0, _cropAtlasTexture.Height);
            _spriteDrawing.Clear(_settings.EditorBackground);
            _spriteDrawing.AppendSprite(context);

            _spriteDrawing.FillRectangle(0, 0, _cropAtlasTexture.Width, sTop, cropColor);
            _spriteDrawing.FillRectangle(0, sTop, sLeft, sBottom - sTop, cropColor);
            _spriteDrawing.FillRectangle(sRight, sTop, _cropAtlasTexture.Width, sBottom - sTop, cropColor);
            _spriteDrawing.FillRectangle(0, sBottom, _cropAtlasTexture.Width, _cropAtlasTexture.Height, cropColor);
            _spriteDrawing.DrawRectangle(sLeft - 1, sTop - 1,
                                         sRight - sLeft + 2, sBottom - sTop + 2, invertedCropColor);

            _spriteDrawing.Flush();
            _spriteDrawing.DestinationTexture = null;
        }