コード例 #1
0
        public void Draw(Texture2D texture, RectangleF targetRectangle, RectangleF?sourceRectangle, Color color, Vector2 origin, QuadEffects effects, float layerDepth)
        {
            PrepareGroup();

            if (targetRectangle.Width == 0 || targetRectangle.Height == 0)
            {
                // Empty draw, ignore it
                return;
            }

            var bounds = texture.Bounds;
            var s      = new Vector2I(bounds.Width, bounds.Height);

            var entry = new BatchEntry();

            entry.Texture       = texture;
            entry.Color         = color;
            entry.SourceRect    = sourceRectangle ?? new RectangleF(0, 0, s.X, s.Y);
            entry.Origin        = origin;
            entry.SpriteEffects = effects;
            entry.Transform     =
                Matrix.CreateScale(targetRectangle.Width / entry.SourceRect.Width, targetRectangle.Height / entry.SourceRect.Height, 1.0f) *
                Matrix.CreateTranslation(targetRectangle.X, targetRectangle.Y, 0);

            currentBatch.Entries.Add(entry);
        }
コード例 #2
0
        public void Draw(Texture2D texture, Matrix transform, RectangleF?sourceRectangle, Color color, Vector2 origin, QuadEffects effects, float layerDepth)
        {
            PrepareGroup();

            var bounds = texture.Bounds;
            var s      = new Vector2I(bounds.Width, bounds.Height);

            var entry = new BatchEntry();

            entry.Texture       = texture;
            entry.Color         = color;
            entry.SourceRect    = sourceRectangle ?? new RectangleF(0, 0, s.X, s.Y);
            entry.Origin        = origin;
            entry.SpriteEffects = effects;
            entry.Transform     = transform;

            currentBatch.Entries.Add(entry);
        }