public static void line4(int x0, int y0, int x1, int y1, Image2D image, ColorRGB color) { bool steep = false; if (Math.Abs(x0 - x1) < Math.Abs(y0 - y1)) { swap(ref x0, ref y0); swap(ref x1, ref y1); steep = true; } if (x0 > x1) { swap(ref x0, ref x1); swap(ref y0, ref y1); } int dx = x1 - x0; int dy = y1 - y0; float derror = Math.Abs(dy / (float)dx); float error = 0; int y = y0; for (int x = x0; x <= x1; x++) { if (steep) { image.setPixel(y, x, color); } else { image.setPixel(x, y, color); } error += derror; if (error > 0.5) { y += (y1 > y0 ? 1 : -1); error -= 1.0F; } } }
public static Color ColorRGBtoColor(ColorRGB value) { Color color = Color.FromArgb(value.Red, value.Green, value.Blue); return(color); }