public static void drawHorizontalLine(int x, int y, int length, int color) {
		if (y < startY || y >= endY)
			return;
		if (x < startX) {
			length -= startX - x;
			x = startX;
		}
		if (x + length > endX)
			length = endX - x;
		int total = x + y * width;
		for (int index = 0; index < length; index++) {
			pixels[total + index] = color;
		}

	}