private void Clear() { Clear(Pixel.defaultColor()); }
public void drawLine(int x1, int y1, int x2, int y2, Pixel p) { /* * source: * https://github.com/OneLoneCoder/videos/blob/master/olcConsoleGameEngine.h */ int x, y, dx, dy, dx1, dy1, px, py, xe, ye, i; dx = x2 - x1; dy = y2 - y1; dx1 = Math.Abs(dx); dy1 = Math.Abs(dy); px = 2 * dy1 - dx1; py = 2 * dx1 - dy1; if (dy1 <= dx1) { if (dx >= 0) { x = x1; y = y1; xe = x2; } else { x = x2; y = y2; xe = x1; } draw(x, y, p); for (i = 0; x < xe; i++) { x = x + 1; if (px < 0) { px = px + 2 * dy1; } else { if ((dx < 0 && dy < 0) || (dx > 0 && dy > 0)) { y = y + 1; } else { y = y - 1; } px = px + 2 * (dy1 - dx1); } draw(x, y, p); } } else { if (dy >= 0) { x = x1; y = y1; ye = y2; } else { x = x2; y = y2; ye = y1; } draw(x, y, p); for (i = 0; y < ye; i++) { y = y + 1; if (py <= 0) { py = py + 2 * dx1; } else { if ((dx < 0 && dy < 0) || (dx > 0 && dy > 0)) { x = x + 1; } else { x = x - 1; } py = py + 2 * (dx1 - dy1); } draw(x, y, p); } } }
public void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, Pixel p) { drawLine(x1, y1, x2, y2, p); drawLine(x2, y2, x3, y3, p); drawLine(x3, y3, x1, y1, p); }
public void drawString(int x, int y, string s) { drawString(x, y, s, Pixel.defaultColor()); }