Ejemplo n.º 1
0
 /// <summary>
 /// Draws anti-aliased line and calls <paramref name="draw"/> on every pixel
 /// </summary>
 /// <remarks>
 /// https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
 /// </remarks>
 public static void RasterAALine(Vector2Int v0, Vector2Int v1, Action<int, int, float> draw)
 {
     RasterAALine(v0.x, v0.y, v1.x, v1.y, draw);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Dot Product of two vectors
 /// </summary>
 public static int Dot(Vector2Int lhs, Vector2Int rhs)
 {
     return lhs.x*rhs.x + lhs.y*rhs.y;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Draws filled aliased circle and calls <paramref name="draw"/> on every pixel
 /// </summary>
 public static void RasterFilledCircle(Vector2Int v0, int radius, Action<int, int> draw)
 {
     RasterFilledCircle(v0.x, v0.y, radius, draw);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Draws filled circle on texture using Bresenham's algorithm
 /// </summary>
 public static void DrawFilledCircle(this Texture2D texture, Vector2Int center, int radius, Color color)
 {
     PTUtils.DrawFilledCircle(center, radius, (x, y) => texture.SetPixel(x, y, color));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Draws anti-aliased line on texture
 /// </summary>
 public static void DrawAALine(this Texture2D texture, Vector2Int v0, Vector2Int v1, Color color)
 {
     PTUtils.DrawAALine(v0, v1,
         (x, y, t) => texture.SetPixel(x, y, Color.Lerp(texture.GetPixel(x, y), color, t)));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Draws line on texture
 /// </summary>
 public static void DrawLine(this Texture2D texture, Vector2Int v0, Vector2Int v1, Color color)
 {
     PTUtils.DrawLine(v0, v1, (x, y) => texture.SetPixel(x, y, color));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Draws circle on texture
 /// </summary>
 public static void DrawCircle(this Texture2D texture, Vector2Int center, int radius, Color color)
 {
     Draw.RasterCircle(center, radius, (x, y) => texture.SetPixel(x, y, color));
 }