Пример #1
0
 public static bool HasDefaultDisplayAttributes(I2DDisplayModifiers displayAttributes)
 {
     return((DefaultModulationColor == displayAttributes.ModulationColor) &&
            (DefaultModulationColorWithOpacity == displayAttributes.ModulationColorWithOpacity) &&
            (DefaultLayerDepth == displayAttributes.LayerDepth) &&
            (DefaultOpacity == displayAttributes.Opacity) &&
            (DefaultOpacityModifier == displayAttributes.OpacityModifier) &&
            (DefaultSpriteEffects == displayAttributes.SpriteEffects));
 }
Пример #2
0
 public static void SetDefaults(I2DDisplayModifiers displayAttributes)
 {
     if (null != displayAttributes)
     {
         displayAttributes.ModulationColor = DefaultModulationColor;
         //displayAttributes.ModulationColorWithOpacity = DefaultModulationColorWithOpacity;
         displayAttributes.LayerDepth      = DefaultLayerDepth;
         displayAttributes.Opacity         = DefaultOpacity;
         displayAttributes.OpacityModifier = DefaultOpacityModifier;
         displayAttributes.SpriteEffects   = DefaultSpriteEffects;
     }
 }
Пример #3
0
        public static void DrawLine(this SpriteBatch spriteBatch, Color color, Vector2 start, Vector2 stop, int thickness, I2DDisplayModifiers attributes, Matrix transformFromWorldToCamera)
        {
            //float scale = Camera.GetScale( 1, Camera.Zoom, attributes.ParallaxDepth );
            //Vector2 position = Camera.TranslateAbsoluteVectorToCamera( start, attributes.ParallaxDepth );
            float originalLength = Vector2.Distance(start, stop);

            start = Vector2.Transform(start, transformFromWorldToCamera);
            stop  = Vector2.Transform(stop, transformFromWorldToCamera);
            float newLength = Vector2.Distance(start, stop);
            float scale     = newLength / originalLength; //originalLength might be 0

            thickness = (int)Math.Max(1, thickness * scale);
            Vector2 position = start;

            _destinationRect.X     = (int)position.X;
            _destinationRect.Y     = (int)(position.Y + (float)thickness / 2.0f);
            _destinationRect.Width = (int)(Math.Ceiling(Vector2.Distance(start, stop)));
            if (_destinationRect.Width == 0)
            {
                _destinationRect.Width = 1;
            }
            _destinationRect.Height = thickness;

            SinglePixel pixel = SinglePixel.WhitePixel;
            float       angle = XenMath.GetAngleFloat(stop - start);

            spriteBatch.Draw(
                pixel.Asset,
                _destinationRect,
                pixel.SourceRectangle,
#if SILVERLIGHT
                new Color(color, attributes.OpacityFinal),
#else
                color *attributes.OpacityFinal,
#endif
                angle,
                Vector2.UnitY / 2.0f,
                attributes.SpriteEffects,
                attributes.LayerDepth);
        }
Пример #4
0
 public static void DrawLine(this SpriteBatch spriteBatch, Color color, Vector2 start, Vector2 stop, I2DDisplayModifiers attributes, Matrix transformFromWorldToCamera)
 {
     DrawLine(spriteBatch, color, start, stop, 1, attributes, transformFromWorldToCamera);
 }
Пример #5
0
 public static void DrawLine(this SpriteBatch spriteBatch, Color color, Vector2 start, Vector2 stop, int thickness, I2DDisplayModifiers attributes)
 {
     DrawLine(spriteBatch, color, start, stop, thickness, attributes, Matrix.Identity);
 }
Пример #6
0
 public static void DrawLine(this SpriteBatch spriteBatch, Color color, IBasicLine2D line, I2DDisplayModifiers attributes, Matrix transformFromWorldToCamera)
 {
     DrawLine(spriteBatch, color, line.Start, line.Stop, line.Thickness, attributes, transformFromWorldToCamera);
 }
Пример #7
0
 public static void DrawLine(this SpriteBatch spriteBatch, Color color, IBasicLine2D line, I2DDisplayModifiers attributes)
 {
     DrawLine(spriteBatch, color, line, attributes, Matrix.Identity);
 }
Пример #8
0
        public static void DrawPixel(this SpriteBatch spriteBatch, Color color, Vector2 position, int thickness, I2DDisplayModifiers attributes, Matrix transformFromWorldToCamera)
        {
            //float scale = Camera.GetScale( 1, Camera.Zoom, attributes.ParallaxDepth );
            //Vector2 position = Camera.TranslateAbsoluteVectorToCamera( start, attributes.ParallaxDepth );
            position  = Vector2.Transform(position, transformFromWorldToCamera);
            thickness = (int)Math.Max(1, thickness);

            _destinationRect.X     = (int)(position.X - (float)thickness / 2.0f);
            _destinationRect.Y     = (int)(position.Y + (float)thickness / 2.0f);
            _destinationRect.Width = thickness;
            if (_destinationRect.Width == 0)
            {
                _destinationRect.Width = 1;
            }
            _destinationRect.Height = thickness;

            SinglePixel pixel = SinglePixel.WhitePixel;

            spriteBatch.Draw(
                pixel.Asset,
                _destinationRect,
                pixel.SourceRectangle,
#if SILVERLIGHT
                new Color(color, attributes.Opacity),
#else
                color *attributes.OpacityFinal,
#endif
                0.0f,
                Vector2.UnitY / 2.0f,
                attributes.SpriteEffects,
                attributes.LayerDepth);
        }
Пример #9
0
 public static void DrawPixel(this SpriteBatch spriteBatch, Color color, Vector2 position, int thickness, I2DDisplayModifiers attributes)
 {
     DrawPixel(spriteBatch, color, position, thickness, attributes, Matrix.Identity);
 }
Пример #10
0
 public static void DrawPixel(this SpriteBatch spriteBatch, Color color, Vector2 position, I2DDisplayModifiers attributes, Matrix transformFromWorldToCamera)
 {
     DrawPixel(spriteBatch, color, position, 1, attributes, transformFromWorldToCamera);
 }