Example #1
0
 public virtual void Begin (DrawBatch drawBatch)
 {
     drawBatch.Begin(DrawSortMode.Deferred, null, null, null, GetCommonRasterizerState(), null, Matrix.Identity);
 }
Example #2
0
        private Vector2 BeginDrawInner(DrawBatch drawBatch, SamplerState samplerState)
        {
            SetupRasterizerState(drawBatch.GraphicsDevice);

            Vector2 offset = GetOffset();
            Matrix transform = Matrix.CreateTranslation(offset.X, offset.Y, 0);

            drawBatch.Begin(DrawSortMode.Deferred, BlendState.NonPremultiplied, samplerState, null, _rasterState, null, transform);

            return offset;
        }
Example #3
0
        private void DrawObjectAction(DrawBatch drawBatch)
        {
            if (_sourceImage == null)
                return;

            drawBatch.GraphicsDevice.ScissorRectangle = Xna.Rectangle.Empty;

            if (_objectBrush == null)
                _objectBrush = new TextureBrush(_sourceImage.CreateTexture(_drawControl.GraphicsDevice)) { OwnsTexture = true };
            if (_maskPen == null)
                _maskPen = new Pen(new CheckerBrush(_drawControl.GraphicsDevice, Xna.Color.Black, Xna.Color.White, 4, .75f), true);

            int originX = (_drawControl.Width - _sourceImage.Width) / 2;
            int originY = (_drawControl.Height - _sourceImage.Height) / 2;

            _objectBrush.Transform = Xna.Matrix.CreateTranslation(-(float)originX / _sourceImage.Width, -(float)originY / _sourceImage.Height, 0);

            drawBatch.Begin();

            drawBatch.FillRectangle(_objectBrush, new Xna.Rectangle(originX, originY, _sourceImage.Width, _sourceImage.Height));
            drawBatch.DrawRectangle(_maskPen, new Microsoft.Xna.Framework.Rectangle(
                originX - 1 + (_maskLeft ?? 0) + (_originX ?? 0),
                originY - 1 + (_maskTop ?? 0) + (_originY ?? 0),
                1 + (_maskRight - _maskLeft) ?? 0,
                1 + (_maskBottom - _maskTop) ?? 0));

            drawBatch.FillCircle(Brush.White, new Xna.Vector2(originX + _originX ?? 0, originY + _originY ?? 0), 4, 12);
            drawBatch.FillCircle(Brush.Black, new Xna.Vector2(originX + _originX ?? 0, originY + _originY ?? 0), 3, 12);

            drawBatch.End();
        }