Advertisement
Guest User

sdadsasdasdasdasdasdasdasdasdasddasd

a guest
Oct 15th, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4.  
  5. namespace GrowaloneXNAEdition
  6. {
  7. public class BasicShapes
  8. {
  9. public Texture2D t;
  10.  
  11. public SpriteBatch sb;
  12.  
  13. public BasicShapes(GraphicsDevice device, SpriteBatch spr)
  14. {
  15. this.t = new Texture2D(device, 1, 1);
  16. Color[] data = new Color[]
  17. {
  18. Color.FromNonPremultiplied(255, 255, 255, 255)
  19. };
  20. this.t.SetData<Color>(data);
  21. this.sb = spr;
  22. }
  23.  
  24. public void FillRectangle(Rectangle rect, Color color)
  25. {
  26. this.sb.Draw(this.t, rect, color);
  27. }
  28.  
  29. public void DrawRectangle(Rectangle rect, Color color)
  30. {
  31. this.DrawLine(new Vector2((float)rect.X, (float)rect.Y), new Vector2((float)(rect.X + rect.Width), (float)rect.Y), color);
  32. this.DrawLine(new Vector2((float)rect.X, (float)rect.Y), new Vector2((float)rect.X, (float)(rect.Y + rect.Height)), color);
  33. this.DrawLine(new Vector2((float)(rect.X + rect.Width), (float)(rect.Y + rect.Height)), new Vector2((float)(rect.X + rect.Width), (float)rect.Y), color);
  34. this.DrawLine(new Vector2((float)(rect.X + rect.Width), (float)(rect.Y + rect.Height)), new Vector2((float)rect.X, (float)(rect.Y + rect.Height)), color);
  35. }
  36.  
  37. public void DrawLine(Vector2 start, Vector2 end, Color color)
  38. {
  39. Vector2 vector = end - start;
  40. float num = (float)Math.Atan2((double)vector.Y, (double)vector.X);
  41. this.sb.Draw(this.t, new Rectangle((int)start.X, (int)start.Y, (int)vector.Length(), 1), null, color, num, new Vector2(0f, 0f), 0, 0f);
  42. }
  43.  
  44. public void DrawLinedTexture(Vector2 start, Vector2 end, Texture2D texture, int thickness)
  45. {
  46. Vector2 vector = end - start;
  47. float num = (float)Math.Atan2((double)vector.Y, (double)vector.X);
  48. this.sb.Draw(texture, new Rectangle((int)start.X, (int)start.Y, (int)vector.Length(), thickness), null, Color.get_White(), num, new Vector2(-2f, (float)(thickness / 2)), 0, 0f);
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement