public static void Line(float x0, float y0, float x1, float y1, Color32 color) { Line((int)x0, (int)y0, (int)x1, (int)y1, color); }
public static void Line(Vector2Int p1, Vector2Int p2, Color32 color) { Line(p1.x, p1.y, p2.x, p2.y, color); }
// public static void DrawLine(Vector3 p1, Vector3 p2, Color32 color, int steps = 2) // { // var a = WorldToScreenPoint2(p1); // var b = WorldToScreenPoint2(p2); // if (a.broke && b.broke) return; // if (steps <= 0) return; // // if (Vector3.Distance(p1, p2) < .001f) return; // if (a.broke) { // var diff = p2 - p1; // DrawLine(p1, p1 + (diff/2), color, steps - 1); // return; // } // if (b.broke) { // var diff = p1 - p2; // DrawLine(p2, p2 + (diff/2), color, steps - 1); // return; // } // DrawLine(a.point, b.point, color); // } public static void Line(Vector2 p1, Vector2 p2, Color32 color) { Line(new Vector2Int((int)p1.X, (int)p1.Y), new Vector2Int((int)p2.X, (int)p2.Y), color); }
public static void PixelBuffer(PixelBuffer texture, int x, int y, Rect rect, Transform2D transform) { int twidth = texture.width; double radians = transform.rotation * 0.0174532925199; x += offsetX; y += offsetY; int sx = (int)rect.x; int sy = (int)rect.y; int sw = (int)rect.width; int sh = (int)rect.height; x -= sx; y -= sy; double c = Math.Cos(radians); double s = Math.Sin(radians); for (int i = sx; i < sx + sw; i++) { for (int j = sy; j < sy + sh; j++) { // Figure out the target x and y position int dx = i; int dy = j; // Don't bother with the math if we aren't rotating if (transform.rotation != 0) { // Determine offset int ii = i - (int)transform.origin.X; int jj = j - (int)transform.origin.Y; dx = (int)(ii * c - jj * s); dy = (int)(jj * c + ii * s); } if (dx + x < 0 || dx + x >= textureWidth) { continue; } if (dy + y < 0 || dy + y >= textureHeight) { continue; } // Determine the pixel from the source texture to be used int tx = i; int ty = j; Color32 tcol = texture.pixels[(ty * twidth) + tx]; if (tcol.a == 0) { continue; } // Draw to screen int index = ((dy + y) * textureWidth) + (dx + x); colorBuffer[index] = tcol; } } }
public static void Clear(Color32 clearColor) { new Span <Color32>(colorBuffer).Fill(clearColor); }
public static void SetFogProperties(Color32 clr, float startDist, float dist) { fogColor = clr; fogStart = startDist; fogDistance = dist; }