Beispiel #1
0
        public static void DrawImage(this IGsGraphics graphics, ImageParams data, GsColor color, GsVector offset, float rotation, GsImageFlip flip)
        {
            var size = data.ImageSize.ToVector() * data.Scale;
            var dest = new GsRectangle(data.Position + offset, size.ToSize());

            graphics.DrawImage(data.Image, dest, null, data.Origin, rotation, flip, color);
        }
Beispiel #2
0
        public static void DrawImage(this IGsGraphics graphics, ImageParams data, GsColor color, GsRectangle source)
        {
            var size = data.ImageSize.ToVector() * data.Scale;
            var dest = new GsRectangle(data.Position, size.ToSize());

            graphics.DrawImage(data.Image, dest, source, data.Origin, 0f, GsImageFlip.None, color);
        }
        public override void Draw(DrawParams dparams)
        {
            var         graphics = dparams.Graphics;
            var         offset   = dparams.Offset;
            ImageParams data     = GetTextureDrawData(offset);

            graphics.DrawImage(data, Color, Orientation);
        }
Beispiel #4
0
        protected virtual void DrawWeaponTower(DrawParams dparams, GsVector offset)
        {
            ImageParams data     = GetTextureDrawData(offset);
            GsColor     color    = GsColor.Gray;
            var         graphics = dparams.Graphics;

            graphics.DrawImage(data, color, Orientation);
        }
        protected override void DrawWeaponTower(DrawParams dparams, GsVector offset)
        {
            ImageParams data   = GetTextureDrawData(offset);
            GsRectangle source = new GsRectangle(
                mIndex * FrameSize.Width, 0,
                FrameSize.Width, FrameSize.Height);
            var graphics = dparams.Graphics;

            graphics.DrawImage(data, Color, source);
        }
Beispiel #6
0
        protected override ImageParams GetTextureDrawData(GsVector offset)
        {
            var outin  = GetOutsideInsideBounds(offset);
            var bounds = outin.Outside;
            var inside = outin.Inside;

            ImageParams data  = base.GetTextureDrawData(offset);
            GsVector    scale = Calculator.ComputeScale(data.ImageSize, bounds.Size);

            return(new ImageParams(data.Image, data.ImageSize, bounds.Location, GsVector.Zero, scale));
        }
Beispiel #7
0
        /// <summary></summary>
        protected virtual GsMatrix CreateTransform(ImageParams data)
        {
            // create the matrix for transforming the center
            GsMatrix transform =
                GsMatrix.CreateTranslation(-data.Origin.X, -data.Origin.Y, 0) *
                GsMatrix.CreateRotationZ(Orientation) *
                GsMatrix.CreateScale(data.Scale.X, data.Scale.Y, 1f) *
                GsMatrix.CreateTranslation(data.Position.X, data.Position.Y, 0);

            // return the transform
            return(transform);
        }
Beispiel #8
0
        /// <summary></summary>
        protected virtual GsVector GetCenter(GsVector offset)
        {
            // get the drawing data
            ImageParams data = GetTextureDrawData(offset);

            // get the center of the image
            GsVector center = data.ImageSize.ToVector() / 2f;

            // compute the transform
            GsMatrix transform = CreateTransform(data);

            // return the center transformated
            return(GsVector.Transform(center, transform));
        }