/** * Gets the last x coordinate contained by a line. * * @param line * The line relative to the first line of this rectangle. */ public final int getLineEndX(int line) { return getLineStartX(line) + this.width - 1; }
@Override public ShortPoint2D next() { if (relativeY < height && width > 0) { int x = getLineStartX(relativeY) + relativeX; int y = getLineY(relativeY); ShortPoint2D pos = new ShortPoint2D(x, y); relativeX++; if (relativeX >= width) { relativeX = 0; relativeY++; } return pos; } else { throw new NoSuchElementException("There are no more elements in the shape"); } }
@Override public boolean iterate(IBooleanCoordinateFunction function) { for (int relativeY = 0; relativeY < height; relativeY++) { int lineStartX = getLineStartX(relativeY); for (int relativeX = 0; relativeX < width; relativeX++) { int x = lineStartX + relativeX; int y = getLineY(relativeY); if (!function.apply(x, y)) { return false; } } } return true; } };
public final boolean contains(int x, int y) { if (!containsLine(y)) { return false; } return !(x < getLineStartX(y - getMinY()) || x > getLineEndX(y - getMinY())); }
private ScreenIterator() { currentX = base.getLineStartX(0); next = new ShortPoint2D(currentX, base.getLineY(0)); if (!contains(next)) { next = searchNext(); } }
private ShortPoint2D searchNext() { int startLine = currentLine; while (startLine >= currentLine - 2 || currentLine < MIN_SEARCH_LINES) { currentX++; if (currentX > base.getLineEndX(currentLine)) { currentLine++; currentX = base.getLineStartX(currentLine); } int x = currentX; int y = base.getLineY(currentLine); if (contains(x, y)) { return new ShortPoint2D(x, y); } } return null; }
int maxB = area.getHeight(); int b = y - area.getMinY(); int a = x - area.getLineStartX(b); float leftVolume, rightVolume;
int line = (int) (Math.random() * screen.getHeight()); int x0 = screen.getLineStartX(line); int x = x0 + (int) (Math.random() * screen.getWidth()); int y = screen.getLineY(line);
int startX = Math.max(area.getLineStartX(line), 0); for (int x = startX; x <= endX; x++) { drawTile(x, y);