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)); }
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; } }
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); }
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); }
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); }
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); }
public static void DrawLine(this SpriteBatch spriteBatch, Color color, IBasicLine2D line, I2DDisplayModifiers attributes) { DrawLine(spriteBatch, color, line, attributes, Matrix.Identity); }
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); }
public static void DrawPixel(this SpriteBatch spriteBatch, Color color, Vector2 position, int thickness, I2DDisplayModifiers attributes) { DrawPixel(spriteBatch, color, position, thickness, attributes, Matrix.Identity); }
public static void DrawPixel(this SpriteBatch spriteBatch, Color color, Vector2 position, I2DDisplayModifiers attributes, Matrix transformFromWorldToCamera) { DrawPixel(spriteBatch, color, position, 1, attributes, transformFromWorldToCamera); }