All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.plantuml.code.SpiralOnRectangle Maven / Gradle / Ivy

There is a newer version: 1.2025.0
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.code;

public class SpiralOnRectangle {
	// ::remove file when __CORE__

	private final Spiral spiral = new Spiral();
	private final int width;
	private final int height;
	private final PairInt delta;

	public SpiralOnRectangle(int width, int height) {
		this.width = width;
		this.height = height;
		this.delta = new PairInt(width / 2, height / 2);
	}

	private boolean inside(PairInt point) {
		final int x = point.getX();
		final int y = point.getY();
		return x >= 0 && x < width && y >= 0 && y < height;
	}

	public PairInt nextPoint() {
		do {
			final PairInt result = spiral.nextPoint().plus(delta);
			if (inside(result)) {
				return result;
			}
		} while (true);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy