public static ConvertVector2 ( Sharpex2D.Math.Vector2 vector2 ) : Vector3 | ||
vector2 | Sharpex2D.Math.Vector2 | The Vector2. |
return | Vector3 |
/// <summary> /// Draws a Texture. /// </summary> /// <param name="texture">The Texture.</param> /// <param name="position">The Position.</param> /// <param name="opacity">The Opacity.</param> /// <param name="color">The Color.</param> public void DrawTexture(Texture2D texture, Vector2 position, Color color, float opacity = 1) { var dxTexture = texture as DirectXTexture; if (dxTexture == null) { throw new ArgumentException("DirectX9 expects a DirectXTexture as resource."); } _sprite.Draw(dxTexture.GetTexture(), null, DirectXHelper.ConvertVector2(position), DirectXHelper.ConvertColor(color)); }
/// <summary> /// Draws a Texture. /// </summary> /// <param name="texture">The Texture.</param> /// <param name="rectangle">The Rectangle.</param> /// <param name="opacity">The Opacity.</param> /// <param name="color">The Color.</param> public void DrawTexture(Texture2D texture, Rectangle rectangle, Color color, float opacity = 1) { var dxTexture = texture as DirectXTexture; if (dxTexture == null) { throw new ArgumentException("DirectX9 expects a DirectXTexture as resource."); } //calc percentages for scaling float scaleX = rectangle.Width / texture.Width; float scaleY = rectangle.Height / texture.Height; _sprite.Transform = Matrix.Scaling(scaleX, scaleY, 1f); _sprite.Draw(dxTexture.GetTexture(), null, DirectXHelper.ConvertVector2(new Vector2(rectangle.X / scaleX, rectangle.Y / scaleY)), DirectXHelper.ConvertColor(color)); _sprite.Transform = Matrix.Identity; }