Sha256: 74f55d5c6a9ed8cdaf4b060cd8d685b705a365c1fe2f00c34da452f1af1a429b
Contents?: true
Size: 956 Bytes
Versions: 9
Compression:
Stored size: 956 Bytes
Contents
package wordcram; import processing.core.PApplet; import processing.core.PVector; public class SpiralWordNudger implements WordNudger { // Who knows? this seems to be good, but it seems to depend on the font -- // bigger fonts need a bigger thetaIncrement. private float thetaIncrement = (float) (Math.PI * 0.03); @Override public PVector nudgeFor(Word w, int attempt) { float rad = powerMap(0.6f, attempt, 0, 600, 1, 100); thetaIncrement = powerMap(1, attempt, 0, 600, 0.5f, 0.3f); float theta = thetaIncrement * attempt; float x = PApplet.cos(theta) * rad; float y = PApplet.sin(theta) * rad; return new PVector(x, y); } private float powerMap(float power, float v, float min1, float max1, float min2, float max2) { float val = PApplet.norm(v, min1, max1); val = PApplet.pow(val, power); return PApplet.lerp(min2, max2, val); } }
Version data entries
9 entries across 9 versions & 1 rubygems