import eu.svjatoslav.sixth.e3d.renderer.raster.Color;
import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.AbstractCoordinateShape;
+/**
+ * Line in 3D space.
+ *
+ * Line is represented by two points, width and color and width.
+ */
public class Line extends AbstractCoordinateShape {
private static final double MINIMUM_WIDTH_THRESHOLD = 1;
private static final double LINE_WIDTH_MULTIPLIER = 0.2d;
+ /**
+ * width of the line.
+ */
public final double width;
- final LineInterpolator[] li = new LineInterpolator[4];
+ final LineInterpolator[] lineInterpolators = new LineInterpolator[4];
+
+ /**
+ * Color of the line.
+ */
public Color color;
public Line(final Line parentLine) {
this.color = color;
this.width = width;
- for (int i = 0; i < li.length; i++)
- li[i] = new LineInterpolator();
+ for (int i = 0; i < lineInterpolators.length; i++)
+ lineInterpolators[i] = new LineInterpolator();
}
private int getLineInterpolator(final int startPointer, final int y) {
- for (int i = startPointer; i < li.length; i++)
- if (li[i].containsY(y))
+ for (int i = startPointer; i < lineInterpolators.length; i++)
+ if (lineInterpolators[i].containsY(y))
return i;
return -1;
}
final double p2x2 = onScreenPoint2.x + xdec2;
final double p2y2 = onScreenPoint2.y - yinc2;
- li[0].setPoints(p1x1, p1y1, 1d, p2x1, p2y1, 1d);
- li[1].setPoints(p1x2, p1y2, -1d, p2x2, p2y2, -1d);
+ lineInterpolators[0].setPoints(p1x1, p1y1, 1d, p2x1, p2y1, 1d);
+ lineInterpolators[1].setPoints(p1x2, p1y2, -1d, p2x2, p2y2, -1d);
- li[2].setPoints(p1x1, p1y1, 1d, p1x2, p1y2, -1d);
- li[3].setPoints(p2x1, p2y1, 1d, p2x2, p2y2, -1d);
+ lineInterpolators[2].setPoints(p1x1, p1y1, 1d, p1x2, p1y2, -1d);
+ lineInterpolators[3].setPoints(p2x1, p2y1, 1d, p2x2, p2y2, -1d);
double ymin = p1y1;
if (p1y2 < ymin)
if (li1 != -1) {
final int li2 = getLineInterpolator(li1 + 1, y);
if (li2 != -1)
- drawHorizontalLine(li[li1], li[li2], y, buffer);
+ drawHorizontalLine(lineInterpolators[li1], lineInterpolators[li2], y, buffer);
}
}
}