/// <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); }
/// <summary> /// Dot Product of two vectors /// </summary> public static int Dot(Vector2Int lhs, Vector2Int rhs) { return lhs.x*rhs.x + lhs.y*rhs.y; }
/// <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); }
/// <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)); }
/// <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))); }
/// <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)); }
/// <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)); }