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

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

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

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

	private PairInt current = new PairInt(0, 0);
	private PairInt direction = new PairInt(1, 0);
	private int step = 0;
	private int lim = 1;
	private int len = 1;
	private int cpt = 0;

	public PairInt nextPoint() {
		final PairInt result = current;
		oneStep();
		return result;
	}

	private void oneStep() {
		this.current = this.current.plus(this.direction);
		step++;
		if (step == lim) {
			this.direction = this.direction.rotate();
			cpt++;
			if (cpt == 2) {
				cpt = 0;
				len++;
			}
			lim += len;
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy