Sha256: e5b6049f2f83dd375fd06146b62f15219ab969dbda6042ddb8059b3c3d10c28b

Contents?: true

Size: 768 Bytes

Versions: 9

Compression:

Stored size: 768 Bytes

Contents

package wordcram;

import java.util.Random;

import processing.core.PApplet;
import processing.core.PVector;

public class UpperLeftWordPlacer implements WordPlacer {

    private final Random r = new Random();

    @Override
    public PVector place(Word word, int wordIndex, int wordsCount, int wordImageWidth, int wordImageHeight, int fieldWidth, int fieldHeight) {
        int x = getOneUnder(fieldWidth - wordImageWidth);
        int y = getOneUnder(fieldHeight - wordImageHeight);
        return new PVector(x, y);
    }

    private int getOneUnder(int limit) {
        return PApplet.round(PApplet.map(random(random(random(random(random(1.0f))))), 0, 1, 0, limit));
    }

    private float random(float limit) {
        return r.nextFloat() * limit;
    }

}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby_wordcram-2.1.1 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.1.0 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.0.6 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.0.5 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.0.4 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.0.3 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.0.2 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.0.1 src/wordcram/UpperLeftWordPlacer.java
ruby_wordcram-2.0.0 src/wordcram/UpperLeftWordPlacer.java