net.sourceforge.plantuml.code.Spiral Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// 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;
}
}
}